nginx 0.1.19
[nginx-catap.git] / src / http / ngx_http_request.h
blob542a6899418c187277bf860195c4d34ca18f37f8
2 /*
3 * Copyright (C) Igor Sysoev
4 */
7 #ifndef _NGX_HTTP_REQUEST_H_INCLUDED_
8 #define _NGX_HTTP_REQUEST_H_INCLUDED_
11 #define NGX_HTTP_DISCARD_BUFFER_SIZE 4096
12 #define NGX_HTTP_LINGERING_BUFFER_SIZE 4096
15 #define NGX_HTTP_VERSION_9 9
16 #define NGX_HTTP_VERSION_10 1000
17 #define NGX_HTTP_VERSION_11 1001
19 #define NGX_HTTP_GET 1
20 #define NGX_HTTP_HEAD 2
21 #define NGX_HTTP_POST 3
23 #define NGX_HTTP_CONNECTION_CLOSE 1
24 #define NGX_HTTP_CONNECTION_KEEP_ALIVE 2
27 #define NGX_NONE 1
30 #define NGX_HTTP_PARSE_HEADER_DONE 1
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
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 16
42 #define NGX_HTTP_PARSE_INVALID_CL_HEADER 17
43 #define NGX_HTTP_PARSE_POST_WO_CL_HEADER 18
45 #define NGX_HTTP_PARSE_INVALID_HOST 19
46 #define NGX_HTTP_PARSE_HTTP_TO_HTTPS 20
49 #define NGX_HTTP_OK 200
50 #define NGX_HTTP_PARTIAL_CONTENT 206
52 #define NGX_HTTP_SPECIAL_RESPONSE 300
53 #define NGX_HTTP_MOVED_PERMANENTLY 301
54 #define NGX_HTTP_MOVED_TEMPORARILY 302
55 #define NGX_HTTP_NOT_MODIFIED 304
57 #define NGX_HTTP_BAD_REQUEST 400
58 #define NGX_HTTP_FORBIDDEN 403
59 #define NGX_HTTP_NOT_FOUND 404
60 #define NGX_HTTP_NOT_ALLOWED 405
61 #define NGX_HTTP_REQUEST_TIME_OUT 408
62 #define NGX_HTTP_REQUEST_ENTITY_TOO_LARGE 413
63 #define NGX_HTTP_REQUEST_URI_TOO_LARGE 414
64 #define NGX_HTTP_RANGE_NOT_SATISFIABLE 416
67 /* Our own HTTP codes */
69 #define NGX_HTTP_NGX_CODES NGX_HTTP_TO_HTTPS
72 * We use the special code for the plain HTTP requests that are sent to
73 * HTTPS port to distinguish it from 4XX in an error page redirection
75 #define NGX_HTTP_TO_HTTPS 497
78 * We use the special code for the requests with invalid host name
79 * to distinguish it from 4XX in an error page redirection
81 #define NGX_HTTP_INVALID_HOST 498
84 * HTTP does not define the code for the case when a client closed
85 * the connection while we are processing its request so we introduce
86 * own code to log such situation when a client has closed the connection
87 * before we even try to send the HTTP header to it
89 #define NGX_HTTP_CLIENT_CLOSED_REQUEST 499
92 #define NGX_HTTP_INTERNAL_SERVER_ERROR 500
93 #define NGX_HTTP_NOT_IMPLEMENTED 501
94 #define NGX_HTTP_BAD_GATEWAY 502
95 #define NGX_HTTP_SERVICE_UNAVAILABLE 503
96 #define NGX_HTTP_GATEWAY_TIME_OUT 504
99 typedef enum {
100 NGX_HTTP_RESTRICT_HOST_OFF = 0,
101 NGX_HTTP_RESTRICT_HOST_ON,
102 NGX_HTTP_RESTRICT_HOST_CLOSE
103 } ngx_http_restrict_host_e;
106 typedef enum {
107 NGX_HTTP_INITING_REQUEST_STATE = 0,
108 NGX_HTTP_READING_REQUEST_STATE,
109 NGX_HTTP_PROCESS_REQUEST_STATE,
111 NGX_HTTP_CONNECT_UPSTREAM_STATE,
112 NGX_HTTP_WRITING_UPSTREAM_STATE,
113 NGX_HTTP_READING_UPSTREAM_STATE,
115 NGX_HTTP_WRITING_REQUEST_STATE,
116 NGX_HTTP_LINGERING_CLOSE_STATE,
117 NGX_HTTP_KEEPALIVE_STATE
118 } ngx_http_state_e;
121 typedef struct {
122 ngx_str_t name;
123 ngx_uint_t offset;
124 } ngx_http_header_t;
127 typedef struct {
128 ngx_list_t headers;
130 ngx_table_elt_t *host;
131 ngx_table_elt_t *connection;
132 ngx_table_elt_t *if_modified_since;
133 ngx_table_elt_t *user_agent;
134 ngx_table_elt_t *referer;
135 ngx_table_elt_t *content_length;
136 ngx_table_elt_t *content_type;
138 ngx_table_elt_t *range;
140 #if (NGX_HTTP_GZIP)
141 ngx_table_elt_t *accept_encoding;
142 ngx_table_elt_t *via;
143 #endif
145 ngx_table_elt_t *authorization;
147 ngx_table_elt_t *keep_alive;
149 #if (NGX_HTTP_PROXY)
150 ngx_table_elt_t *x_forwarded_for;
151 ngx_table_elt_t *x_real_ip;
152 ngx_table_elt_t *x_url;
153 #endif
155 #if (NGX_HTTP_HEADERS)
156 ngx_table_elt_t *accept;
157 ngx_table_elt_t *accept_language;
158 #endif
160 ngx_array_t cookies;
162 size_t host_name_len;
163 ssize_t content_length_n;
164 size_t connection_type;
165 ssize_t keep_alive_n;
167 unsigned msie:1;
168 unsigned msie4:1;
169 unsigned opera:1;
170 unsigned gecko:1;
171 unsigned konqueror:1;
172 } ngx_http_headers_in_t;
175 typedef struct {
176 off_t start;
177 off_t end;
178 ngx_str_t content_range;
179 } ngx_http_range_t;
182 typedef struct {
183 ngx_list_t headers;
185 ngx_uint_t status;
186 ngx_str_t status_line;
188 ngx_table_elt_t *server;
189 ngx_table_elt_t *date;
190 ngx_table_elt_t *content_type;
191 ngx_table_elt_t *content_length;
192 ngx_table_elt_t *content_encoding;
193 ngx_table_elt_t *location;
194 ngx_table_elt_t *last_modified;
195 ngx_table_elt_t *content_range;
196 ngx_table_elt_t *accept_ranges;
197 ngx_table_elt_t *expires;
198 ngx_table_elt_t *cache_control;
199 ngx_table_elt_t *etag;
201 ngx_str_t charset;
202 ngx_array_t ranges;
204 off_t content_length_n;
205 time_t date_time;
206 time_t last_modified_time;
207 } ngx_http_headers_out_t;
210 typedef void (*ngx_http_client_body_handler_pt)(ngx_http_request_t *r);
212 typedef struct {
213 ngx_temp_file_t *temp_file;
214 ngx_chain_t *bufs;
215 ngx_buf_t *buf;
216 size_t rest;
217 ngx_http_client_body_handler_pt post_handler;
218 } ngx_http_request_body_t;
221 struct ngx_http_cleanup_s {
222 union {
223 struct {
224 ngx_fd_t fd;
225 u_char *name;
226 } file;
228 struct {
229 ngx_http_cache_hash_t *hash;
230 ngx_http_cache_entry_t *cache;
231 } cache;
232 } data;
234 unsigned valid:1;
235 unsigned cache:1;
239 typedef struct {
240 ngx_http_request_t *request;
242 ngx_buf_t **busy;
243 ngx_int_t nbusy;
245 ngx_buf_t **free;
246 ngx_int_t nfree;
248 ngx_uint_t pipeline; /* unsigned pipeline:1; */
249 } ngx_http_connection_t;
252 typedef ngx_int_t (*ngx_http_handler_pt)(ngx_http_request_t *r);
254 struct ngx_http_request_s {
255 uint32_t signature; /* "HTTP" */
257 ngx_connection_t *connection;
259 void **ctx;
260 void **main_conf;
261 void **srv_conf;
262 void **loc_conf;
264 ngx_http_cache_t *cache;
266 ngx_http_upstream_t *upstream;
268 ngx_file_t file;
270 ngx_pool_t *pool;
271 ngx_buf_t *header_in;
273 ngx_http_headers_in_t headers_in;
274 ngx_http_headers_out_t headers_out;
276 ngx_http_request_body_t *request_body;
278 time_t lingering_time;
280 ngx_uint_t method;
281 ngx_uint_t http_version;
282 ngx_uint_t http_major;
283 ngx_uint_t http_minor;
285 ngx_str_t request_line;
286 ngx_str_t uri;
287 ngx_str_t args;
288 ngx_str_t exten;
289 ngx_str_t unparsed_uri;
291 ngx_str_t method_name;
292 ngx_str_t http_protocol;
294 ngx_http_request_t *main;
296 uint32_t in_addr;
297 ngx_uint_t port;
298 ngx_str_t *port_text; /* ":80" */
299 ngx_str_t server_name;
300 ngx_http_in_addr_t *virtual_names;
302 ngx_uint_t phase;
303 ngx_int_t phase_handler;
304 ngx_http_handler_pt content_handler;
306 ngx_uint_t nvariables;
307 void **variables;
309 ngx_array_t cleanup;
311 /* used to learn the Apache compatible response length without a header */
312 size_t header_size;
314 size_t request_length;
316 u_char *discarded_buffer;
317 void **err_ctx;
318 ngx_uint_t err_status;
320 ngx_http_connection_t *http_connection;
322 unsigned http_state:4;
324 /* URI with "/." and on Win32 with "//" */
325 unsigned complex_uri:1;
327 /* URI with "%" */
328 unsigned quoted_uri:1;
330 /* URI with "+" */
331 unsigned plus_in_uri:1;
333 /* URI with "\0" or "%00" */
334 unsigned zero_in_uri:1;
336 unsigned uri_changed:1;
337 unsigned uri_changes:4;
339 unsigned low_case_exten:1;
340 unsigned header_timeout_set:1;
342 unsigned proxy:1;
343 unsigned bypass_cache:1;
344 unsigned no_cache:1;
346 #if 0
347 unsigned cachable:1;
348 #endif
349 unsigned pipeline:1;
351 unsigned plain_http:1;
352 unsigned chunked:1;
353 unsigned header_only:1;
354 unsigned keepalive:1;
355 unsigned lingering_close:1;
356 unsigned closed:1;
358 unsigned filter_need_in_memory:1;
359 unsigned filter_ssi_need_in_memory:1;
360 unsigned filter_need_temporary:1;
361 unsigned filter_allow_ranges:1;
363 #if (NGX_STAT_STUB)
364 unsigned stat_reading:1;
365 unsigned stat_writing:1;
366 #endif
368 ngx_uint_t headers_n;
370 /* used to parse HTTP headers */
371 ngx_uint_t state;
372 u_char *uri_start;
373 u_char *uri_end;
374 u_char *uri_ext;
375 u_char *args_start;
376 u_char *request_start;
377 u_char *request_end;
378 u_char *method_end;
379 u_char *schema_start;
380 u_char *schema_end;
381 u_char *host_start;
382 u_char *host_end;
383 u_char *port_start;
384 u_char *port_end;
385 u_char *header_name_start;
386 u_char *header_name_end;
387 u_char *header_start;
388 u_char *header_end;
392 extern ngx_http_header_t ngx_http_headers_in[];
393 extern ngx_http_header_t ngx_http_headers_out[];
397 #endif /* _NGX_HTTP_REQUEST_H_INCLUDED_ */