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