nginx 0.1.19
[nginx-catap.git] / src / http / ngx_http_core_module.h
blobdbaef6f343cfeb952b0679e30c9706af8278903c
2 /*
3 * Copyright (C) Igor Sysoev
4 */
7 #ifndef _NGX_HTTP_CORE_H_INCLUDED_
8 #define _NGX_HTTP_CORE_H_INCLUDED_
11 #include <ngx_string.h>
12 #include <ngx_array.h>
13 #include <ngx_http.h>
16 typedef struct {
17 in_addr_t addr;
18 in_port_t port;
19 int family;
20 ngx_str_t file_name;
21 ngx_int_t line;
23 unsigned default_server:1;
24 } ngx_http_listen_t;
27 typedef enum {
28 NGX_HTTP_FIND_CONFIG_PHASE = 0,
30 NGX_HTTP_REWRITE_PHASE,
32 NGX_HTTP_ACCESS_PHASE,
33 NGX_HTTP_CONTENT_PHASE,
35 NGX_HTTP_LAST_PHASE
36 } ngx_http_phases;
39 typedef struct {
40 ngx_uint_t value;
41 ngx_str_t text;
42 } ngx_http_variable_value_t;
45 typedef struct ngx_http_variable_s ngx_http_variable_t;
47 typedef ngx_http_variable_value_t
48 *(*ngx_http_get_variable_pt) (ngx_http_request_t *r, void *var);
51 struct ngx_http_variable_s {
52 ngx_str_t name;
53 ngx_uint_t index;
54 ngx_http_get_variable_pt handler;
55 void *data;
56 ngx_uint_t uses;
60 typedef struct {
61 ngx_array_t handlers;
62 ngx_int_t type; /* NGX_OK, NGX_DECLINED */
63 } ngx_http_phase_t;
66 typedef struct {
67 ngx_array_t servers; /* ngx_http_core_srv_conf_t */
69 ngx_http_phase_t phases[NGX_HTTP_LAST_PHASE];
70 ngx_array_t index_handlers;
72 ngx_uint_t server_names_hash;
73 ngx_uint_t server_names_hash_threshold;
75 size_t max_server_name_len;
77 ngx_array_t variables; /* ngx_http_variable_t */
78 } ngx_http_core_main_conf_t;
81 typedef struct {
83 * array of the ngx_http_core_loc_conf_t,
84 * used in the translation handler and in the merge phase
86 ngx_array_t locations;
88 /* array of the ngx_http_listen_t, "listen" directive */
89 ngx_array_t listen;
91 /* array of the ngx_http_server_name_t, "server_name" directive */
92 ngx_array_t server_names;
94 /* server ctx */
95 ngx_http_conf_ctx_t *ctx;
97 size_t connection_pool_size;
98 size_t request_pool_size;
99 size_t client_header_buffer_size;
101 ngx_bufs_t large_client_header_buffers;
103 ngx_msec_t post_accept_timeout;
104 ngx_msec_t client_header_timeout;
106 ngx_uint_t restrict_host_names;
107 } ngx_http_core_srv_conf_t;
110 /* list of structures to find core_srv_conf quickly at run time */
112 typedef struct {
113 in_port_t port;
114 ngx_str_t port_text;
115 ngx_array_t addrs; /* array of ngx_http_in_addr_t */
116 } ngx_http_in_port_t;
119 struct ngx_http_in_addr_s {
120 in_addr_t addr;
122 ngx_array_t names; /* array of ngx_http_server_name_t */
123 ngx_array_t *hash; /* hash of ngx_http_server_name_t */
124 ngx_array_t wildcards; /* array of ngx_http_server_name_t */
126 /* the default server configuration for this address:port */
127 ngx_http_core_srv_conf_t *core_srv_conf;
129 ngx_uint_t default_server; /* unsigned default_server:1; */
133 typedef struct {
134 ngx_str_t name;
135 ngx_http_core_srv_conf_t *core_srv_conf; /* virtual name server conf */
137 ngx_uint_t wildcard; /* unsigned wildcard:1 */
138 } ngx_http_server_name_t;
141 #define ngx_http_server_names_hash_key(key, name, len, prime) \
143 ngx_uint_t n; \
144 for (key = 0, n = 0; n < len; n++) { \
145 key += name[n]; \
147 key %= prime; \
151 #define NGX_HTTP_TYPES_HASH_PRIME 13
153 #define ngx_http_types_hash_key(key, ext) \
155 ngx_uint_t n; \
156 for (key = 0, n = 0; n < ext.len; n++) { \
157 key += ext.data[n]; \
159 key %= NGX_HTTP_TYPES_HASH_PRIME; \
162 typedef struct {
163 ngx_str_t exten;
164 ngx_str_t type;
165 } ngx_http_type_t;
168 typedef struct {
169 ngx_int_t status;
170 ngx_int_t overwrite;
171 ngx_str_t uri;
172 } ngx_http_err_page_t;
175 typedef struct ngx_http_core_loc_conf_s ngx_http_core_loc_conf_t;
177 struct ngx_http_core_loc_conf_s {
178 ngx_str_t name; /* location name */
180 #if (NGX_PCRE)
181 ngx_regex_t *regex;
182 #endif
184 unsigned noname:1; /* "if () {}" block */
186 unsigned exact_match:1;
187 unsigned noregex:1;
189 unsigned auto_redirect:1;
190 unsigned alias:1;
192 /* array of inclusive ngx_http_core_loc_conf_t */
193 ngx_array_t locations;
195 /* pointer to the modules' loc_conf */
196 void **loc_conf ;
198 ngx_http_handler_pt handler;
200 ngx_str_t root; /* root, alias */
202 ngx_array_t *types;
203 ngx_str_t default_type;
205 size_t client_max_body_size; /* client_max_body_size */
206 size_t client_body_buffer_size; /* client_body_buffer_size */
207 size_t send_lowat; /* send_lowat */
208 size_t postpone_output; /* postpone_output */
209 size_t limit_rate; /* limit_rate */
211 ngx_msec_t client_body_timeout; /* client_body_timeout */
212 ngx_msec_t send_timeout; /* send_timeout */
213 ngx_msec_t keepalive_timeout; /* keepalive_timeout */
214 ngx_msec_t lingering_time; /* lingering_time */
215 ngx_msec_t lingering_timeout; /* lingering_timeout */
217 time_t keepalive_header; /* keepalive_timeout */
219 ngx_flag_t sendfile; /* sendfile */
220 ngx_flag_t tcp_nopush; /* tcp_nopush */
221 ngx_flag_t tcp_nodelay; /* tcp_nodelay */
222 ngx_flag_t reset_timedout_connection; /* reset_timedout_connection */
223 ngx_flag_t msie_padding; /* msie_padding */
225 ngx_array_t *error_pages; /* error_page */
227 ngx_path_t *client_body_temp_path; /* client_body_temp_path */
229 ngx_http_cache_hash_t *open_files;
231 ngx_log_t *err_log;
233 #if 0
234 ngx_http_core_loc_conf_t *prev_location;
235 #endif
240 extern ngx_http_module_t ngx_http_core_module_ctx;
241 extern ngx_module_t ngx_http_core_module;
243 extern ngx_uint_t ngx_http_max_module;
247 ngx_int_t ngx_http_find_location_config(ngx_http_request_t *r);
249 ngx_int_t ngx_http_set_content_type(ngx_http_request_t *r);
250 ngx_int_t ngx_http_set_exten(ngx_http_request_t *r);
252 ngx_int_t ngx_http_internal_redirect(ngx_http_request_t *r,
253 ngx_str_t *uri, ngx_str_t *args);
255 ngx_http_variable_t *ngx_http_add_variable(ngx_conf_t *cf);
256 ngx_http_variable_value_t *ngx_http_get_variable(ngx_http_request_t *r,
257 ngx_uint_t index);
260 typedef ngx_int_t (*ngx_http_output_header_filter_pt)(ngx_http_request_t *r);
261 typedef ngx_int_t (*ngx_http_output_body_filter_pt)
262 (ngx_http_request_t *r, ngx_chain_t *chain);
265 ngx_int_t ngx_http_output_filter(ngx_http_request_t *r, ngx_chain_t *chain);
266 ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *chain);
269 #endif /* _NGX_HTTP_CORE_H_INCLUDED_ */