comparison src/http/ngx_http_request.c @ 1543:8596627c4cc5

use ngx_strstrn() and ngx_strcasestrn()
author Igor Sysoev <igor@sysoev.ru>
date Wed, 26 Sep 2007 19:26:14 +0000
parents e5352b711c47
children 099d8470e6c3
comparison
equal deleted inserted replaced
1542:f5bd1a7ed2cd 1543:8596627c4cc5
1202 1202
1203 static ngx_int_t 1203 static ngx_int_t
1204 ngx_http_process_connection(ngx_http_request_t *r, ngx_table_elt_t *h, 1204 ngx_http_process_connection(ngx_http_request_t *r, ngx_table_elt_t *h,
1205 ngx_uint_t offset) 1205 ngx_uint_t offset)
1206 { 1206 {
1207 if (ngx_strstr(h->value.data, "close")) { 1207 if (ngx_strcasestrn(h->value.data, "close", 4)) {
1208 r->headers_in.connection_type = NGX_HTTP_CONNECTION_CLOSE; 1208 r->headers_in.connection_type = NGX_HTTP_CONNECTION_CLOSE;
1209 1209
1210 } else if (ngx_strstr(h->value.data, "keep-alive")) { 1210 } else if (ngx_strcasestrn(h->value.data, "keep-alive", 9)) {
1211 r->headers_in.connection_type = NGX_HTTP_CONNECTION_KEEP_ALIVE; 1211 r->headers_in.connection_type = NGX_HTTP_CONNECTION_KEEP_ALIVE;
1212 } 1212 }
1213 1213
1214 return NGX_OK; 1214 return NGX_OK;
1215 } 1215 }
1317 ngx_http_finalize_request(r, NGX_HTTP_NOT_ALLOWED); 1317 ngx_http_finalize_request(r, NGX_HTTP_NOT_ALLOWED);
1318 return NGX_ERROR; 1318 return NGX_ERROR;
1319 } 1319 }
1320 1320
1321 if (r->headers_in.transfer_encoding 1321 if (r->headers_in.transfer_encoding
1322 && ngx_strstr(r->headers_in.transfer_encoding->value.data, "chunked")) 1322 && ngx_strcasestrn(r->headers_in.transfer_encoding->value.data,
1323 "chunked", 6))
1323 { 1324 {
1324 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, 1325 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
1325 "client sent \"Transfer-Encoding: chunked\" header"); 1326 "client sent \"Transfer-Encoding: chunked\" header");
1326 ngx_http_finalize_request(r, NGX_HTTP_LENGTH_REQUIRED); 1327 ngx_http_finalize_request(r, NGX_HTTP_LENGTH_REQUIRED);
1327 return NGX_ERROR; 1328 return NGX_ERROR;
1349 * in CPU cache 1350 * in CPU cache
1350 */ 1351 */
1351 1352
1352 user_agent = r->headers_in.user_agent->value.data; 1353 user_agent = r->headers_in.user_agent->value.data;
1353 1354
1354 ua = (u_char *) ngx_strstr(user_agent, "MSIE"); 1355 ua = ngx_strstrn(user_agent, "MSIE", 3);
1355 1356
1356 if (ua && ua + 8 < user_agent + r->headers_in.user_agent->value.len) { 1357 if (ua && ua + 8 < user_agent + r->headers_in.user_agent->value.len) {
1357 1358
1358 r->headers_in.msie = 1; 1359 r->headers_in.msie = 1;
1359 1360
1367 c->ssl->no_send_shutdown = 1; 1368 c->ssl->no_send_shutdown = 1;
1368 } 1369 }
1369 #endif 1370 #endif
1370 } 1371 }
1371 1372
1372 if (ngx_strstr(user_agent, "Opera")) { 1373 if (ngx_strstrn(user_agent, "Opera", 4)) {
1373 r->headers_in.opera = 1; 1374 r->headers_in.opera = 1;
1374 r->headers_in.msie = 0; 1375 r->headers_in.msie = 0;
1375 r->headers_in.msie4 = 0; 1376 r->headers_in.msie4 = 0;
1376 } 1377 }
1377 1378
1378 if (!r->headers_in.msie && !r->headers_in.opera) { 1379 if (!r->headers_in.msie && !r->headers_in.opera) {
1379 1380
1380 if (ngx_strstr(user_agent, "Gecko/")) { 1381 if (ngx_strstrn(user_agent, "Gecko/", 5)) {
1381 r->headers_in.gecko = 1; 1382 r->headers_in.gecko = 1;
1382 1383
1383 } else if (ngx_strstr(user_agent, "Konqueror")) { 1384 } else if (ngx_strstrn(user_agent, "Konqueror", 8)) {
1384 r->headers_in.konqueror = 1; 1385 r->headers_in.konqueror = 1;
1385 } 1386 }
1386 } 1387 }
1387 } 1388 }
1388 1389