Mercurial > hg > nginx-mail
comparison src/http/ngx_http_core_module.c @ 392:34fb3a573548 NGINX_0_7_8
nginx 0.7.8
*) Feature: the ngx_http_xslt_module.
*) Feature: the "$arg_..." variables.
*) Feature: Solaris directio support.
Thanks to Ivan Debnar.
*) Bugfix: now if FastCGI server sends a "Location" header line without
status line, then nginx uses 302 status code.
Thanks to Maxim Dounin.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 04 Aug 2008 00:00:00 +0400 |
parents | 0b6053502c55 |
children | 9d81578d04bb |
comparison
equal
deleted
inserted
replaced
391:4ec606a899d3 | 392:34fb3a573548 |
---|---|
1300 | 1300 |
1301 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 1301 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
1302 } | 1302 } |
1303 | 1303 |
1304 | 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); | |
1340 } | |
1341 | |
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) |
1307 { | 1345 { |
1308 u_char c, *p, *exten; | 1346 u_char c, *exten; |
1309 ngx_str_t *type; | 1347 ngx_str_t *type; |
1310 ngx_uint_t i, hash; | 1348 ngx_uint_t i, hash; |
1311 ngx_http_core_loc_conf_t *clcf; | 1349 ngx_http_core_loc_conf_t *clcf; |
1312 | 1350 |
1313 if (r->headers_out.content_type.len) { | 1351 if (r->headers_out.content_type.len) { |
1323 for (i = 0; i < r->exten.len; i++) { | 1361 for (i = 0; i < r->exten.len; i++) { |
1324 c = r->exten.data[i]; | 1362 c = r->exten.data[i]; |
1325 | 1363 |
1326 if (c >= 'A' && c <= 'Z') { | 1364 if (c >= 'A' && c <= 'Z') { |
1327 | 1365 |
1328 p = ngx_pnalloc(r->pool, r->exten.len); | 1366 exten = ngx_pnalloc(r->pool, r->exten.len); |
1329 if (p == NULL) { | 1367 if (exten == NULL) { |
1330 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 1368 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
1331 } | 1369 } |
1332 | 1370 |
1333 hash = 0; | 1371 hash = ngx_hash_strlow(exten, r->exten.data, r->exten.len); |
1334 exten = p; | |
1335 | |
1336 for (i = 0; i < r->exten.len; i++) { | |
1337 c = ngx_tolower(r->exten.data[i]); | |
1338 hash = ngx_hash(hash, c); | |
1339 *p++ = c; | |
1340 } | |
1341 | 1372 |
1342 r->exten.data = exten; | 1373 r->exten.data = exten; |
1343 | 1374 |
1344 break; | 1375 break; |
1345 } | 1376 } |
2314 ngx_http_core_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf) | 2345 ngx_http_core_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf) |
2315 { | 2346 { |
2316 ngx_http_core_loc_conf_t *lcf = conf; | 2347 ngx_http_core_loc_conf_t *lcf = conf; |
2317 | 2348 |
2318 ngx_str_t *value, *content_type, *old, file; | 2349 ngx_str_t *value, *content_type, *old, file; |
2319 ngx_uint_t i, n; | 2350 ngx_uint_t i, n, hash; |
2320 ngx_hash_key_t *type; | 2351 ngx_hash_key_t *type; |
2321 | 2352 |
2322 value = cf->args->elts; | 2353 value = cf->args->elts; |
2323 | 2354 |
2324 if (ngx_strcmp(value[0].data, "include") == 0) { | 2355 if (ngx_strcmp(value[0].data, "include") == 0) { |
2340 | 2371 |
2341 *content_type = value[0]; | 2372 *content_type = value[0]; |
2342 | 2373 |
2343 for (i = 1; i < cf->args->nelts; i++) { | 2374 for (i = 1; i < cf->args->nelts; i++) { |
2344 | 2375 |
2345 for (n = 0; n < value[i].len; n++) { | 2376 hash = ngx_hash_strlow(value[i].data, value[i].data, value[i].len); |
2346 value[i].data[n] = ngx_tolower(value[i].data[n]); | |
2347 } | |
2348 | 2377 |
2349 type = lcf->types->elts; | 2378 type = lcf->types->elts; |
2350 for (n = 0; n < lcf->types->nelts; n++) { | 2379 for (n = 0; n < lcf->types->nelts; n++) { |
2351 if (ngx_strcmp(value[i].data, type[n].key.data) == 0) { | 2380 if (ngx_strcmp(value[i].data, type[n].key.data) == 0) { |
2352 old = type[n].value; | 2381 old = type[n].value; |
2366 if (type == NULL) { | 2395 if (type == NULL) { |
2367 return NGX_CONF_ERROR; | 2396 return NGX_CONF_ERROR; |
2368 } | 2397 } |
2369 | 2398 |
2370 type->key = value[i]; | 2399 type->key = value[i]; |
2371 type->key_hash = ngx_hash_key(value[i].data, value[i].len); | 2400 type->key_hash = hash; |
2372 type->value = content_type; | 2401 type->value = content_type; |
2373 } | 2402 } |
2374 | 2403 |
2375 return NGX_CONF_OK; | 2404 return NGX_CONF_OK; |
2376 } | 2405 } |