blob: 403a4fccc464d8d952fdcab5db8c00d92dbd4aff [file] [log] [blame]
Igor Sysoevd90282d2004-09-28 08:34:51 +00001
2/*
Igor Sysoevff8da912004-09-29 16:00:49 +00003 * Copyright (C) Igor Sysoev
Igor Sysoevd90282d2004-09-28 08:34:51 +00004 */
5
6
Igor Sysoeva9830112003-05-19 16:39:14 +00007#ifndef _NGX_HTTP_REQUEST_H_INCLUDED_
8#define _NGX_HTTP_REQUEST_H_INCLUDED_
9
10
Igor Sysoev6f134cc2006-05-23 14:54:58 +000011#define NGX_HTTP_MAX_URI_CHANGES 10
Igor Sysoevef809b82006-06-28 16:00:26 +000012#define NGX_HTTP_MAX_SUBREQUESTS 50
Igor Sysoev1d05de42009-03-06 12:15:07 +000013#define NGX_HTTP_MAX_CAPTURES 9
Igor Sysoev899b44e2005-05-12 14:58:06 +000014
Igor Sysoev3338cfd2006-05-11 14:43:47 +000015/* must be 2^n */
16#define NGX_HTTP_LC_HEADER_LEN 32
17
Igor Sysoev899b44e2005-05-12 14:58:06 +000018
Igor Sysoevf7abd722004-09-23 06:32:00 +000019#define NGX_HTTP_DISCARD_BUFFER_SIZE 4096
20#define NGX_HTTP_LINGERING_BUFFER_SIZE 4096
21
22
Igor Sysoev10a543a2004-03-16 07:10:12 +000023#define NGX_HTTP_VERSION_9 9
24#define NGX_HTTP_VERSION_10 1000
25#define NGX_HTTP_VERSION_11 1001
Igor Sysoeva9830112003-05-19 16:39:14 +000026
Igor Sysoev8a2b2fb2006-04-14 09:53:38 +000027#define NGX_HTTP_UNKNOWN 0x0001
28#define NGX_HTTP_GET 0x0002
29#define NGX_HTTP_HEAD 0x0004
30#define NGX_HTTP_POST 0x0008
31#define NGX_HTTP_PUT 0x0010
32#define NGX_HTTP_DELETE 0x0020
Igor Sysoev7bdb7202006-04-19 15:30:56 +000033#define NGX_HTTP_MKCOL 0x0040
Igor Sysoev8365f732006-11-14 12:43:48 +000034#define NGX_HTTP_COPY 0x0080
35#define NGX_HTTP_MOVE 0x0100
36#define NGX_HTTP_OPTIONS 0x0200
37#define NGX_HTTP_PROPFIND 0x0400
38#define NGX_HTTP_PROPPATCH 0x0800
39#define NGX_HTTP_LOCK 0x1000
40#define NGX_HTTP_UNLOCK 0x2000
Igor Sysoev3e933d22007-03-30 18:59:26 +000041#define NGX_HTTP_TRACE 0x4000
Igor Sysoeva9830112003-05-19 16:39:14 +000042
Igor Sysoev10a543a2004-03-16 07:10:12 +000043#define NGX_HTTP_CONNECTION_CLOSE 1
44#define NGX_HTTP_CONNECTION_KEEP_ALIVE 2
Igor Sysoeva9830112003-05-19 16:39:14 +000045
46
Igor Sysoev10a543a2004-03-16 07:10:12 +000047#define NGX_NONE 1
Igor Sysoev3ae32482003-10-08 15:32:54 +000048
49
Igor Sysoev10a543a2004-03-16 07:10:12 +000050#define NGX_HTTP_PARSE_HEADER_DONE 1
Igor Sysoev10fc9ef2003-10-27 08:53:49 +000051
Igor Sysoev10a543a2004-03-16 07:10:12 +000052#define NGX_HTTP_CLIENT_ERROR 10
53#define NGX_HTTP_PARSE_INVALID_METHOD 10
54#define NGX_HTTP_PARSE_INVALID_REQUEST 11
Igor Sysoevc04deca2005-03-28 14:43:02 +000055#define NGX_HTTP_PARSE_INVALID_09_METHOD 12
Igor Sysoev10fc9ef2003-10-27 08:53:49 +000056
Igor Sysoevc04deca2005-03-28 14:43:02 +000057#define NGX_HTTP_PARSE_INVALID_HEADER 13
Igor Sysoeva9830112003-05-19 16:39:14 +000058
Igor Sysoev960100e2006-10-13 15:20:10 +000059
Igor Sysoev09c684b2005-11-09 17:25:55 +000060#define NGX_HTTP_ZERO_IN_URI 1
Igor Sysoev960100e2006-10-13 15:20:10 +000061#define NGX_HTTP_SUBREQUEST_IN_MEMORY 2
Igor Sysoev851cd732008-12-08 14:23:20 +000062#define NGX_HTTP_SUBREQUEST_WAITED 4
Igor Sysoev09c684b2005-11-09 17:25:55 +000063
Igor Sysoeva9830112003-05-19 16:39:14 +000064
Igor Sysoev2b0c76c2003-10-27 21:01:00 +000065#define NGX_HTTP_OK 200
Igor Sysoev8a2b2fb2006-04-14 09:53:38 +000066#define NGX_HTTP_CREATED 201
Igor Sysoev3362b8d2005-05-14 18:42:03 +000067#define NGX_HTTP_NO_CONTENT 204
Igor Sysoev2b0c76c2003-10-27 21:01:00 +000068#define NGX_HTTP_PARTIAL_CONTENT 206
Igor Sysoeva9830112003-05-19 16:39:14 +000069
Igor Sysoev2b0c76c2003-10-27 21:01:00 +000070#define NGX_HTTP_SPECIAL_RESPONSE 300
71#define NGX_HTTP_MOVED_PERMANENTLY 301
72#define NGX_HTTP_MOVED_TEMPORARILY 302
73#define NGX_HTTP_NOT_MODIFIED 304
Igor Sysoeva9830112003-05-19 16:39:14 +000074
Igor Sysoev2b0c76c2003-10-27 21:01:00 +000075#define NGX_HTTP_BAD_REQUEST 400
Igor Sysoev4d656dc2005-03-22 16:02:46 +000076#define NGX_HTTP_UNAUTHORIZED 401
Igor Sysoev2b0c76c2003-10-27 21:01:00 +000077#define NGX_HTTP_FORBIDDEN 403
78#define NGX_HTTP_NOT_FOUND 404
79#define NGX_HTTP_NOT_ALLOWED 405
80#define NGX_HTTP_REQUEST_TIME_OUT 408
Igor Sysoev7bdb7202006-04-19 15:30:56 +000081#define NGX_HTTP_CONFLICT 409
Igor Sysoevc31a9bb2005-11-26 10:11:11 +000082#define NGX_HTTP_LENGTH_REQUIRED 411
Igor Sysoevda7281a2007-01-18 20:51:51 +000083#define NGX_HTTP_PRECONDITION_FAILED 412
Igor Sysoev2b0c76c2003-10-27 21:01:00 +000084#define NGX_HTTP_REQUEST_ENTITY_TOO_LARGE 413
85#define NGX_HTTP_REQUEST_URI_TOO_LARGE 414
Igor Sysoev7bdb7202006-04-19 15:30:56 +000086#define NGX_HTTP_UNSUPPORTED_MEDIA_TYPE 415
Igor Sysoev2b0c76c2003-10-27 21:01:00 +000087#define NGX_HTTP_RANGE_NOT_SATISFIABLE 416
Igor Sysoeva9830112003-05-19 16:39:14 +000088
Igor Sysoev3043bfc2004-05-14 16:51:47 +000089
90/* Our own HTTP codes */
91
Igor Sysoevcdc46302005-12-07 14:51:31 +000092/* The special code to close connection without any response */
93#define NGX_HTTP_CLOSE 444
94
Igor Sysoev44d87222006-05-06 16:28:56 +000095#define NGX_HTTP_OWN_CODES 495
96
97#define NGX_HTTPS_CERT_ERROR 495
98#define NGX_HTTPS_NO_CERT 496
Igor Sysoeve739eb72004-07-09 07:12:14 +000099
100/*
101 * We use the special code for the plain HTTP requests that are sent to
Igor Sysoev0e5dc5c2005-11-15 13:30:52 +0000102 * HTTPS port to distinguish it from 4XX in an error page redirection
Igor Sysoeve739eb72004-07-09 07:12:14 +0000103 */
104#define NGX_HTTP_TO_HTTPS 497
Igor Sysoev3043bfc2004-05-14 16:51:47 +0000105
Igor Sysoevc2807ec2006-02-16 15:26:46 +0000106/* 498 is the canceled code for the requests with invalid host name */
Igor Sysoev3043bfc2004-05-14 16:51:47 +0000107
Igor Sysoev222a2ad2003-11-18 16:49:00 +0000108/*
Igor Sysoeva2aca9a2004-01-18 21:09:21 +0000109 * HTTP does not define the code for the case when a client closed
110 * the connection while we are processing its request so we introduce
111 * own code to log such situation when a client has closed the connection
112 * before we even try to send the HTTP header to it
Igor Sysoev222a2ad2003-11-18 16:49:00 +0000113 */
Igor Sysoev1b138ed2003-11-18 21:34:08 +0000114#define NGX_HTTP_CLIENT_CLOSED_REQUEST 499
Igor Sysoev222a2ad2003-11-18 16:49:00 +0000115
Igor Sysoev3043bfc2004-05-14 16:51:47 +0000116
Igor Sysoev2b0c76c2003-10-27 21:01:00 +0000117#define NGX_HTTP_INTERNAL_SERVER_ERROR 500
118#define NGX_HTTP_NOT_IMPLEMENTED 501
119#define NGX_HTTP_BAD_GATEWAY 502
120#define NGX_HTTP_SERVICE_UNAVAILABLE 503
121#define NGX_HTTP_GATEWAY_TIME_OUT 504
Igor Sysoev7bdb7202006-04-19 15:30:56 +0000122#define NGX_HTTP_INSUFFICIENT_STORAGE 507
Igor Sysoeva9830112003-05-19 16:39:14 +0000123
124
Igor Sysoev020ffea2006-10-30 20:25:22 +0000125#define NGX_HTTP_LOWLEVEL_BUFFERED 0xf0
126#define NGX_HTTP_WRITE_BUFFERED 0x10
127#define NGX_HTTP_GZIP_BUFFERED 0x20
128#define NGX_HTTP_SSI_BUFFERED 0x01
Igor Sysoevd9bb8e32007-04-19 17:54:23 +0000129#define NGX_HTTP_SUB_BUFFERED 0x02
130#define NGX_HTTP_COPY_BUFFERED 0x04
Igor Sysoevdf3254a2006-01-11 15:26:57 +0000131
132
Igor Sysoev3b30a902003-12-25 20:26:58 +0000133typedef enum {
134 NGX_HTTP_INITING_REQUEST_STATE = 0,
135 NGX_HTTP_READING_REQUEST_STATE,
136 NGX_HTTP_PROCESS_REQUEST_STATE,
Igor Sysoeva9830112003-05-19 16:39:14 +0000137
Igor Sysoev3b30a902003-12-25 20:26:58 +0000138 NGX_HTTP_CONNECT_UPSTREAM_STATE,
139 NGX_HTTP_WRITING_UPSTREAM_STATE,
140 NGX_HTTP_READING_UPSTREAM_STATE,
141
142 NGX_HTTP_WRITING_REQUEST_STATE,
143 NGX_HTTP_LINGERING_CLOSE_STATE,
144 NGX_HTTP_KEEPALIVE_STATE
145} ngx_http_state_e;
Igor Sysoeva9830112003-05-19 16:39:14 +0000146
147
148typedef struct {
Igor Sysoevc1571722005-03-19 12:38:37 +0000149 ngx_str_t name;
150 ngx_uint_t offset;
Igor Sysoev899b44e2005-05-12 14:58:06 +0000151 ngx_http_header_handler_pt handler;
Igor Sysoeva9830112003-05-19 16:39:14 +0000152} ngx_http_header_t;
153
154
155typedef struct {
Igor Sysoev899b44e2005-05-12 14:58:06 +0000156 ngx_str_t name;
157 ngx_uint_t offset;
Igor Sysoev9ac946b2005-10-24 15:09:41 +0000158} ngx_http_header_out_t;
Igor Sysoev899b44e2005-05-12 14:58:06 +0000159
160
161typedef struct {
Igor Sysoevc1571722005-03-19 12:38:37 +0000162 ngx_list_t headers;
Igor Sysoevb5faed22003-10-29 08:30:44 +0000163
Igor Sysoevc1571722005-03-19 12:38:37 +0000164 ngx_table_elt_t *host;
165 ngx_table_elt_t *connection;
166 ngx_table_elt_t *if_modified_since;
167 ngx_table_elt_t *user_agent;
168 ngx_table_elt_t *referer;
169 ngx_table_elt_t *content_length;
170 ngx_table_elt_t *content_type;
Igor Sysoev67f88e92004-03-12 16:57:08 +0000171
Igor Sysoevc1571722005-03-19 12:38:37 +0000172 ngx_table_elt_t *range;
Igor Sysoev6c2f0522007-11-09 15:41:35 +0000173 ngx_table_elt_t *if_range;
Igor Sysoev7578ec92003-06-02 15:24:30 +0000174
Igor Sysoevc31a9bb2005-11-26 10:11:11 +0000175 ngx_table_elt_t *transfer_encoding;
Igor Sysoev1e1f4c82008-06-26 13:00:39 +0000176 ngx_table_elt_t *expect;
Igor Sysoevc31a9bb2005-11-26 10:11:11 +0000177
Igor Sysoev67f88e92004-03-12 16:57:08 +0000178#if (NGX_HTTP_GZIP)
Igor Sysoevc1571722005-03-19 12:38:37 +0000179 ngx_table_elt_t *accept_encoding;
180 ngx_table_elt_t *via;
Igor Sysoev67f88e92004-03-12 16:57:08 +0000181#endif
182
Igor Sysoevc1571722005-03-19 12:38:37 +0000183 ngx_table_elt_t *authorization;
Igor Sysoevcf80a702003-11-03 22:20:44 +0000184
Igor Sysoevc1571722005-03-19 12:38:37 +0000185 ngx_table_elt_t *keep_alive;
Igor Sysoeva9830112003-05-19 16:39:14 +0000186
Igor Sysoev09c684b2005-11-09 17:25:55 +0000187#if (NGX_HTTP_PROXY || NGX_HTTP_REALIP)
Igor Sysoevc1571722005-03-19 12:38:37 +0000188 ngx_table_elt_t *x_forwarded_for;
Igor Sysoev67f88e92004-03-12 16:57:08 +0000189#endif
190
Igor Sysoev09c684b2005-11-09 17:25:55 +0000191#if (NGX_HTTP_REALIP)
192 ngx_table_elt_t *x_real_ip;
193#endif
194
Igor Sysoev1ebfead2005-02-16 13:40:36 +0000195#if (NGX_HTTP_HEADERS)
Igor Sysoevc1571722005-03-19 12:38:37 +0000196 ngx_table_elt_t *accept;
197 ngx_table_elt_t *accept_language;
Igor Sysoev1ebfead2005-02-16 13:40:36 +0000198#endif
199
Igor Sysoev7bdb7202006-04-19 15:30:56 +0000200#if (NGX_HTTP_DAV)
201 ngx_table_elt_t *depth;
202 ngx_table_elt_t *destination;
Igor Sysoev56331ba2007-01-18 21:11:23 +0000203 ngx_table_elt_t *overwrite;
Igor Sysoevda173ab2006-08-30 10:39:17 +0000204 ngx_table_elt_t *date;
Igor Sysoev7bdb7202006-04-19 15:30:56 +0000205#endif
206
Igor Sysoev4d656dc2005-03-22 16:02:46 +0000207 ngx_str_t user;
208 ngx_str_t passwd;
209
Igor Sysoevc1571722005-03-19 12:38:37 +0000210 ngx_array_t cookies;
Igor Sysoev967fd632004-08-27 15:40:59 +0000211
Igor Sysoev5fd09312008-05-15 14:44:47 +0000212 ngx_str_t server;
Igor Sysoev1765f472006-07-07 16:33:19 +0000213 off_t content_length_n;
Igor Sysoevc1571722005-03-19 12:38:37 +0000214 time_t keep_alive_n;
Igor Sysoev2f657222004-06-16 15:32:11 +0000215
Igor Sysoevc1571722005-03-19 12:38:37 +0000216 unsigned connection_type:2;
217 unsigned msie:1;
218 unsigned msie4:1;
Igor Sysoev54477e42008-08-26 15:09:28 +0000219 unsigned msie6:1;
Igor Sysoevc1571722005-03-19 12:38:37 +0000220 unsigned opera:1;
221 unsigned gecko:1;
222 unsigned konqueror:1;
Igor Sysoeva9830112003-05-19 16:39:14 +0000223} ngx_http_headers_in_t;
224
225
226typedef struct {
Igor Sysoevc1571722005-03-19 12:38:37 +0000227 ngx_list_t headers;
Igor Sysoevb5faed22003-10-29 08:30:44 +0000228
Igor Sysoevc1571722005-03-19 12:38:37 +0000229 ngx_uint_t status;
230 ngx_str_t status_line;
Igor Sysoeva9830112003-05-19 16:39:14 +0000231
Igor Sysoevc1571722005-03-19 12:38:37 +0000232 ngx_table_elt_t *server;
233 ngx_table_elt_t *date;
Igor Sysoevc1571722005-03-19 12:38:37 +0000234 ngx_table_elt_t *content_length;
235 ngx_table_elt_t *content_encoding;
236 ngx_table_elt_t *location;
Igor Sysoev32717eb2007-11-27 11:56:18 +0000237 ngx_table_elt_t *refresh;
Igor Sysoevc1571722005-03-19 12:38:37 +0000238 ngx_table_elt_t *last_modified;
239 ngx_table_elt_t *content_range;
240 ngx_table_elt_t *accept_ranges;
Igor Sysoev4d656dc2005-03-22 16:02:46 +0000241 ngx_table_elt_t *www_authenticate;
Igor Sysoevc1571722005-03-19 12:38:37 +0000242 ngx_table_elt_t *expires;
Igor Sysoevc1571722005-03-19 12:38:37 +0000243 ngx_table_elt_t *etag;
Igor Sysoev7578ec92003-06-02 15:24:30 +0000244
Igor Sysoevef809b82006-06-28 16:00:26 +0000245 ngx_str_t *override_charset;
246
247 size_t content_type_len;
Igor Sysoev899b44e2005-05-12 14:58:06 +0000248 ngx_str_t content_type;
Igor Sysoevc1571722005-03-19 12:38:37 +0000249 ngx_str_t charset;
Igor Sysoevb5bc3f92008-08-04 11:29:09 +0000250 u_char *content_type_lowcase;
251 ngx_uint_t content_type_hash;
Igor Sysoeva9830112003-05-19 16:39:14 +0000252
Igor Sysoev899b44e2005-05-12 14:58:06 +0000253 ngx_array_t cache_control;
254
Igor Sysoevc1571722005-03-19 12:38:37 +0000255 off_t content_length_n;
256 time_t date_time;
257 time_t last_modified_time;
Igor Sysoeva9830112003-05-19 16:39:14 +0000258} ngx_http_headers_out_t;
259
260
Igor Sysoev02025fd2005-01-18 13:03:58 +0000261typedef void (*ngx_http_client_body_handler_pt)(ngx_http_request_t *r);
262
Igor Sysoev11dbe972004-03-29 17:43:58 +0000263typedef struct {
Igor Sysoev02025fd2005-01-18 13:03:58 +0000264 ngx_temp_file_t *temp_file;
265 ngx_chain_t *bufs;
266 ngx_buf_t *buf;
Igor Sysoev1765f472006-07-07 16:33:19 +0000267 off_t rest;
Igor Sysoev8a2b2fb2006-04-14 09:53:38 +0000268 ngx_chain_t *to_write;
Igor Sysoev02025fd2005-01-18 13:03:58 +0000269 ngx_http_client_body_handler_pt post_handler;
Igor Sysoev11dbe972004-03-29 17:43:58 +0000270} ngx_http_request_body_t;
271
272
Igor Sysoevdd888c42004-09-21 05:38:28 +0000273typedef struct {
Igor Sysoevc1571722005-03-19 12:38:37 +0000274 ngx_http_request_t *request;
Igor Sysoev4624ae72004-09-21 15:47:05 +0000275
Igor Sysoevc1571722005-03-19 12:38:37 +0000276 ngx_buf_t **busy;
277 ngx_int_t nbusy;
Igor Sysoev4624ae72004-09-21 15:47:05 +0000278
Igor Sysoevc1571722005-03-19 12:38:37 +0000279 ngx_buf_t **free;
280 ngx_int_t nfree;
Igor Sysoev4624ae72004-09-21 15:47:05 +0000281
Igor Sysoevc1571722005-03-19 12:38:37 +0000282 ngx_uint_t pipeline; /* unsigned pipeline:1; */
Igor Sysoevdd888c42004-09-21 05:38:28 +0000283} ngx_http_connection_t;
284
285
Igor Sysoev43c3bf42007-08-12 19:48:12 +0000286typedef struct ngx_http_server_name_s ngx_http_server_name_t;
287
288
289typedef struct {
290 ngx_hash_combined_t names;
291
292 ngx_uint_t nregex;
293 ngx_http_server_name_t *regex;
294} ngx_http_virtual_names_t;
Igor Sysoev305a9d82005-12-26 17:07:48 +0000295
296
Igor Sysoev9ac946b2005-10-24 15:09:41 +0000297typedef void (*ngx_http_cleanup_pt)(void *data);
298
299typedef struct ngx_http_cleanup_s ngx_http_cleanup_t;
300
301struct ngx_http_cleanup_s {
Igor Sysoev305a9d82005-12-26 17:07:48 +0000302 ngx_http_cleanup_pt handler;
303 void *data;
304 ngx_http_cleanup_t *next;
Igor Sysoev9ac946b2005-10-24 15:09:41 +0000305};
306
307
Igor Sysoev960100e2006-10-13 15:20:10 +0000308typedef ngx_int_t (*ngx_http_post_subrequest_pt)(ngx_http_request_t *r,
309 void *data, ngx_int_t rc);
310
311typedef struct {
312 ngx_http_post_subrequest_pt handler;
313 void *data;
314} ngx_http_post_subrequest_t;
315
316
Igor Sysoev899b44e2005-05-12 14:58:06 +0000317typedef struct ngx_http_postponed_request_s ngx_http_postponed_request_t;
318
319struct ngx_http_postponed_request_s {
Igor Sysoevb85fd592005-08-23 15:36:54 +0000320 ngx_http_request_t *request;
321 ngx_chain_t *out;
322 ngx_http_postponed_request_t *next;
Igor Sysoev899b44e2005-05-12 14:58:06 +0000323};
324
325
Igor Sysoev851cd732008-12-08 14:23:20 +0000326typedef struct ngx_http_posted_request_s ngx_http_posted_request_t;
327
328struct ngx_http_posted_request_s {
329 ngx_http_request_t *request;
330 ngx_http_posted_request_t *next;
331};
332
333
Igor Sysoev2f657222004-06-16 15:32:11 +0000334typedef ngx_int_t (*ngx_http_handler_pt)(ngx_http_request_t *r);
Igor Sysoev899b44e2005-05-12 14:58:06 +0000335typedef void (*ngx_http_event_handler_pt)(ngx_http_request_t *r);
336
Igor Sysoevb3e73d82003-10-10 15:10:50 +0000337
Igor Sysoeva9830112003-05-19 16:39:14 +0000338struct ngx_http_request_s {
Igor Sysoevc1571722005-03-19 12:38:37 +0000339 uint32_t signature; /* "HTTP" */
Igor Sysoevc83f6832004-06-24 07:53:37 +0000340
Igor Sysoevc1571722005-03-19 12:38:37 +0000341 ngx_connection_t *connection;
Igor Sysoeva9830112003-05-19 16:39:14 +0000342
Igor Sysoevc1571722005-03-19 12:38:37 +0000343 void **ctx;
344 void **main_conf;
345 void **srv_conf;
346 void **loc_conf;
Igor Sysoeva9830112003-05-19 16:39:14 +0000347
Igor Sysoev899b44e2005-05-12 14:58:06 +0000348 ngx_http_event_handler_pt read_event_handler;
349 ngx_http_event_handler_pt write_event_handler;
350
Igor Sysoevc1571722005-03-19 12:38:37 +0000351 ngx_http_cache_t *cache;
Igor Sysoev0e499db2003-11-27 07:45:22 +0000352
Igor Sysoevc1571722005-03-19 12:38:37 +0000353 ngx_http_upstream_t *upstream;
Igor Sysoeve0f86622007-04-18 20:23:19 +0000354 ngx_array_t *upstream_states;
355 /* of ngx_http_upstream_state_t */
Igor Sysoev02025fd2005-01-18 13:03:58 +0000356
Igor Sysoevc1571722005-03-19 12:38:37 +0000357 ngx_pool_t *pool;
358 ngx_buf_t *header_in;
Igor Sysoeva9830112003-05-19 16:39:14 +0000359
Igor Sysoevc1571722005-03-19 12:38:37 +0000360 ngx_http_headers_in_t headers_in;
361 ngx_http_headers_out_t headers_out;
Igor Sysoeva9830112003-05-19 16:39:14 +0000362
Igor Sysoevc1571722005-03-19 12:38:37 +0000363 ngx_http_request_body_t *request_body;
Igor Sysoev11dbe972004-03-29 17:43:58 +0000364
Igor Sysoevc1571722005-03-19 12:38:37 +0000365 time_t lingering_time;
Igor Sysoevb4ccb9f2007-04-21 07:50:19 +0000366 time_t start_sec;
367 ngx_msec_t start_msec;
Igor Sysoeva9830112003-05-19 16:39:14 +0000368
Igor Sysoevc1571722005-03-19 12:38:37 +0000369 ngx_uint_t method;
370 ngx_uint_t http_version;
Igor Sysoev0e5dc5c2005-11-15 13:30:52 +0000371
Igor Sysoevc1571722005-03-19 12:38:37 +0000372 ngx_str_t request_line;
373 ngx_str_t uri;
374 ngx_str_t args;
375 ngx_str_t exten;
376 ngx_str_t unparsed_uri;
Igor Sysoeva9830112003-05-19 16:39:14 +0000377
Igor Sysoevc1571722005-03-19 12:38:37 +0000378 ngx_str_t method_name;
379 ngx_str_t http_protocol;
Igor Sysoev0e5dc5c2005-11-15 13:30:52 +0000380
Igor Sysoev899b44e2005-05-12 14:58:06 +0000381 ngx_chain_t *out;
Igor Sysoevc1571722005-03-19 12:38:37 +0000382 ngx_http_request_t *main;
Igor Sysoev899b44e2005-05-12 14:58:06 +0000383 ngx_http_request_t *parent;
384 ngx_http_postponed_request_t *postponed;
Igor Sysoev960100e2006-10-13 15:20:10 +0000385 ngx_http_post_subrequest_t *post_subrequest;
Igor Sysoev851cd732008-12-08 14:23:20 +0000386 ngx_http_posted_request_t *posted_requests;
Igor Sysoeva9830112003-05-19 16:39:14 +0000387
Igor Sysoevc1571722005-03-19 12:38:37 +0000388 ngx_int_t phase_handler;
389 ngx_http_handler_pt content_handler;
Igor Sysoev31eb8c02005-09-23 11:02:22 +0000390 ngx_uint_t access_code;
Igor Sysoeva9830112003-05-19 16:39:14 +0000391
Igor Sysoev09c684b2005-11-09 17:25:55 +0000392 ngx_http_variable_value_t *variables;
Igor Sysoeva9830112003-05-19 16:39:14 +0000393
Igor Sysoev1d05de42009-03-06 12:15:07 +0000394#if (NGX_PCRE)
395 ngx_uint_t ncaptures;
396 int *captures;
397 u_char *captures_data;
398#endif
399
Igor Sysoev5192b362005-07-08 14:34:20 +0000400 size_t limit_rate;
401
Igor Sysoev11dbe972004-03-29 17:43:58 +0000402 /* used to learn the Apache compatible response length without a header */
Igor Sysoevc1571722005-03-19 12:38:37 +0000403 size_t header_size;
Igor Sysoevdc867cd2003-12-14 20:10:27 +0000404
Igor Sysoev1765f472006-07-07 16:33:19 +0000405 off_t request_length;
Igor Sysoev6a12fc92004-12-06 14:45:08 +0000406
Igor Sysoevc1571722005-03-19 12:38:37 +0000407 ngx_uint_t err_status;
Igor Sysoeva9830112003-05-19 16:39:14 +0000408
Igor Sysoevc1571722005-03-19 12:38:37 +0000409 ngx_http_connection_t *http_connection;
Igor Sysoevdd888c42004-09-21 05:38:28 +0000410
Igor Sysoev899b44e2005-05-12 14:58:06 +0000411 ngx_http_log_handler_pt log_handler;
412
Igor Sysoev9ac946b2005-10-24 15:09:41 +0000413 ngx_http_cleanup_t *cleanup;
414
Igor Sysoevc1571722005-03-19 12:38:37 +0000415 unsigned http_state:4;
Igor Sysoev3b30a902003-12-25 20:26:58 +0000416
Igor Sysoev924bd792004-10-11 15:07:03 +0000417 /* URI with "/." and on Win32 with "//" */
Igor Sysoevc1571722005-03-19 12:38:37 +0000418 unsigned complex_uri:1;
Igor Sysoev805d9db2005-02-03 19:33:37 +0000419
Igor Sysoev924bd792004-10-11 15:07:03 +0000420 /* URI with "%" */
Igor Sysoevc1571722005-03-19 12:38:37 +0000421 unsigned quoted_uri:1;
Igor Sysoev805d9db2005-02-03 19:33:37 +0000422
423 /* URI with "+" */
Igor Sysoevc1571722005-03-19 12:38:37 +0000424 unsigned plus_in_uri:1;
Igor Sysoev805d9db2005-02-03 19:33:37 +0000425
Igor Sysoev1ebfead2005-02-16 13:40:36 +0000426 /* URI with "\0" or "%00" */
Igor Sysoevc1571722005-03-19 12:38:37 +0000427 unsigned zero_in_uri:1;
Igor Sysoev1ebfead2005-02-16 13:40:36 +0000428
Igor Sysoev3362b8d2005-05-14 18:42:03 +0000429 unsigned invalid_header:1;
430
Igor Sysoev899b44e2005-05-12 14:58:06 +0000431 unsigned valid_location:1;
Igor Sysoevc04deca2005-03-28 14:43:02 +0000432 unsigned valid_unparsed_uri:1;
Igor Sysoevc1571722005-03-19 12:38:37 +0000433 unsigned uri_changed:1;
434 unsigned uri_changes:4;
Igor Sysoev805d9db2005-02-03 19:33:37 +0000435
Igor Sysoev8a2b2fb2006-04-14 09:53:38 +0000436 unsigned request_body_in_single_buf:1;
437 unsigned request_body_in_file_only:1;
438 unsigned request_body_in_persistent_file:1;
Igor Sysoevcd5b99a2007-01-25 08:45:04 +0000439 unsigned request_body_in_clean_file:1;
Igor Sysoev8a2b2fb2006-04-14 09:53:38 +0000440 unsigned request_body_file_group_access:1;
Igor Sysoev7bdb7202006-04-19 15:30:56 +0000441 unsigned request_body_file_log_level:3;
Igor Sysoev8a2b2fb2006-04-14 09:53:38 +0000442
Igor Sysoev960100e2006-10-13 15:20:10 +0000443 unsigned subrequest_in_memory:1;
Igor Sysoev851cd732008-12-08 14:23:20 +0000444 unsigned waited:1;
Igor Sysoevdf3254a2006-01-11 15:26:57 +0000445
Igor Sysoevc16b0052007-12-27 14:21:59 +0000446 unsigned gzip:2;
447
Igor Sysoevc1571722005-03-19 12:38:37 +0000448 unsigned proxy:1;
449 unsigned bypass_cache:1;
450 unsigned no_cache:1;
Igor Sysoev65977492003-11-02 22:56:18 +0000451
Igor Sysoev6eee8012007-01-07 17:47:17 +0000452 /*
Igor Sysoevabe378e2008-11-10 15:22:33 +0000453 * instead of using the request context data in
Igor Sysoevead80912008-11-11 16:04:05 +0000454 * ngx_http_limit_zone_module and ngx_http_limit_req_module
Igor Sysoevabe378e2008-11-10 15:22:33 +0000455 * we use the single bits in the request structure
Igor Sysoev6eee8012007-01-07 17:47:17 +0000456 */
457 unsigned limit_zone_set:1;
Igor Sysoevabe378e2008-11-10 15:22:33 +0000458 unsigned limit_req_set:1;
Igor Sysoev6eee8012007-01-07 17:47:17 +0000459
Igor Sysoev7578ec92003-06-02 15:24:30 +0000460#if 0
Igor Sysoev2d3f3f62007-10-14 18:56:15 +0000461 unsigned cacheable:1;
Igor Sysoeva9830112003-05-19 16:39:14 +0000462#endif
463
Igor Sysoev899b44e2005-05-12 14:58:06 +0000464 unsigned pipeline:1;
Igor Sysoevc1571722005-03-19 12:38:37 +0000465 unsigned plain_http:1;
466 unsigned chunked:1;
467 unsigned header_only:1;
Igor Sysoev8fd830a2006-10-02 10:22:51 +0000468 unsigned zero_body:1;
Igor Sysoevc1571722005-03-19 12:38:37 +0000469 unsigned keepalive:1;
470 unsigned lingering_close:1;
Igor Sysoeve5035392005-08-30 10:55:07 +0000471 unsigned discard_body:1;
Igor Sysoev899b44e2005-05-12 14:58:06 +0000472 unsigned internal:1;
Igor Sysoev3f8dc592006-08-28 16:57:48 +0000473 unsigned error_page:1;
Igor Sysoev6d16e1e2006-04-05 13:40:54 +0000474 unsigned post_action:1;
475 unsigned request_complete:1;
Igor Sysoev8f125582006-07-28 15:16:17 +0000476 unsigned request_output:1;
477 unsigned header_sent:1;
Igor Sysoev1e1f4c82008-06-26 13:00:39 +0000478 unsigned expect_tested:1;
Igor Sysoevedf1c8c2008-07-07 09:26:13 +0000479 unsigned root_tested:1;
Igor Sysoev899b44e2005-05-12 14:58:06 +0000480 unsigned done:1;
Igor Sysoeveb62fa02008-09-29 13:18:41 +0000481 unsigned logged:1;
Igor Sysoevb145b062005-06-15 18:33:41 +0000482 unsigned utf8:1;
Igor Sysoev7578ec92003-06-02 15:24:30 +0000483
Igor Sysoev020ffea2006-10-30 20:25:22 +0000484 unsigned buffered:4;
485
Igor Sysoevd52477f2005-05-16 13:53:20 +0000486 unsigned main_filter_need_in_memory:1;
Igor Sysoevc1571722005-03-19 12:38:37 +0000487 unsigned filter_need_in_memory:1;
Igor Sysoevc1571722005-03-19 12:38:37 +0000488 unsigned filter_need_temporary:1;
Igor Sysoevc31a9bb2005-11-26 10:11:11 +0000489 unsigned allow_ranges:1;
Igor Sysoev7578ec92003-06-02 15:24:30 +0000490
Igor Sysoev85cccfb2004-09-15 16:00:43 +0000491#if (NGX_STAT_STUB)
Igor Sysoevc1571722005-03-19 12:38:37 +0000492 unsigned stat_reading:1;
493 unsigned stat_writing:1;
Igor Sysoev85cccfb2004-09-15 16:00:43 +0000494#endif
495
Igor Sysoevef809b82006-06-28 16:00:26 +0000496 unsigned subrequests:8;
497
Igor Sysoev7578ec92003-06-02 15:24:30 +0000498 /* used to parse HTTP headers */
Igor Sysoevc3df7982006-10-12 13:08:26 +0000499
Igor Sysoevc1571722005-03-19 12:38:37 +0000500 ngx_uint_t state;
501 u_char *uri_start;
502 u_char *uri_end;
503 u_char *uri_ext;
504 u_char *args_start;
505 u_char *request_start;
506 u_char *request_end;
507 u_char *method_end;
508 u_char *schema_start;
509 u_char *schema_end;
510 u_char *host_start;
511 u_char *host_end;
512 u_char *port_start;
513 u_char *port_end;
514 u_char *header_name_start;
515 u_char *header_name_end;
516 u_char *header_start;
517 u_char *header_end;
Igor Sysoev3338cfd2006-05-11 14:43:47 +0000518
Igor Sysoevc3df7982006-10-12 13:08:26 +0000519 unsigned http_minor:16;
520 unsigned http_major:16;
521
Igor Sysoev02f742b2005-04-08 15:18:55 +0000522 ngx_uint_t header_hash;
Igor Sysoev3338cfd2006-05-11 14:43:47 +0000523 ngx_uint_t lowcase_index;
524 u_char lowcase_header[NGX_HTTP_LC_HEADER_LEN];
Igor Sysoeva9830112003-05-19 16:39:14 +0000525};
526
527
Igor Sysoev9ac946b2005-10-24 15:09:41 +0000528extern ngx_http_header_t ngx_http_headers_in[];
529extern ngx_http_header_out_t ngx_http_headers_out[];
Igor Sysoevb5faed22003-10-29 08:30:44 +0000530
531
Igor Sysoeva9830112003-05-19 16:39:14 +0000532#endif /* _NGX_HTTP_REQUEST_H_INCLUDED_ */