Mercurial > hg > nginx
comparison src/http/ngx_http_core_module.c @ 2138:fb3b084e7d42
test Content-Type via hash:
*) ngx_http_test_content_type()
*) ngx_http_types_slot()
*) ngx_http_merge_types()
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 04 Aug 2008 11:29:09 +0000 |
parents | 7a7c9e9024dd |
children | e9420c1b6f25 |
comparison
equal
deleted
inserted
replaced
2137:76d5af541412 | 2138:fb3b084e7d42 |
---|---|
1297 } | 1297 } |
1298 | 1298 |
1299 /* we assume that such small packet should be send successfully */ | 1299 /* we assume that such small packet should be send successfully */ |
1300 | 1300 |
1301 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 1301 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
1302 } | |
1303 | |
1304 | |
1305 void * | |
1306 ngx_http_test_content_type(ngx_http_request_t *r, ngx_hash_t *types_hash) | |
1307 { | |
1308 u_char c, *p; | |
1309 ngx_uint_t i, hash; | |
1310 | |
1311 if (r->headers_out.content_type.len == 0) { | |
1312 return NULL; | |
1313 } | |
1314 | |
1315 if (r->headers_out.content_type_lowcase == NULL) { | |
1316 | |
1317 p = ngx_pnalloc(r->pool, r->headers_out.content_type_len); | |
1318 | |
1319 if (p == NULL) { | |
1320 return NULL; | |
1321 } | |
1322 | |
1323 r->headers_out.content_type_lowcase = p; | |
1324 | |
1325 hash = 0; | |
1326 | |
1327 for (i = 0; i < r->headers_out.content_type_len; i++) { | |
1328 c = ngx_tolower(r->headers_out.content_type.data[i]); | |
1329 hash = ngx_hash(hash, c); | |
1330 *p++ = c; | |
1331 } | |
1332 | |
1333 r->headers_out.content_type_hash = hash; | |
1334 } | |
1335 | |
1336 return ngx_hash_find(types_hash, | |
1337 r->headers_out.content_type_hash, | |
1338 r->headers_out.content_type_lowcase, | |
1339 r->headers_out.content_type_len); | |
1302 } | 1340 } |
1303 | 1341 |
1304 | 1342 |
1305 ngx_int_t | 1343 ngx_int_t |
1306 ngx_http_set_content_type(ngx_http_request_t *r) | 1344 ngx_http_set_content_type(ngx_http_request_t *r) |