Annotation of embedaddon/nginx/src/http/ngx_http_upstream.h, revision 1.1
1.1 ! misho 1:
! 2: /*
! 3: * Copyright (C) Igor Sysoev
! 4: * Copyright (C) Nginx, Inc.
! 5: */
! 6:
! 7:
! 8: #ifndef _NGX_HTTP_UPSTREAM_H_INCLUDED_
! 9: #define _NGX_HTTP_UPSTREAM_H_INCLUDED_
! 10:
! 11:
! 12: #include <ngx_config.h>
! 13: #include <ngx_core.h>
! 14: #include <ngx_event.h>
! 15: #include <ngx_event_connect.h>
! 16: #include <ngx_event_pipe.h>
! 17: #include <ngx_http.h>
! 18:
! 19:
! 20: #define NGX_HTTP_UPSTREAM_FT_ERROR 0x00000002
! 21: #define NGX_HTTP_UPSTREAM_FT_TIMEOUT 0x00000004
! 22: #define NGX_HTTP_UPSTREAM_FT_INVALID_HEADER 0x00000008
! 23: #define NGX_HTTP_UPSTREAM_FT_HTTP_500 0x00000010
! 24: #define NGX_HTTP_UPSTREAM_FT_HTTP_502 0x00000020
! 25: #define NGX_HTTP_UPSTREAM_FT_HTTP_503 0x00000040
! 26: #define NGX_HTTP_UPSTREAM_FT_HTTP_504 0x00000080
! 27: #define NGX_HTTP_UPSTREAM_FT_HTTP_404 0x00000100
! 28: #define NGX_HTTP_UPSTREAM_FT_UPDATING 0x00000200
! 29: #define NGX_HTTP_UPSTREAM_FT_BUSY_LOCK 0x00000400
! 30: #define NGX_HTTP_UPSTREAM_FT_MAX_WAITING 0x00000800
! 31: #define NGX_HTTP_UPSTREAM_FT_NOLIVE 0x40000000
! 32: #define NGX_HTTP_UPSTREAM_FT_OFF 0x80000000
! 33:
! 34: #define NGX_HTTP_UPSTREAM_FT_STATUS (NGX_HTTP_UPSTREAM_FT_HTTP_500 \
! 35: |NGX_HTTP_UPSTREAM_FT_HTTP_502 \
! 36: |NGX_HTTP_UPSTREAM_FT_HTTP_503 \
! 37: |NGX_HTTP_UPSTREAM_FT_HTTP_504 \
! 38: |NGX_HTTP_UPSTREAM_FT_HTTP_404)
! 39:
! 40: #define NGX_HTTP_UPSTREAM_INVALID_HEADER 40
! 41:
! 42:
! 43: #define NGX_HTTP_UPSTREAM_IGN_XA_REDIRECT 0x00000002
! 44: #define NGX_HTTP_UPSTREAM_IGN_XA_EXPIRES 0x00000004
! 45: #define NGX_HTTP_UPSTREAM_IGN_EXPIRES 0x00000008
! 46: #define NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL 0x00000010
! 47: #define NGX_HTTP_UPSTREAM_IGN_SET_COOKIE 0x00000020
! 48: #define NGX_HTTP_UPSTREAM_IGN_XA_LIMIT_RATE 0x00000040
! 49: #define NGX_HTTP_UPSTREAM_IGN_XA_BUFFERING 0x00000080
! 50: #define NGX_HTTP_UPSTREAM_IGN_XA_CHARSET 0x00000100
! 51:
! 52:
! 53: typedef struct {
! 54: ngx_msec_t bl_time;
! 55: ngx_uint_t bl_state;
! 56:
! 57: ngx_uint_t status;
! 58: time_t response_sec;
! 59: ngx_uint_t response_msec;
! 60: off_t response_length;
! 61:
! 62: ngx_str_t *peer;
! 63: } ngx_http_upstream_state_t;
! 64:
! 65:
! 66: typedef struct {
! 67: ngx_hash_t headers_in_hash;
! 68: ngx_array_t upstreams;
! 69: /* ngx_http_upstream_srv_conf_t */
! 70: } ngx_http_upstream_main_conf_t;
! 71:
! 72: typedef struct ngx_http_upstream_srv_conf_s ngx_http_upstream_srv_conf_t;
! 73:
! 74: typedef ngx_int_t (*ngx_http_upstream_init_pt)(ngx_conf_t *cf,
! 75: ngx_http_upstream_srv_conf_t *us);
! 76: typedef ngx_int_t (*ngx_http_upstream_init_peer_pt)(ngx_http_request_t *r,
! 77: ngx_http_upstream_srv_conf_t *us);
! 78:
! 79:
! 80: typedef struct {
! 81: ngx_http_upstream_init_pt init_upstream;
! 82: ngx_http_upstream_init_peer_pt init;
! 83: void *data;
! 84: } ngx_http_upstream_peer_t;
! 85:
! 86:
! 87: typedef struct {
! 88: ngx_addr_t *addrs;
! 89: ngx_uint_t naddrs;
! 90: ngx_uint_t weight;
! 91: ngx_uint_t max_fails;
! 92: time_t fail_timeout;
! 93:
! 94: unsigned down:1;
! 95: unsigned backup:1;
! 96: } ngx_http_upstream_server_t;
! 97:
! 98:
! 99: #define NGX_HTTP_UPSTREAM_CREATE 0x0001
! 100: #define NGX_HTTP_UPSTREAM_WEIGHT 0x0002
! 101: #define NGX_HTTP_UPSTREAM_MAX_FAILS 0x0004
! 102: #define NGX_HTTP_UPSTREAM_FAIL_TIMEOUT 0x0008
! 103: #define NGX_HTTP_UPSTREAM_DOWN 0x0010
! 104: #define NGX_HTTP_UPSTREAM_BACKUP 0x0020
! 105:
! 106:
! 107: struct ngx_http_upstream_srv_conf_s {
! 108: ngx_http_upstream_peer_t peer;
! 109: void **srv_conf;
! 110:
! 111: ngx_array_t *servers; /* ngx_http_upstream_server_t */
! 112:
! 113: ngx_uint_t flags;
! 114: ngx_str_t host;
! 115: u_char *file_name;
! 116: ngx_uint_t line;
! 117: in_port_t port;
! 118: in_port_t default_port;
! 119: ngx_uint_t no_port; /* unsigned no_port:1 */
! 120: };
! 121:
! 122:
! 123: typedef struct {
! 124: ngx_addr_t *addr;
! 125: ngx_http_complex_value_t *value;
! 126: } ngx_http_upstream_local_t;
! 127:
! 128:
! 129: typedef struct {
! 130: ngx_http_upstream_srv_conf_t *upstream;
! 131:
! 132: ngx_msec_t connect_timeout;
! 133: ngx_msec_t send_timeout;
! 134: ngx_msec_t read_timeout;
! 135: ngx_msec_t timeout;
! 136:
! 137: size_t send_lowat;
! 138: size_t buffer_size;
! 139:
! 140: size_t busy_buffers_size;
! 141: size_t max_temp_file_size;
! 142: size_t temp_file_write_size;
! 143:
! 144: size_t busy_buffers_size_conf;
! 145: size_t max_temp_file_size_conf;
! 146: size_t temp_file_write_size_conf;
! 147:
! 148: ngx_bufs_t bufs;
! 149:
! 150: ngx_uint_t ignore_headers;
! 151: ngx_uint_t next_upstream;
! 152: ngx_uint_t store_access;
! 153: ngx_flag_t buffering;
! 154: ngx_flag_t pass_request_headers;
! 155: ngx_flag_t pass_request_body;
! 156:
! 157: ngx_flag_t ignore_client_abort;
! 158: ngx_flag_t intercept_errors;
! 159: ngx_flag_t cyclic_temp_file;
! 160:
! 161: ngx_path_t *temp_path;
! 162:
! 163: ngx_hash_t hide_headers_hash;
! 164: ngx_array_t *hide_headers;
! 165: ngx_array_t *pass_headers;
! 166:
! 167: ngx_http_upstream_local_t *local;
! 168:
! 169: #if (NGX_HTTP_CACHE)
! 170: ngx_shm_zone_t *cache;
! 171:
! 172: ngx_uint_t cache_min_uses;
! 173: ngx_uint_t cache_use_stale;
! 174: ngx_uint_t cache_methods;
! 175:
! 176: ngx_flag_t cache_lock;
! 177: ngx_msec_t cache_lock_timeout;
! 178:
! 179: ngx_array_t *cache_valid;
! 180: ngx_array_t *cache_bypass;
! 181: ngx_array_t *no_cache;
! 182: #endif
! 183:
! 184: ngx_array_t *store_lengths;
! 185: ngx_array_t *store_values;
! 186:
! 187: signed store:2;
! 188: unsigned intercept_404:1;
! 189: unsigned change_buffering:1;
! 190:
! 191: #if (NGX_HTTP_SSL)
! 192: ngx_ssl_t *ssl;
! 193: ngx_flag_t ssl_session_reuse;
! 194: #endif
! 195:
! 196: ngx_str_t module;
! 197: } ngx_http_upstream_conf_t;
! 198:
! 199:
! 200: typedef struct {
! 201: ngx_str_t name;
! 202: ngx_http_header_handler_pt handler;
! 203: ngx_uint_t offset;
! 204: ngx_http_header_handler_pt copy_handler;
! 205: ngx_uint_t conf;
! 206: ngx_uint_t redirect; /* unsigned redirect:1; */
! 207: } ngx_http_upstream_header_t;
! 208:
! 209:
! 210: typedef struct {
! 211: ngx_list_t headers;
! 212:
! 213: ngx_uint_t status_n;
! 214: ngx_str_t status_line;
! 215:
! 216: ngx_table_elt_t *status;
! 217: ngx_table_elt_t *date;
! 218: ngx_table_elt_t *server;
! 219: ngx_table_elt_t *connection;
! 220:
! 221: ngx_table_elt_t *expires;
! 222: ngx_table_elt_t *etag;
! 223: ngx_table_elt_t *x_accel_expires;
! 224: ngx_table_elt_t *x_accel_redirect;
! 225: ngx_table_elt_t *x_accel_limit_rate;
! 226:
! 227: ngx_table_elt_t *content_type;
! 228: ngx_table_elt_t *content_length;
! 229:
! 230: ngx_table_elt_t *last_modified;
! 231: ngx_table_elt_t *location;
! 232: ngx_table_elt_t *accept_ranges;
! 233: ngx_table_elt_t *www_authenticate;
! 234: ngx_table_elt_t *transfer_encoding;
! 235:
! 236: #if (NGX_HTTP_GZIP)
! 237: ngx_table_elt_t *content_encoding;
! 238: #endif
! 239:
! 240: off_t content_length_n;
! 241:
! 242: ngx_array_t cache_control;
! 243:
! 244: unsigned connection_close:1;
! 245: unsigned chunked:1;
! 246: } ngx_http_upstream_headers_in_t;
! 247:
! 248:
! 249: typedef struct {
! 250: ngx_str_t host;
! 251: in_port_t port;
! 252: ngx_uint_t no_port; /* unsigned no_port:1 */
! 253:
! 254: ngx_uint_t naddrs;
! 255: in_addr_t *addrs;
! 256:
! 257: struct sockaddr *sockaddr;
! 258: socklen_t socklen;
! 259:
! 260: ngx_resolver_ctx_t *ctx;
! 261: } ngx_http_upstream_resolved_t;
! 262:
! 263:
! 264: typedef void (*ngx_http_upstream_handler_pt)(ngx_http_request_t *r,
! 265: ngx_http_upstream_t *u);
! 266:
! 267:
! 268: struct ngx_http_upstream_s {
! 269: ngx_http_upstream_handler_pt read_event_handler;
! 270: ngx_http_upstream_handler_pt write_event_handler;
! 271:
! 272: ngx_peer_connection_t peer;
! 273:
! 274: ngx_event_pipe_t *pipe;
! 275:
! 276: ngx_chain_t *request_bufs;
! 277:
! 278: ngx_output_chain_ctx_t output;
! 279: ngx_chain_writer_ctx_t writer;
! 280:
! 281: ngx_http_upstream_conf_t *conf;
! 282:
! 283: ngx_http_upstream_headers_in_t headers_in;
! 284:
! 285: ngx_http_upstream_resolved_t *resolved;
! 286:
! 287: ngx_buf_t from_client;
! 288:
! 289: ngx_buf_t buffer;
! 290: off_t length;
! 291:
! 292: ngx_chain_t *out_bufs;
! 293: ngx_chain_t *busy_bufs;
! 294: ngx_chain_t *free_bufs;
! 295:
! 296: ngx_int_t (*input_filter_init)(void *data);
! 297: ngx_int_t (*input_filter)(void *data, ssize_t bytes);
! 298: void *input_filter_ctx;
! 299:
! 300: #if (NGX_HTTP_CACHE)
! 301: ngx_int_t (*create_key)(ngx_http_request_t *r);
! 302: #endif
! 303: ngx_int_t (*create_request)(ngx_http_request_t *r);
! 304: ngx_int_t (*reinit_request)(ngx_http_request_t *r);
! 305: ngx_int_t (*process_header)(ngx_http_request_t *r);
! 306: void (*abort_request)(ngx_http_request_t *r);
! 307: void (*finalize_request)(ngx_http_request_t *r,
! 308: ngx_int_t rc);
! 309: ngx_int_t (*rewrite_redirect)(ngx_http_request_t *r,
! 310: ngx_table_elt_t *h, size_t prefix);
! 311: ngx_int_t (*rewrite_cookie)(ngx_http_request_t *r,
! 312: ngx_table_elt_t *h);
! 313:
! 314: ngx_msec_t timeout;
! 315:
! 316: ngx_http_upstream_state_t *state;
! 317:
! 318: ngx_str_t method;
! 319: ngx_str_t schema;
! 320: ngx_str_t uri;
! 321:
! 322: ngx_http_cleanup_pt *cleanup;
! 323:
! 324: unsigned store:1;
! 325: unsigned cacheable:1;
! 326: unsigned accel:1;
! 327: unsigned ssl:1;
! 328: #if (NGX_HTTP_CACHE)
! 329: unsigned cache_status:3;
! 330: #endif
! 331:
! 332: unsigned buffering:1;
! 333: unsigned keepalive:1;
! 334: unsigned upgrade:1;
! 335:
! 336: unsigned request_sent:1;
! 337: unsigned header_sent:1;
! 338: };
! 339:
! 340:
! 341: typedef struct {
! 342: ngx_uint_t status;
! 343: ngx_uint_t mask;
! 344: } ngx_http_upstream_next_t;
! 345:
! 346:
! 347: typedef struct {
! 348: ngx_str_t key;
! 349: ngx_str_t value;
! 350: ngx_uint_t skip_empty;
! 351: } ngx_http_upstream_param_t;
! 352:
! 353:
! 354: ngx_int_t ngx_http_upstream_header_variable(ngx_http_request_t *r,
! 355: ngx_http_variable_value_t *v, uintptr_t data);
! 356:
! 357: ngx_int_t ngx_http_upstream_create(ngx_http_request_t *r);
! 358: void ngx_http_upstream_init(ngx_http_request_t *r);
! 359: ngx_http_upstream_srv_conf_t *ngx_http_upstream_add(ngx_conf_t *cf,
! 360: ngx_url_t *u, ngx_uint_t flags);
! 361: char *ngx_http_upstream_bind_set_slot(ngx_conf_t *cf, ngx_command_t *cmd,
! 362: void *conf);
! 363: char *ngx_http_upstream_param_set_slot(ngx_conf_t *cf, ngx_command_t *cmd,
! 364: void *conf);
! 365: ngx_int_t ngx_http_upstream_hide_headers_hash(ngx_conf_t *cf,
! 366: ngx_http_upstream_conf_t *conf, ngx_http_upstream_conf_t *prev,
! 367: ngx_str_t *default_hide_headers, ngx_hash_init_t *hash);
! 368:
! 369:
! 370: #define ngx_http_conf_upstream_srv_conf(uscf, module) \
! 371: uscf->srv_conf[module.ctx_index]
! 372:
! 373:
! 374: extern ngx_module_t ngx_http_upstream_module;
! 375: extern ngx_conf_bitmask_t ngx_http_upstream_cache_method_mask[];
! 376: extern ngx_conf_bitmask_t ngx_http_upstream_ignore_headers_masks[];
! 377:
! 378:
! 379: #endif /* _NGX_HTTP_UPSTREAM_H_INCLUDED_ */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>