Mercurial > hg > nginx
comparison src/http/ngx_http_request.c @ 1526:85e12fc61211 stable-0.5
r1468 merge:
there may be several "Connection" header lines and each may have several tokens
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 23 Sep 2007 19:20:45 +0000 |
parents | 81fa2dadc124 |
children | d5db0e96bcc6 |
comparison
equal
deleted
inserted
replaced
1525:d916a5d7de28 | 1526:85e12fc61211 |
---|---|
18 ngx_uint_t request_line); | 18 ngx_uint_t request_line); |
19 | 19 |
20 static ngx_int_t ngx_http_process_header_line(ngx_http_request_t *r, | 20 static ngx_int_t ngx_http_process_header_line(ngx_http_request_t *r, |
21 ngx_table_elt_t *h, ngx_uint_t offset); | 21 ngx_table_elt_t *h, ngx_uint_t offset); |
22 static ngx_int_t ngx_http_process_unique_header_line(ngx_http_request_t *r, | 22 static ngx_int_t ngx_http_process_unique_header_line(ngx_http_request_t *r, |
23 ngx_table_elt_t *h, ngx_uint_t offset); | |
24 static ngx_int_t ngx_http_process_connection(ngx_http_request_t *r, | |
23 ngx_table_elt_t *h, ngx_uint_t offset); | 25 ngx_table_elt_t *h, ngx_uint_t offset); |
24 static ngx_int_t ngx_http_process_cookie(ngx_http_request_t *r, | 26 static ngx_int_t ngx_http_process_cookie(ngx_http_request_t *r, |
25 ngx_table_elt_t *h, ngx_uint_t offset); | 27 ngx_table_elt_t *h, ngx_uint_t offset); |
26 | 28 |
27 static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r); | 29 static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r); |
70 ngx_http_header_t ngx_http_headers_in[] = { | 72 ngx_http_header_t ngx_http_headers_in[] = { |
71 { ngx_string("Host"), offsetof(ngx_http_headers_in_t, host), | 73 { ngx_string("Host"), offsetof(ngx_http_headers_in_t, host), |
72 ngx_http_process_unique_header_line }, | 74 ngx_http_process_unique_header_line }, |
73 | 75 |
74 { ngx_string("Connection"), offsetof(ngx_http_headers_in_t, connection), | 76 { ngx_string("Connection"), offsetof(ngx_http_headers_in_t, connection), |
75 ngx_http_process_unique_header_line }, | 77 ngx_http_process_connection }, |
76 | 78 |
77 { ngx_string("If-Modified-Since"), | 79 { ngx_string("If-Modified-Since"), |
78 offsetof(ngx_http_headers_in_t, if_modified_since), | 80 offsetof(ngx_http_headers_in_t, if_modified_since), |
79 ngx_http_process_unique_header_line }, | 81 ngx_http_process_unique_header_line }, |
80 | 82 |
1198 return NGX_ERROR; | 1200 return NGX_ERROR; |
1199 } | 1201 } |
1200 | 1202 |
1201 | 1203 |
1202 static ngx_int_t | 1204 static ngx_int_t |
1205 ngx_http_process_connection(ngx_http_request_t *r, ngx_table_elt_t *h, | |
1206 ngx_uint_t offset) | |
1207 { | |
1208 if (ngx_strstr(h->value.data, "close")) { | |
1209 r->headers_in.connection_type = NGX_HTTP_CONNECTION_CLOSE; | |
1210 | |
1211 } else if (ngx_strstr(h->value.data, "keep-alive")) { | |
1212 r->headers_in.connection_type = NGX_HTTP_CONNECTION_KEEP_ALIVE; | |
1213 } | |
1214 | |
1215 return NGX_OK; | |
1216 } | |
1217 | |
1218 | |
1219 static ngx_int_t | |
1203 ngx_http_process_cookie(ngx_http_request_t *r, ngx_table_elt_t *h, | 1220 ngx_http_process_cookie(ngx_http_request_t *r, ngx_table_elt_t *h, |
1204 ngx_uint_t offset) | 1221 ngx_uint_t offset) |
1205 { | 1222 { |
1206 ngx_table_elt_t **cookie; | 1223 ngx_table_elt_t **cookie; |
1207 | 1224 |
1316 "client sent plain HTTP request to HTTPS port"); | 1333 "client sent plain HTTP request to HTTPS port"); |
1317 ngx_http_finalize_request(r, NGX_HTTP_TO_HTTPS); | 1334 ngx_http_finalize_request(r, NGX_HTTP_TO_HTTPS); |
1318 return NGX_ERROR; | 1335 return NGX_ERROR; |
1319 } | 1336 } |
1320 | 1337 |
1321 if (r->headers_in.connection) { | 1338 if (r->headers_in.connection_type == NGX_HTTP_CONNECTION_KEEP_ALIVE) { |
1322 if (r->headers_in.connection->value.len == 5 | 1339 if (r->headers_in.keep_alive) { |
1323 && ngx_strcasecmp(r->headers_in.connection->value.data, | 1340 r->headers_in.keep_alive_n = |
1324 (u_char *) "close") | 1341 ngx_atotm(r->headers_in.keep_alive->value.data, |
1325 == 0) | 1342 r->headers_in.keep_alive->value.len); |
1326 { | |
1327 r->headers_in.connection_type = NGX_HTTP_CONNECTION_CLOSE; | |
1328 | |
1329 } else if (r->headers_in.connection->value.len == 10 | |
1330 && ngx_strcasecmp(r->headers_in.connection->value.data, | |
1331 (u_char *) "keep-alive") | |
1332 == 0) | |
1333 { | |
1334 r->headers_in.connection_type = NGX_HTTP_CONNECTION_KEEP_ALIVE; | |
1335 | |
1336 if (r->headers_in.keep_alive) { | |
1337 r->headers_in.keep_alive_n = | |
1338 ngx_atotm(r->headers_in.keep_alive->value.data, | |
1339 r->headers_in.keep_alive->value.len); | |
1340 } | |
1341 } | 1343 } |
1342 } | 1344 } |
1343 | 1345 |
1344 if (r->headers_in.user_agent) { | 1346 if (r->headers_in.user_agent) { |
1345 | 1347 |