comparison src/http/ngx_http_core_module.h @ 0:f0b350454894 NGINX_0_1_0

nginx 0.1.0 *) The first public version.
author Igor Sysoev <http://sysoev.ru>
date Mon, 04 Oct 2004 00:00:00 +0400
parents
children cc9f381affaa
comparison
equal deleted inserted replaced
-1:000000000000 0:f0b350454894
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 typedef struct {
17 in_addr_t addr;
18 in_port_t port;
19 int family;
20 ngx_str_t file_name;
21 int line;
22
23 unsigned default_server:1;
24 } ngx_http_listen_t;
25
26
27 typedef enum {
28 NGX_HTTP_REWRITE_PHASE = 0,
29
30 NGX_HTTP_FIND_CONFIG_PHASE,
31
32 NGX_HTTP_ACCESS_PHASE,
33 NGX_HTTP_CONTENT_PHASE,
34
35 NGX_HTTP_LAST_PHASE
36 } ngx_http_phases;
37
38
39 typedef struct {
40 ngx_array_t handlers;
41 ngx_int_t type; /* NGX_OK, NGX_DECLINED */
42 } ngx_http_phase_t;
43
44
45 typedef struct {
46 ngx_array_t servers; /* array of ngx_http_core_srv_conf_t */
47
48 ngx_http_phase_t phases[NGX_HTTP_LAST_PHASE];
49 ngx_array_t index_handlers;
50
51 size_t max_server_name_len;
52 } ngx_http_core_main_conf_t;
53
54
55 typedef struct {
56 /*
57 * array of ngx_http_core_loc_conf_t, used in the translation handler
58 * and in the merge phase
59 */
60 ngx_array_t locations;
61
62 /* "listen", array of ngx_http_listen_t */
63 ngx_array_t listen;
64
65 /* "server_name", array of ngx_http_server_name_t */
66 ngx_array_t server_names;
67
68 /* server ctx */
69 ngx_http_conf_ctx_t *ctx;
70
71 size_t connection_pool_size;
72 size_t request_pool_size;
73 size_t client_header_buffer_size;
74
75 ngx_bufs_t large_client_header_buffers;
76
77 ngx_msec_t post_accept_timeout;
78 ngx_msec_t client_header_timeout;
79
80 ngx_uint_t restrict_host_names;
81 } ngx_http_core_srv_conf_t;
82
83
84 /* list of structures to find core_srv_conf quickly at run time */
85
86 typedef struct {
87 in_port_t port;
88 ngx_str_t port_text;
89 ngx_array_t addrs; /* array of ngx_http_in_addr_t */
90 } ngx_http_in_port_t;
91
92
93 typedef struct {
94 in_addr_t addr;
95 ngx_array_t names; /* array of ngx_http_server_name_t */
96 ngx_http_core_srv_conf_t *core_srv_conf; /* default server conf
97 for this address:port */
98
99 unsigned default_server:1;
100 } ngx_http_in_addr_t;
101
102
103 typedef struct {
104 ngx_str_t name;
105 ngx_http_core_srv_conf_t *core_srv_conf; /* virtual name server conf */
106 } ngx_http_server_name_t;
107
108
109 #define NGX_HTTP_TYPES_HASH_PRIME 13
110
111 #define ngx_http_types_hash_key(key, ext) \
112 { \
113 u_int n; \
114 for (key = 0, n = 0; n < ext.len; n++) { \
115 key += ext.data[n]; \
116 } \
117 key %= NGX_HTTP_TYPES_HASH_PRIME; \
118 }
119
120 typedef struct {
121 ngx_str_t exten;
122 ngx_str_t type;
123 } ngx_http_type_t;
124
125
126 typedef struct {
127 ngx_int_t status;
128 ngx_int_t overwrite;
129 ngx_str_t uri;
130 } ngx_http_err_page_t;
131
132
133 typedef struct ngx_http_core_loc_conf_s ngx_http_core_loc_conf_t;
134
135 struct ngx_http_core_loc_conf_s {
136 ngx_str_t name; /* location name */
137
138 #if (HAVE_PCRE)
139 ngx_regex_t *regex;
140 #endif
141
142 unsigned exact_match:1;
143 unsigned auto_redirect:1;
144 unsigned alias:1;
145
146 /* array of inclusive ngx_http_core_loc_conf_t */
147 ngx_array_t locations;
148
149 /* pointer to the modules' loc_conf */
150 void **loc_conf ;
151
152 ngx_http_handler_pt handler;
153
154 ngx_str_t root; /* root, alias */
155
156 ngx_array_t *types;
157 ngx_str_t default_type;
158
159 size_t client_max_body_size; /* client_max_body_size */
160 size_t client_body_buffer_size; /* client_body_buffer_size */
161 size_t send_lowat; /* send_lowat */
162 size_t postpone_output; /* postpone_output */
163 size_t limit_rate; /* limit_rate */
164
165 ngx_msec_t client_body_timeout; /* client_body_timeout */
166 ngx_msec_t send_timeout; /* send_timeout */
167 ngx_msec_t keepalive_timeout; /* keepalive_timeout */
168 ngx_msec_t lingering_time; /* lingering_time */
169 ngx_msec_t lingering_timeout; /* lingering_timeout */
170
171 time_t keepalive_header; /* keepalive_timeout */
172
173 ngx_flag_t sendfile; /* sendfile */
174 ngx_flag_t tcp_nopush; /* tcp_nopush */
175 ngx_flag_t reset_timedout_connection; /* reset_timedout_connection */
176 ngx_flag_t msie_padding; /* msie_padding */
177
178 ngx_array_t *error_pages; /* error_page */
179
180 ngx_http_cache_hash_t *open_files;
181
182 ngx_log_t *err_log;
183
184 ngx_http_core_loc_conf_t *prev_location;
185 };
186
187
188 extern ngx_http_module_t ngx_http_core_module_ctx;
189 extern ngx_module_t ngx_http_core_module;
190
191 extern int ngx_http_max_module;
192
193
194
195 ngx_int_t ngx_http_find_location_config(ngx_http_request_t *r);
196 ngx_int_t ngx_http_core_translate_handler(ngx_http_request_t *r);
197
198 ngx_int_t ngx_http_set_content_type(ngx_http_request_t *r);
199 ngx_int_t ngx_http_set_exten(ngx_http_request_t *r);
200
201 ngx_int_t ngx_http_internal_redirect(ngx_http_request_t *r,
202 ngx_str_t *uri, ngx_str_t *args);
203
204
205 typedef ngx_int_t (*ngx_http_output_header_filter_pt)(ngx_http_request_t *r);
206 typedef ngx_int_t (*ngx_http_output_body_filter_pt)
207 (ngx_http_request_t *r, ngx_chain_t *chain);
208
209
210 ngx_int_t ngx_http_output_filter(ngx_http_request_t *r, ngx_chain_t *chain);
211 ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *chain);
212
213
214 #endif /* _NGX_HTTP_CORE_H_INCLUDED_ */