blob: 5b396b11c1f3bd0ffa8b99dd790eb7fe5c814acd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
|
#ifndef _NGX_HTTP_REQUEST_H_INCLUDED_
#define _NGX_HTTP_REQUEST_H_INCLUDED_
#define NGX_HTTP_VERSION_9 9
#define NGX_HTTP_VERSION_10 1000
#define NGX_HTTP_VERSION_11 1001
#define NGX_HTTP_GET 1
#define NGX_HTTP_HEAD 2
#define NGX_HTTP_POST 3
#define NGX_HTTP_CONNECTION_CLOSE 1
#define NGX_HTTP_CONNECTION_KEEP_ALIVE 2
#define NGX_NONE 1
#define NGX_HTTP_PARSE_HEADER_DONE 1
#define NGX_HTTP_CLIENT_ERROR 10
#define NGX_HTTP_PARSE_INVALID_METHOD 10
#define NGX_HTTP_PARSE_INVALID_REQUEST 11
#define NGX_HTTP_PARSE_TOO_LONG_URI 12
#define NGX_HTTP_PARSE_INVALID_09_METHOD 13
#define NGX_HTTP_PARSE_HEADER_ERROR 14
#define NGX_HTTP_PARSE_INVALID_HEADER 14
#define NGX_HTTP_PARSE_TOO_LONG_HEADER 15
#define NGX_HTTP_PARSE_NO_HOST_HEADER 16
#define NGX_HTTP_PARSE_INVALID_CL_HEADER 17
#define NGX_HTTP_OK 200
#define NGX_HTTP_PARTIAL_CONTENT 206
#define NGX_HTTP_SPECIAL_RESPONSE 300
#define NGX_HTTP_MOVED_PERMANENTLY 301
#define NGX_HTTP_MOVED_TEMPORARILY 302
#define NGX_HTTP_NOT_MODIFIED 304
#define NGX_HTTP_BAD_REQUEST 400
#define NGX_HTTP_FORBIDDEN 403
#define NGX_HTTP_NOT_FOUND 404
#define NGX_HTTP_NOT_ALLOWED 405
#define NGX_HTTP_REQUEST_TIME_OUT 408
#define NGX_HTTP_REQUEST_ENTITY_TOO_LARGE 413
#define NGX_HTTP_REQUEST_URI_TOO_LARGE 414
#define NGX_HTTP_RANGE_NOT_SATISFIABLE 416
/*
* HTTP does not define a code for the case when a client closed a connection
* while we are processing request so we introduce own code to log such
* situation when client has closed a connection before we even try to
* send HTTP header to it
*/
#define NGX_HTTP_CLIENT_CLOSED_REQUEST 499
#define NGX_HTTP_INTERNAL_SERVER_ERROR 500
#define NGX_HTTP_NOT_IMPLEMENTED 501
#define NGX_HTTP_BAD_GATEWAY 502
#define NGX_HTTP_SERVICE_UNAVAILABLE 503
#define NGX_HTTP_GATEWAY_TIME_OUT 504
typedef enum {
NGX_HTTP_INITING_REQUEST_STATE = 0,
NGX_HTTP_READING_REQUEST_STATE,
NGX_HTTP_PROCESS_REQUEST_STATE,
NGX_HTTP_CONNECT_UPSTREAM_STATE,
NGX_HTTP_WRITING_UPSTREAM_STATE,
NGX_HTTP_READING_UPSTREAM_STATE,
NGX_HTTP_WRITING_REQUEST_STATE,
NGX_HTTP_LINGERING_CLOSE_STATE,
NGX_HTTP_KEEPALIVE_STATE
} ngx_http_state_e;
typedef struct {
ngx_str_t name;
int offset;
} ngx_http_header_t;
typedef struct {
ngx_table_t *headers; /* it must be first field */
ngx_table_elt_t *host;
ngx_table_elt_t *connection;
ngx_table_elt_t *if_modified_since;
ngx_table_elt_t *user_agent;
ngx_table_elt_t *referer;
ngx_table_elt_t *content_length;
ngx_table_elt_t *accept_encoding;
ngx_table_elt_t *range;
ngx_table_elt_t *authorization;
ngx_table_elt_t *keep_alive;
size_t host_name_len;
ssize_t content_length_n;
size_t connection_type;
ssize_t keep_alive_n;
} ngx_http_headers_in_t;
typedef struct {
ngx_chain_t chain[4];
ngx_hunk_t *header_out;
ngx_hunk_t *hunk;
ngx_hunk_t *file_hunk;
ngx_file_t temp_file;
ngx_path_t *temp_path;
off_t offset;
char *header_in_pos;
} ngx_http_request_body_t;
typedef struct {
off_t start;
off_t end;
ngx_str_t content_range;
} ngx_http_range_t;
typedef struct {
ngx_table_t *headers; /* it must be first field */
int status;
ngx_str_t status_line;
ngx_table_elt_t *server;
ngx_table_elt_t *date;
ngx_table_elt_t *content_type;
ngx_table_elt_t *content_length;
ngx_table_elt_t *content_encoding;
ngx_table_elt_t *location;
ngx_table_elt_t *last_modified;
ngx_table_elt_t *content_range;
ngx_table_elt_t *accept_ranges;
ngx_str_t charset;
ngx_array_t ranges;
off_t content_length_n;
char *etag;
time_t date_time;
time_t last_modified_time;
} ngx_http_headers_out_t;
struct ngx_http_cleanup_s {
union {
struct {
ngx_fd_t fd;
char *name;
} file;
struct {
ngx_http_cache_hash_t *hash;
ngx_http_cache_t *cache;
} cache;
} data;
unsigned valid:1;
unsigned cache:1;
};
typedef int (*ngx_http_handler_pt)(ngx_http_request_t *r);
struct ngx_http_request_s {
ngx_connection_t *connection;
void **ctx;
void **main_conf;
void **srv_conf;
void **loc_conf;
ngx_http_cache_t *cache;
ngx_file_t file;
ngx_pool_t *pool;
ngx_hunk_t *header_in;
ngx_http_request_body_t *request_body;
ngx_http_headers_in_t headers_in;
ngx_http_headers_out_t headers_out;
time_t lingering_time;
int method;
int http_version;
int http_major;
int http_minor;
ngx_str_t request_line;
ngx_str_t uri;
ngx_str_t args;
ngx_str_t exten;
ngx_str_t unparsed_uri;
ngx_http_request_t *main;
u_int in_addr;
int port;
ngx_str_t *port_name; /* ":80" */
ngx_str_t *server_name;
ngx_array_t *virtual_names;
int phase;
int phase_handler;
ngx_http_handler_pt content_handler;
ngx_temp_file_t *temp_file;
ngx_chain_t *request_hunks;
ngx_hunk_t *request_body_hunk;
int request_body_len;
void (*request_body_handler) (void *data);
void *data;
ngx_array_t cleanup;
size_t header_size;
char *discarded_buffer;
void **err_ctx;
int err_status;
unsigned http_state:4;
/* URI is not started with '/' - "GET http://" */
unsigned unusual_uri:1;
/* URI with "/.", "%" and on Win32 with "//" */
unsigned complex_uri:1;
unsigned header_timeout_set:1;
unsigned proxy:1;
unsigned bypass_cache:1;
unsigned no_cache:1;
#if 0
unsigned cachable:1;
#endif
unsigned pipeline:1;
/* can we use sendfile ? */
unsigned sendfile:1;
unsigned chunked:1;
unsigned header_only:1;
unsigned keepalive:1;
unsigned lingering_close:1;
#if 0
unsigned closed:1;
#endif
/* TODO: use filter or bits ???? */
int filter;
/* used to parse HTTP headers */
int state;
char *uri_start;
char *uri_end;
char *uri_ext;
char *args_start;
char *request_start;
char *request_end;
char *header_name_start;
char *header_name_end;
char *header_start;
char *header_end;
};
extern ngx_http_header_t ngx_http_headers_in[];
extern ngx_http_header_t ngx_http_headers_out[];
#endif /* _NGX_HTTP_REQUEST_H_INCLUDED_ */
|