comparison src/http/ngx_http.c @ 394: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 984bb0b1399b
children 05981f639d21
comparison
equal deleted inserted replaced
393:4ec606a899d3 394:34fb3a573548
1257 1257
1258 static ngx_int_t 1258 static ngx_int_t
1259 ngx_http_add_names(ngx_conf_t *cf, ngx_http_core_srv_conf_t *cscf, 1259 ngx_http_add_names(ngx_conf_t *cf, ngx_http_core_srv_conf_t *cscf,
1260 ngx_http_conf_in_addr_t *in_addr) 1260 ngx_http_conf_in_addr_t *in_addr)
1261 { 1261 {
1262 ngx_uint_t i, n; 1262 ngx_uint_t i;
1263 ngx_http_server_name_t *server_names, *name; 1263 ngx_http_server_name_t *server_names, *name;
1264 1264
1265 if (in_addr->names.elts == NULL) { 1265 if (in_addr->names.elts == NULL) {
1266 if (ngx_array_init(&in_addr->names, cf->temp_pool, 4, 1266 if (ngx_array_init(&in_addr->names, cf->temp_pool, 4,
1267 sizeof(ngx_http_server_name_t)) 1267 sizeof(ngx_http_server_name_t))
1273 1273
1274 server_names = cscf->server_names.elts; 1274 server_names = cscf->server_names.elts;
1275 1275
1276 for (i = 0; i < cscf->server_names.nelts; i++) { 1276 for (i = 0; i < cscf->server_names.nelts; i++) {
1277 1277
1278 for (n = 0; n < server_names[i].name.len; n++) { 1278 ngx_strlow(server_names[i].name.data, server_names[i].name.data,
1279 server_names[i].name.data[n] = 1279 server_names[i].name.len);
1280 ngx_tolower(server_names[i].name.data[n]);
1281 }
1282 1280
1283 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, cf->log, 0, 1281 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, cf->log, 0,
1284 "name: %V", &server_names[i].name); 1282 "name: %V", &server_names[i].name);
1285 1283
1286 name = ngx_array_push(&in_addr->names); 1284 name = ngx_array_push(&in_addr->names);
1687 a = 0; 1685 a = 0;
1688 } 1686 }
1689 1687
1690 return NGX_OK; 1688 return NGX_OK;
1691 } 1689 }
1690
1691
1692 char *
1693 ngx_http_types_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1694 {
1695 char *p = conf;
1696
1697 ngx_array_t **types;
1698 ngx_str_t *value, *default_type;
1699 ngx_uint_t i, n, hash;
1700 ngx_hash_key_t *type;
1701
1702 types = (ngx_array_t **) (p + cmd->offset);
1703
1704 default_type = cmd->post;
1705
1706 if (*types == NULL) {
1707 *types = ngx_array_create(cf->temp_pool, 1, sizeof(ngx_hash_key_t));
1708 if (*types == NULL) {
1709 return NGX_CONF_ERROR;
1710 }
1711
1712 if (default_type) {
1713 type = ngx_array_push(*types);
1714 if (type == NULL) {
1715 return NGX_CONF_ERROR;
1716 }
1717
1718 type->key = *default_type;
1719 type->key_hash = ngx_hash_key(default_type->data,
1720 default_type->len);
1721 type->value = (void *) 4;
1722 }
1723 }
1724
1725 value = cf->args->elts;
1726
1727 for (i = 1; i < cf->args->nelts; i++) {
1728
1729 hash = ngx_hash_strlow(value[i].data, value[i].data, value[i].len);
1730 value[i].data[value[i].len] = '\0';
1731
1732 type = (*types)->elts;
1733 for (n = 0; n < (*types)->nelts; n++) {
1734
1735 if (ngx_strcmp(value[i].data, type[n].key.data) == 0) {
1736 ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
1737 "duplicate MIME type \"%V\"", &value[i]);
1738 continue;
1739 }
1740 }
1741
1742 type = ngx_array_push(*types);
1743 if (type == NULL) {
1744 return NGX_CONF_ERROR;
1745 }
1746
1747 type->key = value[i];
1748 type->key_hash = hash;
1749 type->value = (void *) 4;
1750 }
1751
1752 return NGX_CONF_OK;
1753 }
1754
1755
1756 char *
1757 ngx_http_merge_types(ngx_conf_t *cf, ngx_array_t *keys, ngx_hash_t *types_hash,
1758 ngx_array_t *prev_keys, ngx_hash_t *prev_types_hash,
1759 ngx_str_t *default_types)
1760 {
1761 ngx_hash_init_t hash;
1762
1763 if (keys == NULL) {
1764
1765 if (prev_keys) {
1766 *types_hash = *prev_types_hash;
1767 return NGX_CONF_OK;
1768 }
1769
1770 if (ngx_http_set_default_types(cf, &keys, default_types)
1771 != NGX_CONF_OK)
1772 {
1773 return NGX_CONF_ERROR;
1774 }
1775 }
1776
1777 hash.hash = types_hash;
1778 hash.key = NULL;
1779 hash.max_size = 2048;
1780 hash.bucket_size = 64;
1781 hash.name = "test_types_hash";
1782 hash.pool = cf->pool;
1783 hash.temp_pool = NULL;
1784
1785 if (ngx_hash_init(&hash, keys->elts, keys->nelts) != NGX_OK) {
1786 return NGX_CONF_ERROR;
1787 }
1788
1789 return NGX_CONF_OK;
1790
1791 }
1792
1793
1794 char *
1795 ngx_http_set_default_types(ngx_conf_t *cf, ngx_array_t **types,
1796 ngx_str_t *default_type)
1797 {
1798 ngx_hash_key_t *type;
1799
1800 *types = ngx_array_create(cf->temp_pool, 1, sizeof(ngx_hash_key_t));
1801 if (*types == NULL) {
1802 return NGX_CONF_ERROR;
1803 }
1804
1805 while (default_type->len) {
1806
1807 type = ngx_array_push(*types);
1808 if (type == NULL) {
1809 return NGX_CONF_ERROR;
1810 }
1811
1812 type->key = *default_type;
1813 type->key_hash = ngx_hash_key(default_type->data,
1814 default_type->len);
1815 type->value = (void *) 4;
1816
1817 default_type++;
1818 }
1819
1820 return NGX_CONF_OK;
1821 }