Groonga 3.0.9 Source Code Document
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ngx_http_request.h
Go to the documentation of this file.
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 {
148 
152 
157 
158 
159 typedef struct {
164 
165 
166 typedef struct {
170 
171 
172 typedef struct {
174 
185 
188 
192 
193 #if (NGX_HTTP_GZIP)
194  ngx_table_elt_t *accept_encoding;
195  ngx_table_elt_t *via;
196 #endif
197 
199 
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;
220 #endif
221 
224 
226 
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;
241 
242 
243 typedef struct {
245 
248 
261 
263 
269 
271 
273  time_t date_time;
276 
277 
279 
280 typedef struct {
284  off_t rest;
290 
291 
293 
294 typedef struct {
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 
307 
310 
311 #if (NGX_HTTP_SSL)
312  ngx_uint_t ssl; /* unsigned ssl:1; */
313 #endif
315 
316 
317 typedef void (*ngx_http_cleanup_pt)(void *data);
318 
320 
323  void *data;
325 };
326 
327 
329  void *data, ngx_int_t rc);
330 
331 typedef struct {
333  void *data;
335 
336 
338 
343 };
344 
345 
347 
351 };
352 
353 
356 
357 
359  uint32_t signature; /* "HTTP" */
360 
362 
363  void **ctx;
364  void **main_conf;
365  void **srv_conf;
366  void **loc_conf;
367 
370 
371 #if (NGX_HTTP_CACHE)
372  ngx_http_cache_t *cache;
373 #endif
374 
377  /* of ngx_http_upstream_state_t */
378 
381 
384 
386 
388  time_t start_sec;
390 
393 
399 
402 
409 
413 
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 
428 
430 
432 #if (NGX_HTTP_SPDY)
433  ngx_http_spdy_stream_t *spdy_stream;
434 #endif
435 
437 
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 
474 
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;
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 
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 
538 
542 
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 {
574 #if (NGX_HAVE_AIO_SENDFILE)
575  u_char aio_preload;
576 #endif
578 
579 
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_ */