3 * Copyright (C) Igor Sysoev
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
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
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
;
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
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
;
141 ngx_table_elt_t
*accept_encoding
;
142 ngx_table_elt_t
*via
;
145 ngx_table_elt_t
*authorization
;
147 ngx_table_elt_t
*keep_alive
;
150 ngx_table_elt_t
*x_forwarded_for
;
151 ngx_table_elt_t
*x_real_ip
;
152 ngx_table_elt_t
*x_url
;
155 #if (NGX_HTTP_HEADERS)
156 ngx_table_elt_t
*accept
;
157 ngx_table_elt_t
*accept_language
;
162 size_t host_name_len
;
163 ssize_t content_length_n
;
164 size_t connection_type
;
165 ssize_t keep_alive_n
;
171 unsigned konqueror
:1;
172 } ngx_http_headers_in_t
;
178 ngx_str_t content_range
;
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
;
204 off_t content_length_n
;
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
);
213 ngx_temp_file_t
*temp_file
;
217 ngx_http_client_body_handler_pt post_handler
;
218 } ngx_http_request_body_t
;
221 struct ngx_http_cleanup_s
{
229 ngx_http_cache_hash_t
*hash
;
230 ngx_http_cache_entry_t
*cache
;
240 ngx_http_request_t
*request
;
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
;
264 ngx_http_cache_t
*cache
;
266 ngx_http_upstream_t
*upstream
;
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
;
281 ngx_uint_t http_version
;
282 ngx_uint_t http_major
;
283 ngx_uint_t http_minor
;
285 ngx_str_t request_line
;
289 ngx_str_t unparsed_uri
;
291 ngx_str_t method_name
;
292 ngx_str_t http_protocol
;
294 ngx_http_request_t
*main
;
298 ngx_str_t
*port_text
; /* ":80" */
299 ngx_str_t server_name
;
300 ngx_http_in_addr_t
*virtual_names
;
303 ngx_int_t phase_handler
;
304 ngx_http_handler_pt content_handler
;
306 ngx_uint_t nvariables
;
311 /* used to learn the Apache compatible response length without a header */
314 size_t request_length
;
316 u_char
*discarded_buffer
;
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;
328 unsigned quoted_uri
:1;
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;
343 unsigned bypass_cache
:1;
351 unsigned plain_http
:1;
353 unsigned header_only
:1;
354 unsigned keepalive
:1;
355 unsigned lingering_close
: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;
364 unsigned stat_reading
:1;
365 unsigned stat_writing
:1;
368 ngx_uint_t headers_n
;
370 /* used to parse HTTP headers */
376 u_char
*request_start
;
379 u_char
*schema_start
;
385 u_char
*header_name_start
;
386 u_char
*header_name_end
;
387 u_char
*header_start
;
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_ */