comparison src/http/ngx_http_request.c @ 400:6ebbca3d5ed7 NGINX_0_7_12

nginx 0.7.12 *) Feature: the "server_name" directive supports empty name "". *) Feature: the "gzip_disable" directive supports special "msie6" mask. *) Bugfix: if the "max_fails=0" parameter was used in upstream with several servers, then a worker process exited on a SIGFPE signal. Thanks to Maxim Dounin. *) Bugfix: a request body was dropped while redirection via an "error_page" directive. *) Bugfix: a full response was returned for request method HEAD while redirection via an "error_page" directive. *) Bugfix: the $r->header_in() method did not return value of the "Host", "User-Agent", and "Connection" request header lines; the bug had appeared in 0.7.0.
author Igor Sysoev <http://sysoev.ru>
date Tue, 26 Aug 2008 00:00:00 +0400
parents 34fb3a573548
children a094317ba307
comparison
equal deleted inserted replaced
399:59e324e4d6d3 400:6ebbca3d5ed7
72 "client sent invalid method in HTTP/0.9 request" 72 "client sent invalid method in HTTP/0.9 request"
73 }; 73 };
74 74
75 75
76 ngx_http_header_t ngx_http_headers_in[] = { 76 ngx_http_header_t ngx_http_headers_in[] = {
77 { ngx_string("Host"), 0, ngx_http_process_host }, 77 { ngx_string("Host"), offsetof(ngx_http_headers_in_t, host),
78 78 ngx_http_process_host },
79 { ngx_string("Connection"), 0, ngx_http_process_connection }, 79
80 { ngx_string("Connection"), offsetof(ngx_http_headers_in_t, connection),
81 ngx_http_process_connection },
80 82
81 { ngx_string("If-Modified-Since"), 83 { ngx_string("If-Modified-Since"),
82 offsetof(ngx_http_headers_in_t, if_modified_since), 84 offsetof(ngx_http_headers_in_t, if_modified_since),
83 ngx_http_process_unique_header_line }, 85 ngx_http_process_unique_header_line },
84 86
85 { ngx_string("User-Agent"), 0, ngx_http_process_user_agent }, 87 { ngx_string("User-Agent"), offsetof(ngx_http_headers_in_t, user_agent),
88 ngx_http_process_user_agent },
86 89
87 { ngx_string("Referer"), offsetof(ngx_http_headers_in_t, referer), 90 { ngx_string("Referer"), offsetof(ngx_http_headers_in_t, referer),
88 ngx_http_process_header_line }, 91 ngx_http_process_header_line },
89 92
90 { ngx_string("Content-Length"), 93 { ngx_string("Content-Length"),
566 #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME 569 #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
567 570
568 int 571 int
569 ngx_http_ssl_servername(ngx_ssl_conn_t *ssl_conn, int *ad, void *arg) 572 ngx_http_ssl_servername(ngx_ssl_conn_t *ssl_conn, int *ad, void *arg)
570 { 573 {
574 size_t len;
571 const char *servername; 575 const char *servername;
572 ngx_connection_t *c; 576 ngx_connection_t *c;
573 ngx_http_request_t *r; 577 ngx_http_request_t *r;
574 ngx_http_ssl_srv_conf_t *sscf; 578 ngx_http_ssl_srv_conf_t *sscf;
575 579
582 c = ngx_ssl_get_connection(ssl_conn); 586 c = ngx_ssl_get_connection(ssl_conn);
583 587
584 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, 588 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
585 "SSL server name: \"%s\"", servername); 589 "SSL server name: \"%s\"", servername);
586 590
591 len = ngx_strlen(servername);
592
593 if (len == 0) {
594 return SSL_TLSEXT_ERR_NOACK;
595 }
596
587 r = c->data; 597 r = c->data;
588 598
589 if (ngx_http_find_virtual_server(r, (u_char *) servername, 599 if (ngx_http_find_virtual_server(r, (u_char *) servername, len) != NGX_OK) {
590 ngx_strlen(servername))
591 != NGX_OK)
592 {
593 return SSL_TLSEXT_ERR_NOACK; 600 return SSL_TLSEXT_ERR_NOACK;
594 } 601 }
595 602
596 sscf = ngx_http_get_module_srv_conf(r, ngx_http_ssl_module); 603 sscf = ngx_http_get_module_srv_conf(r, ngx_http_ssl_module);
597 604
1281 1288
1282 static ngx_int_t 1289 static ngx_int_t
1283 ngx_http_process_user_agent(ngx_http_request_t *r, ngx_table_elt_t *h, 1290 ngx_http_process_user_agent(ngx_http_request_t *r, ngx_table_elt_t *h,
1284 ngx_uint_t offset) 1291 ngx_uint_t offset)
1285 { 1292 {
1286 u_char *ua, *user_agent; 1293 u_char *user_agent, *msie;
1287 1294
1288 if (r->headers_in.user_agent) { 1295 if (r->headers_in.user_agent) {
1289 return NGX_OK; 1296 return NGX_OK;
1290 } 1297 }
1291 1298
1293 1300
1294 /* check some widespread browsers while the header is in CPU cache */ 1301 /* check some widespread browsers while the header is in CPU cache */
1295 1302
1296 user_agent = h->value.data; 1303 user_agent = h->value.data;
1297 1304
1298 ua = ngx_strstrn(user_agent, "MSIE", 4 - 1); 1305 msie = ngx_strstrn(user_agent, "MSIE ", 5 - 1);
1299 1306
1300 if (ua && ua + 8 < user_agent + h->value.len) { 1307 if (msie && msie + 7 < user_agent + h->value.len) {
1301 1308
1302 r->headers_in.msie = 1; 1309 r->headers_in.msie = 1;
1303 1310
1304 if (ua[4] == ' ' && ua[5] == '4' && ua[6] == '.') { 1311 if (msie[6] == '.') {
1305 r->headers_in.msie4 = 1; 1312
1313 switch (msie[5]) {
1314 case '4':
1315 r->headers_in.msie4 = 1;
1316 /* fall through */
1317 case '5':
1318 case '6':
1319 r->headers_in.msie6 = 1;
1320 }
1306 } 1321 }
1307 1322
1308 #if 0 1323 #if 0
1309 /* MSIE ignores the SSL "close notify" alert */ 1324 /* MSIE ignores the SSL "close notify" alert */
1310 if (c->ssl) { 1325 if (c->ssl) {
1315 1330
1316 if (ngx_strstrn(user_agent, "Opera", 5 - 1)) { 1331 if (ngx_strstrn(user_agent, "Opera", 5 - 1)) {
1317 r->headers_in.opera = 1; 1332 r->headers_in.opera = 1;
1318 r->headers_in.msie = 0; 1333 r->headers_in.msie = 0;
1319 r->headers_in.msie4 = 0; 1334 r->headers_in.msie4 = 0;
1335 r->headers_in.msie6 = 0;
1320 } 1336 }
1321 1337
1322 if (!r->headers_in.msie && !r->headers_in.opera) { 1338 if (!r->headers_in.msie && !r->headers_in.opera) {
1323 1339
1324 if (ngx_strstrn(user_agent, "Gecko/", 6 - 1)) { 1340 if (ngx_strstrn(user_agent, "Gecko/", 6 - 1)) {
1554 ngx_uint_t hash; 1570 ngx_uint_t hash;
1555 ngx_http_core_loc_conf_t *clcf; 1571 ngx_http_core_loc_conf_t *clcf;
1556 ngx_http_core_srv_conf_t *cscf; 1572 ngx_http_core_srv_conf_t *cscf;
1557 u_char buf[32]; 1573 u_char buf[32];
1558 1574
1559 if (len == 0 || r->virtual_names == NULL) { 1575 if (r->virtual_names == NULL) {
1560 return NGX_DECLINED; 1576 return NGX_DECLINED;
1561 } 1577 }
1562 1578
1563 if (len <= 32) { 1579 if (len <= 32) {
1564 server = buf; 1580 server = buf;