comparison src/http/ngx_http_request.c @ 1467:e5352b711c47

there may be several "Connection" header lines and each may have several tokens
author Igor Sysoev <igor@sysoev.ru>
date Sun, 09 Sep 2007 18:28:49 +0000
parents 3263e4b17903
children 8596627c4cc5
comparison
equal deleted inserted replaced
1466:943f2ba615cd 1467:e5352b711c47
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);
69 ngx_http_header_t ngx_http_headers_in[] = { 71 ngx_http_header_t ngx_http_headers_in[] = {
70 { ngx_string("Host"), offsetof(ngx_http_headers_in_t, host), 72 { ngx_string("Host"), offsetof(ngx_http_headers_in_t, host),
71 ngx_http_process_unique_header_line }, 73 ngx_http_process_unique_header_line },
72 74
73 { ngx_string("Connection"), offsetof(ngx_http_headers_in_t, connection), 75 { ngx_string("Connection"), offsetof(ngx_http_headers_in_t, connection),
74 ngx_http_process_unique_header_line }, 76 ngx_http_process_connection },
75 77
76 { ngx_string("If-Modified-Since"), 78 { ngx_string("If-Modified-Since"),
77 offsetof(ngx_http_headers_in_t, if_modified_since), 79 offsetof(ngx_http_headers_in_t, if_modified_since),
78 ngx_http_process_unique_header_line }, 80 ngx_http_process_unique_header_line },
79 81
1197 return NGX_ERROR; 1199 return NGX_ERROR;
1198 } 1200 }
1199 1201
1200 1202
1201 static ngx_int_t 1203 static ngx_int_t
1204 ngx_http_process_connection(ngx_http_request_t *r, ngx_table_elt_t *h,
1205 ngx_uint_t offset)
1206 {
1207 if (ngx_strstr(h->value.data, "close")) {
1208 r->headers_in.connection_type = NGX_HTTP_CONNECTION_CLOSE;
1209
1210 } else if (ngx_strstr(h->value.data, "keep-alive")) {
1211 r->headers_in.connection_type = NGX_HTTP_CONNECTION_KEEP_ALIVE;
1212 }
1213
1214 return NGX_OK;
1215 }
1216
1217
1218 static ngx_int_t
1202 ngx_http_process_cookie(ngx_http_request_t *r, ngx_table_elt_t *h, 1219 ngx_http_process_cookie(ngx_http_request_t *r, ngx_table_elt_t *h,
1203 ngx_uint_t offset) 1220 ngx_uint_t offset)
1204 { 1221 {
1205 ngx_table_elt_t **cookie; 1222 ngx_table_elt_t **cookie;
1206 1223
1315 "client sent plain HTTP request to HTTPS port"); 1332 "client sent plain HTTP request to HTTPS port");
1316 ngx_http_finalize_request(r, NGX_HTTP_TO_HTTPS); 1333 ngx_http_finalize_request(r, NGX_HTTP_TO_HTTPS);
1317 return NGX_ERROR; 1334 return NGX_ERROR;
1318 } 1335 }
1319 1336
1320 if (r->headers_in.connection) { 1337 if (r->headers_in.connection_type == NGX_HTTP_CONNECTION_KEEP_ALIVE) {
1321 if (r->headers_in.connection->value.len == 5 1338 if (r->headers_in.keep_alive) {
1322 && ngx_strcasecmp(r->headers_in.connection->value.data, 1339 r->headers_in.keep_alive_n =
1323 (u_char *) "close") 1340 ngx_atotm(r->headers_in.keep_alive->value.data,
1324 == 0) 1341 r->headers_in.keep_alive->value.len);
1325 {
1326 r->headers_in.connection_type = NGX_HTTP_CONNECTION_CLOSE;
1327
1328 } else if (r->headers_in.connection->value.len == 10
1329 && ngx_strcasecmp(r->headers_in.connection->value.data,
1330 (u_char *) "keep-alive")
1331 == 0)
1332 {
1333 r->headers_in.connection_type = NGX_HTTP_CONNECTION_KEEP_ALIVE;
1334
1335 if (r->headers_in.keep_alive) {
1336 r->headers_in.keep_alive_n =
1337 ngx_atotm(r->headers_in.keep_alive->value.data,
1338 r->headers_in.keep_alive->value.len);
1339 }
1340 } 1342 }
1341 } 1343 }
1342 1344
1343 if (r->headers_in.user_agent) { 1345 if (r->headers_in.user_agent) {
1344 1346