comparison src/http/ngx_http_request.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_REQUEST_H_INCLUDED_
8 #define _NGX_HTTP_REQUEST_H_INCLUDED_
9
10
11 #define NGX_HTTP_DISCARD_BUFFER_SIZE 4096
12 #define NGX_HTTP_LINGERING_BUFFER_SIZE 4096
13
14
15 #define NGX_HTTP_VERSION_9 9
16 #define NGX_HTTP_VERSION_10 1000
17 #define NGX_HTTP_VERSION_11 1001
18
19 #define NGX_HTTP_GET 1
20 #define NGX_HTTP_HEAD 2
21 #define NGX_HTTP_POST 3
22
23 #define NGX_HTTP_CONNECTION_CLOSE 1
24 #define NGX_HTTP_CONNECTION_KEEP_ALIVE 2
25
26
27 #define NGX_NONE 1
28
29
30 #define NGX_HTTP_PARSE_HEADER_DONE 1
31
32 #define NGX_HTTP_CLIENT_ERROR 10
33 #define NGX_HTTP_PARSE_INVALID_METHOD 10
34 #define NGX_HTTP_PARSE_INVALID_REQUEST 11
35 #define NGX_HTTP_PARSE_TOO_LONG_URI 12
36 #define NGX_HTTP_PARSE_INVALID_09_METHOD 13
37
38 #define NGX_HTTP_PARSE_HEADER_ERROR 14
39 #define NGX_HTTP_PARSE_INVALID_HEADER 14
40 #define NGX_HTTP_PARSE_TOO_LONG_HEADER 15
41 #define NGX_HTTP_PARSE_NO_HOST_HEADER 17
42 #define NGX_HTTP_PARSE_INVALID_CL_HEADER 18
43 #define NGX_HTTP_PARSE_POST_WO_CL_HEADER 19
44 #define NGX_HTTP_PARSE_HTTP_TO_HTTPS 20
45 #define NGX_HTTP_PARSE_INVALID_HOST 21
46
47
48 #define NGX_HTTP_OK 200
49 #define NGX_HTTP_PARTIAL_CONTENT 206
50
51 #define NGX_HTTP_SPECIAL_RESPONSE 300
52 #define NGX_HTTP_MOVED_PERMANENTLY 301
53 #define NGX_HTTP_MOVED_TEMPORARILY 302
54 #define NGX_HTTP_NOT_MODIFIED 304
55
56 #define NGX_HTTP_BAD_REQUEST 400
57 #define NGX_HTTP_FORBIDDEN 403
58 #define NGX_HTTP_NOT_FOUND 404
59 #define NGX_HTTP_NOT_ALLOWED 405
60 #define NGX_HTTP_REQUEST_TIME_OUT 408
61 #define NGX_HTTP_REQUEST_ENTITY_TOO_LARGE 413
62 #define NGX_HTTP_REQUEST_URI_TOO_LARGE 414
63 #define NGX_HTTP_RANGE_NOT_SATISFIABLE 416
64
65
66 /* Our own HTTP codes */
67
68 #define NGX_HTTP_NGX_CODES NGX_HTTP_TO_HTTPS
69
70 /*
71 * We use the special code for the plain HTTP requests that are sent to
72 * HTTPS port to distinguish it from 4XX in an error page redirection
73 */
74 #define NGX_HTTP_TO_HTTPS 497
75
76 /*
77 * We use the special code for the requests with invalid host name
78 * to distinguish it from 4XX in an error page redirection
79 */
80 #define NGX_HTTP_INVALID_HOST 498
81
82 /*
83 * HTTP does not define the code for the case when a client closed
84 * the connection while we are processing its request so we introduce
85 * own code to log such situation when a client has closed the connection
86 * before we even try to send the HTTP header to it
87 */
88 #define NGX_HTTP_CLIENT_CLOSED_REQUEST 499
89
90
91 #define NGX_HTTP_INTERNAL_SERVER_ERROR 500
92 #define NGX_HTTP_NOT_IMPLEMENTED 501
93 #define NGX_HTTP_BAD_GATEWAY 502
94 #define NGX_HTTP_SERVICE_UNAVAILABLE 503
95 #define NGX_HTTP_GATEWAY_TIME_OUT 504
96
97
98 typedef enum {
99 NGX_HTTP_RESTRICT_HOST_OFF = 0,
100 NGX_HTTP_RESTRICT_HOST_ON,
101 NGX_HTTP_RESTRICT_HOST_CLOSE
102 } ngx_http_restrict_host_e;
103
104
105 typedef enum {
106 NGX_HTTP_INITING_REQUEST_STATE = 0,
107 NGX_HTTP_READING_REQUEST_STATE,
108 NGX_HTTP_PROCESS_REQUEST_STATE,
109
110 NGX_HTTP_CONNECT_UPSTREAM_STATE,
111 NGX_HTTP_WRITING_UPSTREAM_STATE,
112 NGX_HTTP_READING_UPSTREAM_STATE,
113
114 NGX_HTTP_WRITING_REQUEST_STATE,
115 NGX_HTTP_LINGERING_CLOSE_STATE,
116 NGX_HTTP_KEEPALIVE_STATE
117 } ngx_http_state_e;
118
119
120 typedef struct {
121 ngx_str_t name;
122 ngx_uint_t offset;
123 } ngx_http_header_t;
124
125
126 typedef struct {
127 ngx_list_t headers;
128
129 ngx_table_elt_t *host;
130 ngx_table_elt_t *connection;
131 ngx_table_elt_t *if_modified_since;
132 ngx_table_elt_t *user_agent;
133 ngx_table_elt_t *referer;
134 ngx_table_elt_t *content_length;
135
136 ngx_table_elt_t *range;
137
138 #if (NGX_HTTP_GZIP)
139 ngx_table_elt_t *accept_encoding;
140 ngx_table_elt_t *via;
141 #endif
142
143 ngx_table_elt_t *authorization;
144
145 ngx_table_elt_t *keep_alive;
146
147 #if (NGX_HTTP_PROXY)
148 ngx_table_elt_t *x_forwarded_for;
149 #endif
150
151 ngx_array_t cookies;
152
153 size_t host_name_len;
154 ssize_t content_length_n;
155 size_t connection_type;
156 ssize_t keep_alive_n;
157
158 unsigned msie:1;
159 unsigned msie4:1;
160 unsigned opera:1;
161 unsigned gecko:1;
162 unsigned konqueror:1;
163 } ngx_http_headers_in_t;
164
165
166 typedef struct {
167 off_t start;
168 off_t end;
169 ngx_str_t content_range;
170 } ngx_http_range_t;
171
172
173 typedef struct {
174 ngx_list_t headers;
175
176 ngx_uint_t status;
177 ngx_str_t status_line;
178
179 ngx_table_elt_t *server;
180 ngx_table_elt_t *date;
181 ngx_table_elt_t *content_type;
182 ngx_table_elt_t *content_length;
183 ngx_table_elt_t *content_encoding;
184 ngx_table_elt_t *location;
185 ngx_table_elt_t *last_modified;
186 ngx_table_elt_t *content_range;
187 ngx_table_elt_t *accept_ranges;
188 ngx_table_elt_t *expires;
189 ngx_table_elt_t *cache_control;
190 ngx_table_elt_t *etag;
191
192 ngx_str_t charset;
193 ngx_array_t ranges;
194
195 off_t content_length_n;
196 time_t date_time;
197 time_t last_modified_time;
198 } ngx_http_headers_out_t;
199
200
201 typedef struct {
202 ngx_temp_file_t *temp_file;
203 ngx_chain_t *bufs;
204 ngx_buf_t *buf;
205 size_t rest;
206 void (*handler) (void *data);
207 void *data;
208 } ngx_http_request_body_t;
209
210
211 struct ngx_http_cleanup_s {
212 union {
213 struct {
214 ngx_fd_t fd;
215 u_char *name;
216 } file;
217
218 struct {
219 ngx_http_cache_hash_t *hash;
220 ngx_http_cache_t *cache;
221 } cache;
222 } data;
223
224 unsigned valid:1;
225 unsigned cache:1;
226 };
227
228
229 typedef struct {
230 ngx_http_request_t *request;
231
232 ngx_buf_t **busy;
233 ngx_int_t nbusy;
234
235 ngx_buf_t **free;
236 ngx_int_t nfree;
237
238 ngx_uint_t pipeline; /* unsigned pipeline:1; */
239 } ngx_http_connection_t;
240
241
242 typedef ngx_int_t (*ngx_http_handler_pt)(ngx_http_request_t *r);
243
244 struct ngx_http_request_s {
245 uint32_t signature; /* "HTTP" */
246
247 ngx_connection_t *connection;
248
249 void **ctx;
250 void **main_conf;
251 void **srv_conf;
252 void **loc_conf;
253
254 ngx_http_cache_t *cache;
255
256 ngx_file_t file;
257
258 ngx_pool_t *pool;
259 ngx_buf_t *header_in;
260
261 ngx_http_headers_in_t headers_in;
262 ngx_http_headers_out_t headers_out;
263
264 ngx_http_request_body_t *request_body;
265
266 time_t lingering_time;
267
268 ngx_uint_t method;
269 ngx_uint_t http_version;
270 ngx_uint_t http_major;
271 ngx_uint_t http_minor;
272
273 ngx_str_t request_line;
274 ngx_str_t uri;
275 ngx_str_t args;
276 ngx_str_t exten;
277 ngx_str_t unparsed_uri;
278
279 ngx_str_t method_name;
280
281 ngx_http_request_t *main;
282
283 uint32_t in_addr;
284 ngx_uint_t port;
285 ngx_str_t *port_text; /* ":80" */
286 ngx_str_t *server_name;
287 ngx_array_t *virtual_names;
288
289 ngx_uint_t phase;
290 ngx_int_t phase_handler;
291 ngx_http_handler_pt content_handler;
292
293 ngx_array_t cleanup;
294
295 /* used to learn the Apache compatible response length without a header */
296 size_t header_size;
297
298 u_char *discarded_buffer;
299 void **err_ctx;
300 ngx_uint_t err_status;
301
302 ngx_http_connection_t *http_connection;
303
304 unsigned http_state:4;
305
306 #if 0
307 /* URI is not started with '/' - "GET http://" */
308 unsigned unusual_uri:1;
309 #endif
310 /* URI with "/.", "%" and on Win32 with "//" */
311 unsigned complex_uri:1;
312 unsigned header_timeout_set:1;
313
314 unsigned proxy:1;
315 unsigned bypass_cache:1;
316 unsigned no_cache:1;
317
318 #if 0
319 unsigned cachable:1;
320 #endif
321 unsigned pipeline:1;
322
323 /* can we use sendfile ? */
324 unsigned sendfile:1;
325
326 unsigned plain_http:1;
327 unsigned chunked:1;
328 unsigned header_only:1;
329 unsigned keepalive:1;
330 unsigned lingering_close:1;
331 unsigned closed:1;
332
333 unsigned filter_need_in_memory:1;
334 unsigned filter_ssi_need_in_memory:1;
335 unsigned filter_need_temporary:1;
336 unsigned filter_allow_ranges:1;
337
338 #if (NGX_STAT_STUB)
339 unsigned stat_reading:1;
340 unsigned stat_writing:1;
341 #endif
342
343 ngx_uint_t headers_n;
344
345 /* used to parse HTTP headers */
346 ngx_uint_t state;
347 u_char *uri_start;
348 u_char *uri_end;
349 u_char *uri_ext;
350 u_char *args_start;
351 u_char *request_start;
352 u_char *request_end;
353 u_char *method_end;
354 u_char *schema_start;
355 u_char *schema_end;
356 u_char *host_start;
357 u_char *host_end;
358 u_char *port_start;
359 u_char *port_end;
360 u_char *header_name_start;
361 u_char *header_name_end;
362 u_char *header_start;
363 u_char *header_end;
364 };
365
366
367 extern ngx_http_header_t ngx_http_headers_in[];
368 extern ngx_http_header_t ngx_http_headers_out[];
369
370
371
372 #endif /* _NGX_HTTP_REQUEST_H_INCLUDED_ */