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

Linux Cross Reference
Nginx/http/ngx_http_core_module.h

Version: ~ [ nginx-0.6.26 ] ~ [ nginx-0.5.35 ] ~ [ nginx-0.5.20 ] ~ [ nginx-0.5.19 ] ~

  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_string.h>
 12 #include <ngx_array.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_SATISFY_ALL            0
 28 #define NGX_HTTP_SATISFY_ANY            1
 29 
 30 
 31 typedef struct {
 32     unsigned                   default_server:1;
 33     unsigned                   bind:1;
 34 
 35     int                        backlog;
 36     int                        rcvbuf;
 37     int                        sndbuf;
 38 
 39 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
 40     char                      *accept_filter;
 41 #endif
 42 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
 43     ngx_uint_t                 deferred_accept;
 44 #endif
 45 
 46     u_char                     addr[INET_ADDRSTRLEN + 6];
 47 
 48 } ngx_http_listen_conf_t;
 49 
 50 
 51 typedef struct {
 52     in_addr_t                  addr;
 53     in_port_t                  port;
 54     int                        family;
 55 
 56     u_char                    *file_name;
 57     ngx_uint_t                 line;
 58 
 59     ngx_http_listen_conf_t     conf;
 60 } ngx_http_listen_t;
 61 
 62 
 63 typedef enum {
 64     NGX_HTTP_POST_READ_PHASE = 0,
 65 
 66     NGX_HTTP_SERVER_REWRITE_PHASE,
 67 
 68     NGX_HTTP_FIND_CONFIG_PHASE,
 69     NGX_HTTP_REWRITE_PHASE,
 70     NGX_HTTP_POST_REWRITE_PHASE,
 71 
 72     NGX_HTTP_PREACCESS_PHASE,
 73 
 74     NGX_HTTP_ACCESS_PHASE,
 75     NGX_HTTP_POST_ACCESS_PHASE,
 76 
 77     NGX_HTTP_CONTENT_PHASE,
 78 
 79     NGX_HTTP_LOG_PHASE
 80 } ngx_http_phases;
 81 
 82 typedef struct ngx_http_phase_handler_s  ngx_http_phase_handler_t;
 83 
 84 typedef ngx_int_t (*ngx_http_phase_handler_pt)(ngx_http_request_t *r,
 85     ngx_http_phase_handler_t *ph);
 86 
 87 struct ngx_http_phase_handler_s {
 88     ngx_http_phase_handler_pt  checker;
 89     ngx_http_handler_pt        handler;
 90     ngx_uint_t                 next;
 91 };
 92 
 93 
 94 typedef struct {
 95     ngx_http_phase_handler_t  *handlers;
 96     ngx_uint_t                 server_rewrite_index;
 97     ngx_uint_t                 location_rewrite_index;
 98 } ngx_http_phase_engine_t;
 99 
