~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Nginx/http/ngx_http_request.h

Version: ~ [ nginx-0.8.20 ] ~ [ nginx-0.7.62 ] ~ [ nginx-0.6.39 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.