3 * Copyright (C) Igor Sysoev
7 #ifndef _NGX_HTTP_CORE_H_INCLUDED_
8 #define _NGX_HTTP_CORE_H_INCLUDED_
11 #include <ngx_string.h>
12 #include <ngx_array.h>
23 unsigned default_server
:1;
28 NGX_HTTP_FIND_CONFIG_PHASE
= 0,
30 NGX_HTTP_REWRITE_PHASE
,
32 NGX_HTTP_ACCESS_PHASE
,
33 NGX_HTTP_CONTENT_PHASE
,
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
{
54 ngx_http_get_variable_pt handler
;
62 ngx_int_t type
; /* NGX_OK, NGX_DECLINED */
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
;
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 */
91 /* array of the ngx_http_server_name_t, "server_name" directive */
92 ngx_array_t server_names
;
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 */
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
{
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; */
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) \
144 for (key = 0, n = 0; n < len; n++) { \
151 #define NGX_HTTP_TYPES_HASH_PRIME 13
153 #define ngx_http_types_hash_key(key, ext) \
156 for (key = 0, n = 0; n < ext.len; n++) { \
157 key += ext.data[n]; \
159 key %= NGX_HTTP_TYPES_HASH_PRIME; \
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 */
184 unsigned noname
:1; /* "if () {}" block */
186 unsigned exact_match
:1;
189 unsigned auto_redirect
:1;
192 /* array of inclusive ngx_http_core_loc_conf_t */
193 ngx_array_t locations
;
195 /* pointer to the modules' loc_conf */
198 ngx_http_handler_pt handler
;
200 ngx_str_t root
; /* root, alias */
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
;
234 ngx_http_core_loc_conf_t
*prev_location
;
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
,
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_ */