100 
101 typedef struct {
102     ngx_array_t                handlers;
103 } ngx_http_phase_t;
104 
105 
106 typedef struct {
107     ngx_array_t                servers;         /* ngx_http_core_srv_conf_t */
108 
109     ngx_http_phase_engine_t    phase_engine;
110 
111     ngx_hash_t                 headers_in_hash;
112 
113     ngx_hash_t                 variables_hash;
114 
115     ngx_array_t                variables;       /* ngx_http_variable_t */
116 
117     ngx_uint_t                 server_names_hash_max_size;
118     ngx_uint_t                 server_names_hash_bucket_size;
119 
120     ngx_uint_t                 variables_hash_max_size;
121     ngx_uint_t                 variables_hash_bucket_size;
122 
123     ngx_hash_keys_arrays_t    *variables_keys;
124 
125     ngx_http_phase_t           phases[NGX_HTTP_LOG_PHASE + 1];
126 } ngx_http_core_main_conf_t;
127 
128 
129 typedef struct {
130     /*
131      * array of the ngx_http_core_loc_conf_t *,
132      * used in the ngx_http_core_find_location() and in the merge phase
133      */
134     ngx_array_t                locations;
135 
136     unsigned                   regex_start:15;
137     unsigned                   named_start:15;
138 
139     /* array of the ngx_http_listen_t, "listen" directive */
140     ngx_array_t                listen;
141 
142     /* array of the ngx_http_server_name_t, "server_name" directive */
143     ngx_array_t                server_names;
144 
145     /* server ctx */
146     ngx_http_conf_ctx_t       *ctx;
147 
148     ngx_str_t                  server_name;
149 
150     size_t                     connection_pool_size;
151     size_t                     request_pool_size;
152     size_t                     client_header_buffer_size;
153 
154     ngx_bufs_t                 large_client_header_buffers;
155 
156     ngx_msec_t                 client_header_timeout;
157 
158     ngx_flag_t                 optimize_server_names;
159     ngx_flag_t                 ignore_invalid_headers;
160     ngx_flag_t                 merge_slashes;
161 } ngx_http_core_srv_conf_t;
162 
163 
164 /* list of structures to find core_srv_conf quickly at run time */
165 
166 
167 typedef struct {
168     in_addr_t                  addr;
169 
170     /* the default server configuration for this address:port */
171     ngx_http_core_srv_conf_t  *core_srv_conf;
172 
173     ngx_http_virtual_names_t  *virtual_names;
174 } ngx_http_in_addr_t;
175 
176 
177 typedef struct {
178     in_port_t                  port;
179     ngx_str_t                  port_text;
180     ngx_http_in_addr_t        *addrs;
181     ngx_uint_t                 naddrs;
182 } ngx_http_in_port_t;
183 
184 
185 typedef struct {
186     in_port_t                  port;
187     ngx_array_t                addrs;     /* array of ngx_http_conf_in_addr_t */
188 } ngx_http_conf_in_port_t;
189 
190 
191 typedef struct {
192     in_addr_t                  addr;
193 
194     ngx_hash_t                 hash;
195     ngx_hash_wildcard_t       *wc_head;
196     ngx_hash_wildcard_t       *wc_tail;
197 
198     ngx_array_t                names;      /* array of ngx_http_server_name_t */
199 
200 #if (NGX_PCRE)
201     ngx_uint_t                 nregex;
202     ngx_http_server_name_t    *regex;
203 #endif
204 
205     /* the default server configuration for this address:port */
206     ngx_http_core_srv_conf_t  *core_srv_conf;
207 
208     unsigned                   default_server:1;
209     unsigned                   bind:1;
210 
211     ngx_http_listen_conf_t    *listen_conf;
212 } ngx_http_conf_in_addr_t;
213 
214 
215 struct ngx_http_server_name_s {
216 #if (NGX_PCRE)
217     ngx_regex_t               *regex;
218 #endif
219     ngx_http_core_srv_conf_t  *core_srv_conf; /* virtual name server conf */
220     ngx_str_t                  name;
221 };
222 
223 
224 typedef struct {
225     ngx_int_t                  status;
226     ngx_int_t                  overwrite;
227     ngx_str_t                  uri;
228     ngx_array_t               *uri_lengths;
229     ngx_array_t               *uri_values;
230 } ngx_http_err_page_t;
231 
232 
233 typedef struct ngx_http_core_loc_conf_s  ngx_http_core_loc_conf_t;
234 
235 struct ngx_http_core_loc_conf_s {
236     ngx_str_t     name;          /* location name */
237 
238 #if (NGX_PCRE)
239     ngx_regex_t  *regex;
240 #endif
241 
242     unsigned      regex_start:15;
243 
244     unsigned      noname:1;   /* "if () {}" block or limit_except */
245     unsigned      named:1;
246 
247     unsigned      exact_match:1;
248     unsigned      noregex:1;
249 
250     unsigned      auto_redirect:1;
251     unsigned      alias:1;
252 
253     /* array of inclusive ngx_http_core_loc_conf_t */
254     ngx_array_t  *locations;
255 
256     /* pointer to the modules' loc_conf */
257     void        **loc_conf ;
258 
259     uint32_t      limit_except;
260     void        **limit_except_loc_conf ;
261 
262     ngx_http_handler_pt  handler;
263 
264     ngx_str_t     root;                    /* root, alias */
265     ngx_str_t     post_action;
266 
267     ngx_array_t  *root_lengths;
268     ngx_array_t  *root_values;
269 
270     ngx_array_t  *types;
271     ngx_hash_t    types_hash;
272     ngx_str_t     default_type;
273 
274     off_t         client_max_body_size;    /* client_max_body_size */
275 
276     size_t        client_body_buffer_size; /* client_body_buffer_size */
277     size_t        send_lowat;              /* send_lowat */
278     size_t        postpone_output;         /* postpone_output */
279     size_t        limit_rate;              /* limit_rate */
280     size_t        sendfile_max_chunk;      /* sendfile_max_chunk */
281 
282     ngx_msec_t    client_body_timeout;     /* client_body_timeout */
283     ngx_msec_t    send_timeout;            /* send_timeout */
284     ngx_msec_t    keepalive_timeout;       /* keepalive_timeout */
285     ngx_msec_t    lingering_time;          /* lingering_time */
286     ngx_msec_t    lingering_timeout;       /* lingering_timeout */
287     ngx_msec_t    resolver_timeout;        /* resolver_timeout */
288 
289     ngx_resolver_t  *resolver;             /* resolver */
290 
291     time_t        keepalive_header;        /* keepalive_timeout */
292 
293     ngx_uint_t    satisfy;                 /* satisfy */
294 
295     ngx_flag_t    internal;                /* internal */
296     ngx_flag_t    client_body_in_file_only; /* client_body_in_file_only */
297     ngx_flag_t    sendfile;                /* sendfile */
298     ngx_flag_t    tcp_nopush;              /* tcp_nopush */
299     ngx_flag_t    tcp_nodelay;             /* tcp_nodelay */
300     ngx_flag_t    reset_timedout_connection; /* reset_timedout_connection */
301     ngx_flag_t    server_name_in_redirect; /* server_name_in_redirect */
302     ngx_flag_t    port_in_redirect;        /* port_in_redirect */
303     ngx_flag_t    msie_padding;            /* msie_padding */
304     ngx_flag_t    msie_refresh;            /* msie_refresh */
305     ngx_flag_t    log_not_found;           /* log_not_found */
306     ngx_flag_t    recursive_error_pages;   /* recursive_error_pages */
307     ngx_flag_t    server_tokens;           /* server_tokens */
308 
309 #if (NGX_HTTP_GZIP)
310     ngx_flag_t    gzip_vary;               /* gzip_vary */
311 
312     ngx_uint_t    gzip_http_version;       /* gzip_http_version */
313     ngx_uint_t    gzip_proxied;            /* gzip_proxied */
314 
315 #if (NGX_PCRE)
316     ngx_array_t  *gzip_disable;            /* gzip_disable */
317 #endif
318 #endif
319 
320     ngx_array_t  *error_pages;             /* error_page */
321 
322     ngx_path_t   *client_body_temp_path;   /* client_body_temp_path */
323 
324     ngx_open_file_cache_t  *open_file_cache;
325     time_t        open_file_cache_valid;
326     ngx_uint_t    open_file_cache_min_uses;
327     ngx_flag_t    open_file_cache_errors;
328     ngx_flag_t    open_file_cache_events;
329 
330     ngx_log_t    *err_log;
331 
332     ngx_uint_t    types_hash_max_size;
333     ngx_uint_t    types_hash_bucket_size;
334 
335 #if 0
336     ngx_http_core_loc_conf_t  *prev_location;
337 #endif
338 };
339 
340 
341 void ngx_http_core_run_phases(ngx_http_request_t *r);
342 ngx_int_t ngx_http_core_generic_phase(ngx_http_request_t *r,
343     ngx_http_phase_handler_t *ph);
344 ngx_int_t ngx_http_core_find_config_phase(ngx_http_request_t *r,
345     ngx_http_phase_handler_t *ph);
346 ngx_int_t ngx_http_core_post_rewrite_phase(ngx_http_request_t *r,
347     ngx_http_phase_handler_t *ph);
348 ngx_int_t ngx_http_core_access_phase(ngx_http_request_t *r,
349     ngx_http_phase_handler_t *ph);
350 ngx_int_t ngx_http_core_post_access_phase(ngx_http_request_t *r,
351     ngx_http_phase_handler_t *ph);
352 ngx_int_t ngx_http_core_content_phase(ngx_http_request_t *r,
353     ngx_http_phase_handler_t *ph);
354 
355 ngx_int_t ngx_http_set_content_type(ngx_http_request_t *r);
356 ngx_int_t ngx_http_set_exten(ngx_http_request_t *r);
357 u_char *ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *name,
358     size_t *root_length, size_t reserved);
359 ngx_int_t ngx_http_auth_basic_user(ngx_http_request_t *r);
360 ngx_int_t ngx_http_server_addr(ngx_http_request_t *r, ngx_str_t *s);
361 #if (NGX_HTTP_GZIP)
362 ngx_int_t ngx_http_gzip_ok(ngx_http_request_t *r);
363 #endif
364 
365 
366 ngx_int_t ngx_http_subrequest(ngx_http_request_t *r,
367     ngx_str_t *uri, ngx_str_t *args, ngx_http_request_t **sr,
368     ngx_http_post_subrequest_t *psr, ngx_uint_t flags);
369 ngx_int_t ngx_http_internal_redirect(ngx_http_request_t *r,
370     ngx_str_t *uri, ngx_str_t *args);
371 ngx_int_t ngx_http_named_location(ngx_http_request_t *r, ngx_str_t *name);
372 
373 
374 ngx_http_cleanup_t *ngx_http_cleanup_add(ngx_http_request_t *r, size_t size);
375 
376 
377 typedef ngx_int_t (*ngx_http_output_header_filter_pt)(ngx_http_request_t *r);
378 typedef ngx_int_t (*ngx_http_output_body_filter_pt)
379     (ngx_http_request_t *r, ngx_chain_t *chain);
380 
381 
382 ngx_int_t ngx_http_output_filter(ngx_http_request_t *r, ngx_chain_t *chain);
383 ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *chain);
384 
385 
386 extern ngx_module_t  ngx_http_core_module;
387 
388 extern ngx_uint_t ngx_http_max_module;
389 
390 
391 #define ngx_http_clear_content_length(r)                                      \
392                                                                               \
393     r->headers_out.content_length_n = -1;                                     \
394     if (r->headers_out.content_length) {                                      \
395         r->headers_out.content_length->hash = 0;                              \
396         r->headers_out.content_length = NULL;                                 \
397     }
398                                                                               \
399 #define ngx_http_clear_accept_ranges(r)                                       \
400                                                                               \
401     r->allow_ranges = 0;                                                      \
402     if (r->headers_out.accept_ranges) {                                       \
403         r->headers_out.accept_ranges->hash = 0 ;                              \
404         r->headers_out.accept_ranges = NULL;                                  \
405     }
406 
407 #define ngx_http_clear_last_modified(r)                                       \
408                                                                               \
409     r->headers_out.last_modified_time = -1;                                   \
410     if (r->headers_out.last_modified) {                                       \
411         r->headers_out.last_modified->hash = 0;                               \
412         r->headers_out.last_modified = NULL;                                  \
413     }
414 
415 
416 #endif /* _NGX_HTTP_CORE_H_INCLUDED_ */
417 

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