Return to ngx_http_request.h CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / nginx / src / http |
1.1 ! misho 1: ! 2: /* ! 3: * Copyright (C) Igor Sysoev ! 4: * Copyright (C) Nginx, Inc. ! 5: */ ! 6: ! 7: ! 8: #ifndef _NGX_HTTP_REQUEST_H_INCLUDED_ ! 9: #define _NGX_HTTP_REQUEST_H_INCLUDED_ ! 10: ! 11: ! 12: #define NGX_HTTP_MAX_URI_CHANGES 10 ! 13: #define NGX_HTTP_MAX_SUBREQUESTS 200 ! 14: ! 15: /* must be 2^n */ ! 16: #define NGX_HTTP_LC_HEADER_LEN 32 ! 17: ! 18: ! 19: #define NGX_HTTP_DISCARD_BUFFER_SIZE 4096 ! 20: #define NGX_HTTP_LINGERING_BUFFER_SIZE 4096 ! 21: ! 22: ! 23: #define NGX_HTTP_VERSION_9 9 ! 24: #define NGX_HTTP_VERSION_10 1000 ! 25: #define NGX_HTTP_VERSION_11 1001 ! 26: ! 27: #define NGX_HTTP_UNKNOWN 0x0001 ! 28: #define NGX_HTTP_GET 0x0002 ! 29: #define NGX_HTTP_HEAD 0x0004 ! 30: #define NGX_HTTP_POST 0x0008 ! 31: #define NGX_HTTP_PUT 0x0010 ! 32: #define NGX_HTTP_DELETE 0x0020 ! 33: #define NGX_HTTP_MKCOL 0x0040 ! 34: #define NGX_HTTP_COPY 0x0080 ! 35: #define NGX_HTTP_MOVE 0x0100 ! 36: #define NGX_HTTP_OPTIONS 0x0200 ! 37: #define NGX_HTTP_PROPFIND 0x0400 ! 38: #define NGX_HTTP_PROPPATCH 0x0800 ! 39: #define NGX_HTTP_LOCK 0x1000 ! 40: #define NGX_HTTP_UNLOCK 0x2000 ! 41: #define NGX_HTTP_PATCH 0x4000 ! 42: #define NGX_HTTP_TRACE 0x8000 ! 43: ! 44: #define NGX_HTTP_CONNECTION_CLOSE 1 ! 45: #define NGX_HTTP_CONNECTION_KEEP_ALIVE 2 ! 46: ! 47: ! 48: #define NGX_NONE 1 ! 49: ! 50: ! 51: #define NGX_HTTP_PARSE_HEADER_DONE 1 ! 52: ! 53: #define NGX_HTTP_CLIENT_ERROR 10 ! 54: #define NGX_HTTP_PARSE_INVALID_METHOD 10 ! 55: #define NGX_HTTP_PARSE_INVALID_REQUEST 11 ! 56: #define NGX_HTTP_PARSE_INVALID_09_METHOD 12 ! 57: ! 58: #define NGX_HTTP_PARSE_INVALID_HEADER 13 ! 59: ! 60: ! 61: /* unused 1 */ ! 62: #define NGX_HTTP_SUBREQUEST_IN_MEMORY 2 ! 63: #define NGX_HTTP_SUBREQUEST_WAITED 4 ! 64: #define NGX_HTTP_LOG_UNSAFE 8 ! 65: ! 66: ! 67: #define NGX_HTTP_CONTINUE 100 ! 68: #define NGX_HTTP_SWITCHING_PROTOCOLS 101 ! 69: #define NGX_HTTP_PROCESSING 102 ! 70: ! 71: #define NGX_HTTP_OK 200 ! 72: #define NGX_HTTP_CREATED 201 ! 73: #define NGX_HTTP_ACCEPTED 202 ! 74: #define NGX_HTTP_NO_CONTENT 204 ! 75: #define NGX_HTTP_PARTIAL_CONTENT 206 ! 76: ! 77: #define NGX_HTTP_SPECIAL_RESPONSE 300 ! 78: #define NGX_HTTP_MOVED_PERMANENTLY 301 ! 79: #define NGX_HTTP_MOVED_TEMPORARILY 302 ! 80: #define NGX_HTTP_SEE_OTHER 303 ! 81: #define NGX_HTTP_NOT_MODIFIED 304 ! 82: #define NGX_HTTP_TEMPORARY_REDIRECT 307 ! 83: ! 84: #define NGX_HTTP_BAD_REQUEST 400 ! 85: #define NGX_HTTP_UNAUTHORIZED 401 ! 86: #define NGX_HTTP_FORBIDDEN 403 ! 87: #define NGX_HTTP_NOT_FOUND 404 ! 88: #define NGX_HTTP_NOT_ALLOWED 405 ! 89: #define NGX_HTTP_REQUEST_TIME_OUT 408 ! 90: #define NGX_HTTP_CONFLICT 409 ! 91: #define NGX_HTTP_LENGTH_REQUIRED 411 ! 92: #define NGX_HTTP_PRECONDITION_FAILED 412 ! 93: #define NGX_HTTP_REQUEST_ENTITY_TOO_LARGE 413 ! 94: #define NGX_HTTP_REQUEST_URI_TOO_LARGE 414 ! 95: #define NGX_HTTP_UNSUPPORTED_MEDIA_TYPE 415 ! 96: #define NGX_HTTP_RANGE_NOT_SATISFIABLE 416 ! 97: ! 98: ! 99: /* Our own HTTP codes */ ! 100: ! 101: /* The special code to close connection without any response */ ! 102: #define NGX_HTTP_CLOSE 444 ! 103: ! 104: #define NGX_HTTP_NGINX_CODES 494 ! 105: ! 106: #define NGX_HTTP_REQUEST_HEADER_TOO_LARGE 494 ! 107: ! 108: #define NGX_HTTPS_CERT_ERROR 495 ! 109: #define NGX_HTTPS_NO_CERT 496 ! 110: ! 111: /* ! 112: * We use the special code for the plain HTTP requests that are sent to ! 113: * HTTPS port to distinguish it from 4XX in an error page redirection ! 114: */ ! 115: #define NGX_HTTP_TO_HTTPS 497 ! 116: ! 117: /* 498 is the canceled code for the requests with invalid host name */ ! 118: ! 119: /* ! 120: * HTTP does not define the code for the case when a client closed ! 121: * the connection while we are processing its request so we introduce ! 122: * own code to log such situation when a client has closed the connection ! 123: * before we even try to send the HTTP header to it ! 124: */ ! 125: #define NGX_HTTP_CLIENT_CLOSED_REQUEST 499 ! 126: ! 127: ! 128: #define NGX_HTTP_INTERNAL_SERVER_ERROR 500 ! 129: #define NGX_HTTP_NOT_IMPLEMENTED 501 ! 130: #define NGX_HTTP_BAD_GATEWAY 502 ! 131: #define NGX_HTTP_SERVICE_UNAVAILABLE 503 ! 132: #define NGX_HTTP_GATEWAY_TIME_OUT 504 ! 133: #define NGX_HTTP_INSUFFICIENT_STORAGE 507 ! 134: ! 135: ! 136: #define NGX_HTTP_LOWLEVEL_BUFFERED 0xf0 ! 137: #define NGX_HTTP_WRITE_BUFFERED 0x10 ! 138: #define NGX_HTTP_GZIP_BUFFERED 0x20 ! 139: #define NGX_HTTP_SSI_BUFFERED 0x01 ! 140: #define NGX_HTTP_SUB_BUFFERED 0x02 ! 141: #define NGX_HTTP_COPY_BUFFERED 0x04 ! 142: ! 143: ! 144: typedef enum { ! 145: NGX_HTTP_INITING_REQUEST_STATE = 0, ! 146: NGX_HTTP_READING_REQUEST_STATE, ! 147: NGX_HTTP_PROCESS_REQUEST_STATE, ! 148: ! 149: NGX_HTTP_CONNECT_UPSTREAM_STATE, ! 150: NGX_HTTP_WRITING_UPSTREAM_STATE, ! 151: NGX_HTTP_READING_UPSTREAM_STATE, ! 152: ! 153: NGX_HTTP_WRITING_REQUEST_STATE, ! 154: NGX_HTTP_LINGERING_CLOSE_STATE, ! 155: NGX_HTTP_KEEPALIVE_STATE ! 156: } ngx_http_state_e; ! 157: ! 158: ! 159: typedef struct { ! 160: ngx_str_t name; ! 161: ngx_uint_t offset; ! 162: ngx_http_header_handler_pt handler; ! 163: } ngx_http_header_t; ! 164: ! 165: ! 166: typedef struct { ! 167: ngx_str_t name; ! 168: ngx_uint_t offset; ! 169: } ngx_http_header_out_t; ! 170: ! 171: ! 172: typedef struct { ! 173: ngx_list_t headers; ! 174: ! 175: ngx_table_elt_t *host; ! 176: ngx_table_elt_t *connection; ! 177: ngx_table_elt_t *if_modified_since; ! 178: ngx_table_elt_t *if_unmodified_since; ! 179: ngx_table_elt_t *if_match; ! 180: ngx_table_elt_t *if_none_match; ! 181: ngx_table_elt_t *user_agent; ! 182: ngx_table_elt_t *referer; ! 183: ngx_table_elt_t *content_length; ! 184: ngx_table_elt_t *content_type; ! 185: ! 186: ngx_table_elt_t *range; ! 187: ngx_table_elt_t *if_range; ! 188: ! 189: ngx_table_elt_t *transfer_encoding; ! 190: ngx_table_elt_t *expect; ! 191: ngx_table_elt_t *upgrade; ! 192: ! 193: #if (NGX_HTTP_GZIP) ! 194: ngx_table_elt_t *accept_encoding; ! 195: ngx_table_elt_t *via; ! 196: #endif ! 197: ! 198: ngx_table_elt_t *authorization; ! 199: ! 200: ngx_table_elt_t *keep_alive; ! 201: ! 202: #if (NGX_HTTP_X_FORWARDED_FOR) ! 203: ngx_array_t x_forwarded_for; ! 204: #endif ! 205: ! 206: #if (NGX_HTTP_REALIP) ! 207: ngx_table_elt_t *x_real_ip; ! 208: #endif ! 209: ! 210: #if (NGX_HTTP_HEADERS) ! 211: ngx_table_elt_t *accept; ! 212: ngx_table_elt_t *accept_language; ! 213: #endif ! 214: ! 215: #if (NGX_HTTP_DAV) ! 216: ngx_table_elt_t *depth; ! 217: ngx_table_elt_t *destination; ! 218: ngx_table_elt_t *overwrite; ! 219: ngx_table_elt_t *date; ! 220: #endif ! 221: ! 222: ngx_str_t user; ! 223: ngx_str_t passwd; ! 224: ! 225: ngx_array_t cookies; ! 226: ! 227: ngx_str_t server; ! 228: off_t content_length_n; ! 229: time_t keep_alive_n; ! 230: ! 231: unsigned connection_type:2; ! 232: unsigned chunked:1; ! 233: unsigned msie:1; ! 234: unsigned msie6:1; ! 235: unsigned opera:1; ! 236: unsigned gecko:1; ! 237: unsigned chrome:1; ! 238: unsigned safari:1; ! 239: unsigned konqueror:1; ! 240: } ngx_http_headers_in_t; ! 241: ! 242: ! 243: typedef struct { ! 244: ngx_list_t headers; ! 245: ! 246: ngx_uint_t status; ! 247: ngx_str_t status_line; ! 248: ! 249: ngx_table_elt_t *server; ! 250: ngx_table_elt_t *date; ! 251: ngx_table_elt_t *content_length; ! 252: ngx_table_elt_t *content_encoding; ! 253: ngx_table_elt_t *location; ! 254: ngx_table_elt_t *refresh; ! 255: ngx_table_elt_t *last_modified; ! 256: ngx_table_elt_t *content_range; ! 257: ngx_table_elt_t *accept_ranges; ! 258: ngx_table_elt_t *www_authenticate; ! 259: ngx_table_elt_t *expires; ! 260: ngx_table_elt_t *etag; ! 261: ! 262: ngx_str_t *override_charset; ! 263: ! 264: size_t content_type_len; ! 265: ngx_str_t content_type; ! 266: ngx_str_t charset; ! 267: u_char *content_type_lowcase; ! 268: ngx_uint_t content_type_hash; ! 269: ! 270: ngx_array_t cache_control; ! 271: ! 272: off_t content_length_n; ! 273: time_t date_time; ! 274: time_t last_modified_time; ! 275: } ngx_http_headers_out_t; ! 276: ! 277: ! 278: typedef void (*ngx_http_client_body_handler_pt)(ngx_http_request_t *r); ! 279: ! 280: typedef struct { ! 281: ngx_temp_file_t *temp_file; ! 282: ngx_chain_t *bufs; ! 283: ngx_buf_t *buf; ! 284: off_t rest; ! 285: ngx_chain_t *free; ! 286: ngx_chain_t *busy; ! 287: ngx_http_chunked_t *chunked; ! 288: ngx_http_client_body_handler_pt post_handler; ! 289: } ngx_http_request_body_t; ! 290: ! 291: ! 292: typedef struct ngx_http_addr_conf_s ngx_http_addr_conf_t; ! 293: ! 294: typedef struct { ! 295: ngx_http_addr_conf_t *addr_conf; ! 296: ngx_http_conf_ctx_t *conf_ctx; ! 297: ! 298: #if (NGX_HTTP_SSL && defined SSL_CTRL_SET_TLSEXT_HOSTNAME) ! 299: ngx_str_t *ssl_servername; ! 300: #if (NGX_PCRE) ! 301: ngx_http_regex_t *ssl_servername_regex; ! 302: #endif ! 303: #endif ! 304: ! 305: ngx_buf_t **busy; ! 306: ngx_int_t nbusy; ! 307: ! 308: ngx_buf_t **free; ! 309: ngx_int_t nfree; ! 310: ! 311: #if (NGX_HTTP_SSL) ! 312: ngx_uint_t ssl; /* unsigned ssl:1; */ ! 313: #endif ! 314: } ngx_http_connection_t; ! 315: ! 316: ! 317: typedef void (*ngx_http_cleanup_pt)(void *data); ! 318: ! 319: typedef struct ngx_http_cleanup_s ngx_http_cleanup_t; ! 320: ! 321: struct ngx_http_cleanup_s { ! 322: ngx_http_cleanup_pt handler; ! 323: void *data; ! 324: ngx_http_cleanup_t *next; ! 325: }; ! 326: ! 327: ! 328: typedef ngx_int_t (*ngx_http_post_subrequest_pt)(ngx_http_request_t *r, ! 329: void *data, ngx_int_t rc); ! 330: ! 331: typedef struct { ! 332: ngx_http_post_subrequest_pt handler; ! 333: void *data; ! 334: } ngx_http_post_subrequest_t; ! 335: ! 336: ! 337: typedef struct ngx_http_postponed_request_s ngx_http_postponed_request_t; ! 338: ! 339: struct ngx_http_postponed_request_s { ! 340: ngx_http_request_t *request; ! 341: ngx_chain_t *out; ! 342: ngx_http_postponed_request_t *next; ! 343: }; ! 344: ! 345: ! 346: typedef struct ngx_http_posted_request_s ngx_http_posted_request_t; ! 347: ! 348: struct ngx_http_posted_request_s { ! 349: ngx_http_request_t *request; ! 350: ngx_http_posted_request_t *next; ! 351: }; ! 352: ! 353: ! 354: typedef ngx_int_t (*ngx_http_handler_pt)(ngx_http_request_t *r); ! 355: typedef void (*ngx_http_event_handler_pt)(ngx_http_request_t *r); ! 356: ! 357: ! 358: struct ngx_http_request_s { ! 359: uint32_t signature; /* "HTTP" */ ! 360: ! 361: ngx_connection_t *connection; ! 362: ! 363: void **ctx; ! 364: void **main_conf; ! 365: void **srv_conf; ! 366: void **loc_conf; ! 367: ! 368: ngx_http_event_handler_pt read_event_handler; ! 369: ngx_http_event_handler_pt write_event_handler; ! 370: ! 371: #if (NGX_HTTP_CACHE) ! 372: ngx_http_cache_t *cache; ! 373: #endif ! 374: ! 375: ngx_http_upstream_t *upstream; ! 376: ngx_array_t *upstream_states; ! 377: /* of ngx_http_upstream_state_t */ ! 378: ! 379: ngx_pool_t *pool; ! 380: ngx_buf_t *header_in; ! 381: ! 382: ngx_http_headers_in_t headers_in; ! 383: ngx_http_headers_out_t headers_out; ! 384: ! 385: ngx_http_request_body_t *request_body; ! 386: ! 387: time_t lingering_time; ! 388: time_t start_sec; ! 389: ngx_msec_t start_msec; ! 390: ! 391: ngx_uint_t method; ! 392: ngx_uint_t http_version; ! 393: ! 394: ngx_str_t request_line; ! 395: ngx_str_t uri; ! 396: ngx_str_t args; ! 397: ngx_str_t exten; ! 398: ngx_str_t unparsed_uri; ! 399: ! 400: ngx_str_t method_name; ! 401: ngx_str_t http_protocol; ! 402: ! 403: ngx_chain_t *out; ! 404: ngx_http_request_t *main; ! 405: ngx_http_request_t *parent; ! 406: ngx_http_postponed_request_t *postponed; ! 407: ngx_http_post_subrequest_t *post_subrequest; ! 408: ngx_http_posted_request_t *posted_requests; ! 409: ! 410: ngx_int_t phase_handler; ! 411: ngx_http_handler_pt content_handler; ! 412: ngx_uint_t access_code; ! 413: ! 414: ngx_http_variable_value_t *variables; ! 415: ! 416: #if (NGX_PCRE) ! 417: ngx_uint_t ncaptures; ! 418: int *captures; ! 419: u_char *captures_data; ! 420: #endif ! 421: ! 422: size_t limit_rate; ! 423: ! 424: /* used to learn the Apache compatible response length without a header */ ! 425: size_t header_size; ! 426: ! 427: off_t request_length; ! 428: ! 429: ngx_uint_t err_status; ! 430: ! 431: ngx_http_connection_t *http_connection; ! 432: #if (NGX_HTTP_SPDY) ! 433: ngx_http_spdy_stream_t *spdy_stream; ! 434: #endif ! 435: ! 436: ngx_http_log_handler_pt log_handler; ! 437: ! 438: ngx_http_cleanup_t *cleanup; ! 439: ! 440: unsigned subrequests:8; ! 441: unsigned count:8; ! 442: unsigned blocked:8; ! 443: ! 444: unsigned aio:1; ! 445: ! 446: unsigned http_state:4; ! 447: ! 448: /* URI with "/." and on Win32 with "//" */ ! 449: unsigned complex_uri:1; ! 450: ! 451: /* URI with "%" */ ! 452: unsigned quoted_uri:1; ! 453: ! 454: /* URI with "+" */ ! 455: unsigned plus_in_uri:1; ! 456: ! 457: /* URI with " " */ ! 458: unsigned space_in_uri:1; ! 459: ! 460: unsigned invalid_header:1; ! 461: ! 462: unsigned add_uri_to_alias:1; ! 463: unsigned valid_location:1; ! 464: unsigned valid_unparsed_uri:1; ! 465: unsigned uri_changed:1; ! 466: unsigned uri_changes:4; ! 467: ! 468: unsigned request_body_in_single_buf:1; ! 469: unsigned request_body_in_file_only:1; ! 470: unsigned request_body_in_persistent_file:1; ! 471: unsigned request_body_in_clean_file:1; ! 472: unsigned request_body_file_group_access:1; ! 473: unsigned request_body_file_log_level:3; ! 474: ! 475: unsigned subrequest_in_memory:1; ! 476: unsigned waited:1; ! 477: ! 478: #if (NGX_HTTP_CACHE) ! 479: unsigned cached:1; ! 480: #endif ! 481: ! 482: #if (NGX_HTTP_GZIP) ! 483: unsigned gzip_tested:1; ! 484: unsigned gzip_ok:1; ! 485: unsigned gzip_vary:1; ! 486: #endif ! 487: ! 488: unsigned proxy:1; ! 489: unsigned bypass_cache:1; ! 490: unsigned no_cache:1; ! 491: ! 492: /* ! 493: * instead of using the request context data in ! 494: * ngx_http_limit_conn_module and ngx_http_limit_req_module ! 495: * we use the single bits in the request structure ! 496: */ ! 497: unsigned limit_conn_set:1; ! 498: unsigned limit_req_set:1; ! 499: ! 500: #if 0 ! 501: unsigned cacheable:1; ! 502: #endif ! 503: ! 504: unsigned pipeline:1; ! 505: unsigned chunked:1; ! 506: unsigned header_only:1; ! 507: unsigned keepalive:1; ! 508: unsigned lingering_close:1; ! 509: unsigned discard_body:1; ! 510: unsigned internal:1; ! 511: unsigned error_page:1; ! 512: unsigned ignore_content_encoding:1; ! 513: unsigned filter_finalize:1; ! 514: unsigned post_action:1; ! 515: unsigned request_complete:1; ! 516: unsigned request_output:1; ! 517: unsigned header_sent:1; ! 518: unsigned expect_tested:1; ! 519: unsigned root_tested:1; ! 520: unsigned done:1; ! 521: unsigned logged:1; ! 522: ! 523: unsigned buffered:4; ! 524: ! 525: unsigned main_filter_need_in_memory:1; ! 526: unsigned filter_need_in_memory:1; ! 527: unsigned filter_need_temporary:1; ! 528: unsigned allow_ranges:1; ! 529: ! 530: #if (NGX_STAT_STUB) ! 531: unsigned stat_reading:1; ! 532: unsigned stat_writing:1; ! 533: #endif ! 534: ! 535: /* used to parse HTTP headers */ ! 536: ! 537: ngx_uint_t state; ! 538: ! 539: ngx_uint_t header_hash; ! 540: ngx_uint_t lowcase_index; ! 541: u_char lowcase_header[NGX_HTTP_LC_HEADER_LEN]; ! 542: ! 543: u_char *header_name_start; ! 544: u_char *header_name_end; ! 545: u_char *header_start; ! 546: u_char *header_end; ! 547: ! 548: /* ! 549: * a memory that can be reused after parsing a request line ! 550: * via ngx_http_ephemeral_t ! 551: */ ! 552: ! 553: u_char *uri_start; ! 554: u_char *uri_end; ! 555: u_char *uri_ext; ! 556: u_char *args_start; ! 557: u_char *request_start; ! 558: u_char *request_end; ! 559: u_char *method_end; ! 560: u_char *schema_start; ! 561: u_char *schema_end; ! 562: u_char *host_start; ! 563: u_char *host_end; ! 564: u_char *port_start; ! 565: u_char *port_end; ! 566: ! 567: unsigned http_minor:16; ! 568: unsigned http_major:16; ! 569: }; ! 570: ! 571: ! 572: typedef struct { ! 573: ngx_http_posted_request_t terminal_posted_request; ! 574: #if (NGX_HAVE_AIO_SENDFILE) ! 575: u_char aio_preload; ! 576: #endif ! 577: } ngx_http_ephemeral_t; ! 578: ! 579: ! 580: extern ngx_http_header_t ngx_http_headers_in[]; ! 581: extern ngx_http_header_out_t ngx_http_headers_out[]; ! 582: ! 583: ! 584: #define ngx_http_set_connection_log(c, l) \ ! 585: \ ! 586: c->log->file = l->file; \ ! 587: if (!(c->log->log_level & NGX_LOG_DEBUG_CONNECTION)) { \ ! 588: c->log->log_level = l->log_level; \ ! 589: } ! 590: ! 591: ! 592: #endif /* _NGX_HTTP_REQUEST_H_INCLUDED_ */