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

Linux Cross Reference
Nginx/http/ngx_http_core_module.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_CORE_H_INCLUDED_
  8 #define _NGX_HTTP_CORE_H_INCLUDED_
  9 
 10 
 11 #include <ngx_config.h>
 12 #include <ngx_core.h>
 13 #include <ngx_http.h>
 14 
 15 
 16 #define NGX_HTTP_GZIP_PROXIED_OFF       0x0002
 17 #define NGX_HTTP_GZIP_PROXIED_EXPIRED   0x0004
 18 #define NGX_HTTP_GZIP_PROXIED_NO_CACHE  0x0008
 19 #define NGX_HTTP_GZIP_PROXIED_NO_STORE  0x0010
 20 #define NGX_HTTP_GZIP_PROXIED_PRIVATE   0x0020
 21 #define NGX_HTTP_GZIP_PROXIED_NO_LM     0x0040
 22 #define NGX_HTTP_GZIP_PROXIED_NO_ETAG   0x0080
 23 #define NGX_HTTP_GZIP_PROXIED_AUTH      0x0100
 24 #define NGX_HTTP_GZIP_PROXIED_ANY       0x0200
 25 
 26 
 27 #define NGX_HTTP_AIO_OFF                0
 28 #define NGX_HTTP_AIO_ON                 1
 29 #define NGX_HTTP_AIO_SENDFILE           2
 30 
 31 
 32 #define NGX_HTTP_SATISFY_ALL            0
 33 #define NGX_HTTP_SATISFY_ANY            1
 34 
 35 
 36 #define NGX_HTTP_IMS_OFF                0
 37 #define NGX_HTTP_IMS_EXACT              1
 38 #define NGX_HTTP_IMS_BEFORE             2
 39 
 40 
 41 typedef struct ngx_http_location_tree_node_s  ngx_http_location_tree_node_t;
 42 typedef struct ngx_http_core_loc_conf_s  ngx_http_core_loc_conf_t;
 43 
 44 
 45 typedef struct {
 46     unsigned                   default_server:1;
 47     unsigned                   bind:1;
 48     unsigned                   wildcard:1;
 49 #if (NGX_HTTP_SSL)
 50     unsigned                   ssl:1;
 51 #endif
 52 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
 53     unsigned                   ipv6only:2;
 54 #endif
 55 
 56     int                        backlog;
 57     int                        rcvbuf;
 58     int                        sndbuf;
 59 
 60 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
 61     char                      *accept_filter;
 62 #endif
 63 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
 64     ngx_uint_t                 deferred_accept;
 65 #endif
 66 
 67     u_char                     addr[NGX_SOCKADDR_STRLEN + 1];
 68 } ngx_http_listen_conf_t;
 69 
 70 
 71 typedef struct {
 72     u_char                     sockaddr[NGX_SOCKADDRLEN];
 73     socklen_t                  socklen;
 74 
 75     u_char                    *file_name;
 76     ngx_uint_t                 line;
 77 
 78     ngx_http_listen_conf_t     conf;
 79 } ngx_http_listen_t;
 80 
 81 
 82 typedef enum {
 83     NGX_HTTP_POST_READ_PHASE = 0,
 84 
 85     NGX_HTTP_SERVER_REWRITE_PHASE,
 86 
 87     NGX_HTTP_FIND_CONFIG_PHASE,
 88     NGX_HTTP_REWRITE_PHASE,
 89     NGX_HTTP_POST_REWRITE_PHASE,
 90 
 91     NGX_HTTP_PREACCESS_PHASE,
 92 
 93     NGX_HTTP_ACCESS_PHASE,
 94     NGX_HTTP_POST_ACCESS_PHASE,
 95 
 96     NGX_HTTP_TRY_FILES_PHASE,
 97     NGX_HTTP_CONTENT_PHASE,
 98 
 99     NGX_HTTP_LOG_PHASE
100 } ngx_http_phases;
101 
102 typedef struct ngx_http_phase_handler_s  ngx_http_phase_handler_t;
103 
104 typedef ngx_int_t (*ngx_http_phase_handler_pt)(ngx_http_request_t *r,
105     ngx_http_phase_handler_t *ph);
106 
107 struct ngx_http_phase_handler_s {
108     ngx_http_phase_handler_pt  checker;
109     ngx_http_handler_pt        handler;
110     ngx_uint_t                 next;
111 };
112 
113 
114 typedef struct {
115     ngx_http_phase_handler_t  *handlers;
116     ngx_uint_t                 server_rewrite_index;
117     ngx_uint_t                 location_rewrite_index;
118 } ngx_http_phase_engine_t;
119 
120 
121 typedef struct {
122     ngx_array_t                handlers;
123 } ngx_http_phase_t;
124 
125 
126 typedef struct {
127     ngx_array_t                servers;         /* ngx_http_core_srv_conf_t */
128 
129     ngx_http_phase_engine_t    phase_engine;
130 
131     ngx_hash_t                 headers_in_hash;
132 
133     ngx_hash_t                 variables_hash;
134 
135     ngx_array_t                variables;       /* ngx_http_variable_t */
136 
137     ngx_uint_t                 server_names_hash_max_size;
138     ngx_uint_t                 server_names_hash_bucket_size;
139 
140     ngx_uint_t                 variables_hash_max_size;
141     ngx_uint_t                 variables_hash_bucket_size;
142 
143     ngx_hash_keys_arrays_t    *variables_keys;
144 
145     ngx_uint_t                 try_files;       /* unsigned  try_files:1 */
146 
147     ngx_http_phase_t           phases[NGX_HTTP_LOG_PHASE + 1];
148 } ngx_http_core_main_conf_t;
149 
150 
151 typedef struct {
152     /* array of the ngx_http_listen_t, "listen" directive */
153     ngx_array_t                 listen;
154 
155     /* array of the ngx_http_server_name_t, "server_name" directive */
156     ngx_array_t                 server_names;
157 
158     /* server ctx */
159     ngx_http_conf_ctx_t        *ctx;
160 
161     ngx_str_t                   server_name;
162 
163     size_t                      connection_pool_size;
164     size_t                      request_pool_size;
165     size_t                      client_header_buffer_size;
166 
167     ngx_bufs_t                  large_client_header_buffers;
168 
169     ngx_msec_t                  client_header_timeout;
170 
171     ngx_flag_t                  ignore_invalid_headers;
172     ngx_flag_t                  merge_slashes;
173     ngx_flag_t                  underscores_in_headers;
174 
175     ngx_http_core_loc_conf_t  **named_locations;
176 } ngx_http_core_srv_conf_t;
177 
178 
179 /* list of structures to find core_srv_conf quickly at run time */
180 
181 
182 typedef struct {
183     /* the default server configuration for this address:port */
184     ngx_http_core_srv_conf_t  *core_srv_conf;
185 
186     ngx_http_virtual_names_t  *virtual_names;
187 
188 #if (NGX_HTTP_SSL)
189     ngx_uint_t                 ssl;   /* unsigned  ssl:1; */
190 #endif
191 } ngx_http_addr_conf_t;
192 
193 
194 typedef struct {
195     in_addr_t                  addr;
196     ngx_http_addr_conf_t       conf;
197 } ngx_http_in_addr_t;
198 
199 
200 #if (NGX_HAVE_INET6)
201 
202 typedef struct {
203     struct in6_addr            addr6;
204     ngx_http_addr_conf_t       conf;
205 } ngx_http_in6_addr_t;
206 
207 #endif
208 
209 
210 typedef struct {
211     /* ngx_http_in_addr_t or ngx_http_in6_addr_t */
212     void                      *addrs;
213     ngx_uint_t                 naddrs;
214 } ngx_http_port_t;
215 
216 
217 typedef struct {
218     ngx_int_t                  family;
219     in_port_t                  port;
220     ngx_array_t                addrs;     /* array of ngx_http_conf_addr_t */
221 } ngx_http_conf_port_t;
222 
223 
224 typedef struct {
225     struct sockaddr           *sockaddr;
226     socklen_t                  socklen;
227 
228     ngx_hash_t                 hash;
229     ngx_hash_wildcard_t       *wc_head;
230     ngx_hash_wildcard_t       *wc_tail;
231 
232     ngx_array_t                names;      /* array of ngx_http_server_name_t */
233 
234 #if (NGX_PCRE)
235     ngx_uint_t                 nregex;
236     ngx_http_server_name_t    *regex;
237 #endif
238 
239     /* the default server configuration for this address:port */
240     ngx_http_core_srv_conf_t  *core_srv_conf;
241 
242     unsigned                   default_server:1;
243     unsigned                   bind:1;
244     unsigned                   wildcard:1;
245 #if (NGX_HTTP_SSL)
246     unsigned                   ssl:1;
247 #endif
248 
249     ngx_http_listen_conf_t    *listen_conf;
250 } ngx_http_conf_addr_t;
251 
252 
253 struct ngx_http_server_name_s {
254 #if (NGX_PCRE)
255     ngx_regex_t               *regex;
256     ngx_uint_t                 captures;      /* unsigned  captures:1; */
257 #endif
258     ngx_http_core_srv_conf_t  *core_srv_conf; /* virtual name server conf */
259     ngx_str_t                  name;
260 };
261 
262 
263 typedef struct {
264     ngx_int_t                  status;
265     ngx_int_t                  overwrite;
266     ngx_http_complex_value_t   value;
267     ngx_str_t                  args;
268 } ngx_http_err_page_t;
269 
270 
271 typedef struct {
272     ngx_array_t               *lengths;
273     ngx_array_t               *values;
274     ngx_str_t                  name;
275 
276     unsigned                   code:10;
277     unsigned                   test_dir:1;
278 } ngx_http_try_file_t;
279 
280 
281 struct ngx_http_core_loc_conf_s {
282     ngx_str_t     name;          /* location name */
283 
284 #if (NGX_PCRE)
285     ngx_regex_t  *regex;
286 
287     unsigned      captures:1;
288 #endif
289 
290     unsigned      noname:1;   /* "if () {}" block or limit_except */
291     unsigned      named:1;
292 
293     unsigned      exact_match:1;
294     unsigned      noregex:1;
295 
296     unsigned      auto_redirect:1;
297     unsigned      alias:1;
298 #if (NGX_HTTP_GZIP)
299     unsigned      gzip_disable_msie6:2;
300 #endif
301 
302     ngx_http_location_tree_node_t   *static_locations;
303 #if (NGX_PCRE)
304     ngx_http_core_loc_conf_t       **regex_locations;
305 #endif
306 
307     /* pointer to the modules' loc_conf */
308     void        **loc_conf;
309 
310     uint32_t      limit_except;
311     void        **limit_except_loc_conf;
312 
313     ngx_http_handler_pt  handler;
314 
315     ngx_str_t     root;                    /* root, alias */
316     ngx_str_t     post_action;
317 
318     ngx_array_t  *root_lengths;
319     ngx_array_t  *root_values;
320 
321     ngx_array_t  *types;
322     ngx_hash_t    types_hash;
323     ngx_str_t     default_type;
324 
325     off_t         client_max_body_size;    /* client_max_body_size */
326     off_t         directio;                /* directio */
327     off_t         directio_alignment;      /* directio_alignment */
328 
329     size_t        client_body_buffer_size; /* client_body_buffer_size */
330     size_t        send_lowat;              /* send_lowat */
331     size_t        postpone_output;         /* postpone_output */
332     size_t        limit_rate;              /* limit_rate */
333     size_t        limit_rate_after;        /* limit_rate_after */
334     size_t        sendfile_max_chunk;      /* sendfile_max_chunk */
335     size_t        read_ahead;              /* read_ahead */
336 
337     ngx_msec_t    client_body_timeout;     /* client_body_timeout */
338     ngx_msec_t    send_timeout;            /* send_timeout */
339     ngx_msec_t    keepalive_timeout;       /* keepalive_timeout */
340     ngx_msec_t    lingering_time;          /* lingering_time */
341     ngx_msec_t    lingering_timeout;       /* lingering_timeout */
342     ngx_msec_t    resolver_timeout;        /* resolver_timeout */
343 
344     ngx_resolver_t  *resolver;             /* resolver */
345 
346     time_t        keepalive_header;        /* keepalive_timeout */
347 
348     ngx_uint_t    keepalive_requests;      /* keepalive_requests */
349     ngx_uint_t    satisfy;                 /* satisfy */
350     ngx_uint_t    if_modified_since;       /* if_modified_since */
351     ngx_uint_t    client_body_in_file_only; /* client_body_in_file_only */
352 
353     ngx_flag_t    client_body_in_single_buffer;
354                                            /* client_body_in_singe_buffer */
355     ngx_flag_t    internal;                /* internal */
356     ngx_flag_t    sendfile;                /* sendfile */
357 #if (NGX_HAVE_FILE_AIO)
358     ngx_flag_t    aio;                     /* aio */
359 #endif
360     ngx_flag_t    tcp_nopush;              /* tcp_nopush */
361     ngx_flag_t    tcp_nodelay;             /* tcp_nodelay */
362     ngx_flag_t    reset_timedout_connection; /* reset_timedout_connection */
363     ngx_flag_t    server_name_in_redirect; /* server_name_in_redirect */
364     ngx_flag_t    port_in_redirect;        /* port_in_redirect */
365     ngx_flag_t    msie_padding;            /* msie_padding */
366     ngx_flag_t    msie_refresh;            /* msie_refresh */
367     ngx_flag_t    log_not_found;           /* log_not_found */
368     ngx_flag_t    log_subrequest;          /* log_subrequest */
369     ngx_flag_t    recursive_error_pages;   /* recursive_error_pages */
370     ngx_flag_t    server_tokens;           /* server_tokens */
371 
372 #if (NGX_HTTP_GZIP)
373     ngx_flag_t    gzip_vary;               /* gzip_vary */
374 
375     ngx_uint_t    gzip_http_version;       /* gzip_http_version */
376     ngx_uint_t    gzip_proxied;            /* gzip_proxied */
377 
378 #if (NGX_PCRE)
379     ngx_array_t  *gzip_disable;            /* gzip_disable */
380 #endif
381 #endif
382 
383     ngx_array_t  *error_pages;             /* error_page */
384     ngx_http_try_file_t    *try_files;     /* try_files */
385 
386     ngx_path_t   *client_body_temp_path;   /* client_body_temp_path */
387 
388     ngx_open_file_cache_t  *open_file_cache;
389     time_t        open_file_cache_valid;
390     ngx_uint_t    open_file_cache_min_uses;
391     ngx_flag_t    open_file_cache_errors;
392     ngx_flag_t    open_file_cache_events;
393 
394     ngx_log_t    *error_log;
395 
396     ngx_uint_t    types_hash_max_size;
397     ngx_uint_t    types_hash_bucket_size;
398 
399     ngx_queue_t  *locations;
400 
401 #if 0
402     ngx_http_core_loc_conf_t  *prev_location;
403 #endif
404 };
405 
406 
407 typedef struct {
408     ngx_queue_t                      queue;
409     ngx_http_core_loc_conf_t        *exact;
410     ngx_http_core_loc_conf_t        *inclusive;
411     ngx_str_t                       *name;
412     u_char                          *file_name;
413     ngx_uint_t                       line;
414     ngx_queue_t                      list;
415 } ngx_http_location_queue_t;
416 
417 
418 struct ngx_http_location_tree_node_s {
419     ngx_http_location_tree_node_t   *left;
420     ngx_http_location_tree_node_t   *right;
421     ngx_http_location_tree_node_t   *tree;
422 
423     ngx_http_core_loc_conf_t        *exact;
424     ngx_http_core_loc_conf_t        *inclusive;
425 
426     u_char                           auto_redirect;
427     u_char                           len;
428     u_char                           name[1];
429 };
430 
431 
432 void ngx_http_core_run_phases(ngx_http_request_t *r);
433 ngx_int_t ngx_http_core_generic_phase(ngx_http_request_t *r,
434     ngx_http_phase_handler_t *ph);
435 ngx_int_t ngx_http_core_find_config_phase(ngx_http_request_t *r,
436     ngx_http_phase_handler_t *ph);
437 ngx_int_t ngx_http_core_post_rewrite_phase(ngx_http_request_t *r,
438     ngx_http_phase_handler_t *ph);
439 ngx_int_t ngx_http_core_access_phase(ngx_http_request_t *r,
440     ngx_http_phase_handler_t *ph);
441 ngx_int_t ngx_http_core_post_access_phase(ngx_http_request_t *r,
442     ngx_http_phase_handler_t *ph);
443 ngx_int_t ngx_http_core_try_files_phase(ngx_http_request_t *r,
444     ngx_http_phase_handler_t *ph);
445 ngx_int_t ngx_http_core_content_phase(ngx_http_request_t *r,
446     ngx_http_phase_handler_t *ph);
447 
448 
449 void *ngx_http_test_content_type(ngx_http_request_t *r, ngx_hash_t *types_hash);
450 ngx_int_t ngx_http_set_content_type(ngx_http_request_t *r);
451 void ngx_http_set_exten(ngx_http_request_t *r);
452 u_char *ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *name,
453     size_t *root_length, size_t reserved);
454 ngx_int_t ngx_http_auth_basic_user(ngx_http_request_t *r);
455 #if (NGX_HTTP_GZIP)
456 ngx_int_t ngx_http_gzip_ok(ngx_http_request_t *r);
457 #endif
458 
459 
460 ngx_int_t ngx_http_subrequest(ngx_http_request_t *r,
461     ngx_str_t *uri, ngx_str_t *args, ngx_http_request_t **sr,
462     ngx_http_post_subrequest_t *psr, ngx_uint_t flags);
463 ngx_int_t ngx_http_internal_redirect(ngx_http_request_t *r,
464     ngx_str_t *uri, ngx_str_t *args);
465 ngx_int_t ngx_http_named_location(ngx_http_request_t *r, ngx_str_t *name);
466 
467 
468 ngx_http_cleanup_t *ngx_http_cleanup_add(ngx_http_request_t *r, size_t size);
469 
470 
471 typedef ngx_int_t (*ngx_http_output_header_filter_pt)(ngx_http_request_t *r);
472 typedef ngx_int_t (*ngx_http_output_body_filter_pt)
473     (ngx_http_request_t *r, ngx_chain_t *chain);
474 
475 
476 ngx_int_t ngx_http_output_filter(ngx_http_request_t *r, ngx_chain_t *chain);
477 ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *chain);
478 
479 
480 extern ngx_module_t  ngx_http_core_module;
481 
482 extern ngx_uint_t ngx_http_max_module;
483 
484 extern ngx_str_t  ngx_http_core_get_method;
485 
486 
487 #define ngx_http_clear_content_length(r)                                      \
488                                                                               \
489     r->headers_out.content_length_n = -1;                                     \
490     if (r->headers_out.content_length) {                                      \
491         r->headers_out.content_length->hash = 0;                              \
492         r->headers_out.content_length = NULL;                                 \
493     }
494                                                                               \
495 #define ngx_http_clear_accept_ranges(r)                                       \
496                                                                               \
497     r->allow_ranges = 0;                                                      \
498     if (r->headers_out.accept_ranges) {                                       \
499         r->headers_out.accept_ranges->hash = 0;                               \
500         r->headers_out.accept_ranges = NULL;                                  \
501     }
502 
503 #define ngx_http_clear_last_modified(r)                                       \
504                                                                               \
505     r->headers_out.last_modified_time = -1;                                   \
506     if (r->headers_out.last_modified) {                                       \
507         r->headers_out.last_modified->hash = 0;                               \
508         r->headers_out.last_modified = NULL;                                  \
509     }
510 
511 
512 #endif /* _NGX_HTTP_CORE_H_INCLUDED_ */
513 

~ [ 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.