comparison src/http/ngx_http_core_module.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 9d81578d04bb
children a094317ba307
comparison
equal deleted inserted replaced
399:59e324e4d6d3 400:6ebbca3d5ed7
1623 1623
1624 if (s == NULL) { 1624 if (s == NULL) {
1625 return NGX_OK; 1625 return NGX_OK;
1626 } 1626 }
1627 1627
1628 s->len = ngx_inet_ntop(c->listening->family, &r->in_addr, 1628 s->len = ngx_sock_ntop((struct sockaddr *) &sin, s->data,
1629 s->data, INET_ADDRSTRLEN); 1629 NGX_INET_ADDRSTRLEN);
1630 1630
1631 return NGX_OK; 1631 return NGX_OK;
1632 } 1632 }
1633 1633
1634 1634
1669 { 1669 {
1670 return NGX_DECLINED; 1670 return NGX_DECLINED;
1671 } 1671 }
1672 1672
1673 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); 1673 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
1674
1675 if (r->headers_in.msie6 && clcf->gzip_disable_msie6) {
1676 return NGX_DECLINED;
1677 }
1674 1678
1675 if (r->http_version < clcf->gzip_http_version) { 1679 if (r->http_version < clcf->gzip_http_version) {
1676 return NGX_DECLINED; 1680 return NGX_DECLINED;
1677 } 1681 }
1678 1682
2675 #if (NGX_HTTP_GZIP) 2679 #if (NGX_HTTP_GZIP)
2676 lcf->gzip_vary = NGX_CONF_UNSET; 2680 lcf->gzip_vary = NGX_CONF_UNSET;
2677 lcf->gzip_http_version = NGX_CONF_UNSET_UINT; 2681 lcf->gzip_http_version = NGX_CONF_UNSET_UINT;
2678 #if (NGX_PCRE) 2682 #if (NGX_PCRE)
2679 lcf->gzip_disable = NGX_CONF_UNSET_PTR; 2683 lcf->gzip_disable = NGX_CONF_UNSET_PTR;
2684 lcf->gzip_disable_msie6 = 3;
2680 #endif 2685 #endif
2681 #endif 2686 #endif
2682 2687
2683 return lcf; 2688 return lcf;
2684 } 2689 }
2912 2917
2913 #if (NGX_PCRE) 2918 #if (NGX_PCRE)
2914 ngx_conf_merge_ptr_value(conf->gzip_disable, prev->gzip_disable, NULL); 2919 ngx_conf_merge_ptr_value(conf->gzip_disable, prev->gzip_disable, NULL);
2915 #endif 2920 #endif
2916 2921
2922 if (conf->gzip_disable_msie6 == 3) {
2923 conf->gzip_disable_msie6 =
2924 (prev->gzip_disable_msie6 == 3) ? 0 : prev->gzip_disable_msie6;
2925 }
2926
2917 #endif 2927 #endif
2918 2928
2919 return NGX_CONF_OK; 2929 return NGX_CONF_OK;
2920 } 2930 }
2921 2931
2960 return NGX_CONF_ERROR; 2970 return NGX_CONF_ERROR;
2961 } 2971 }
2962 2972
2963 ngx_memzero(ls, sizeof(ngx_http_listen_t)); 2973 ngx_memzero(ls, sizeof(ngx_http_listen_t));
2964 2974
2965 ls->family = AF_INET; 2975 ls->family = u.family;
2966 ls->addr = u.addr.in_addr; 2976 ls->addr = u.addr.in_addr;
2967 ls->port = u.port; 2977 ls->port = u.port;
2968 ls->file_name = cf->conf_file->file.name.data; 2978 ls->file_name = cf->conf_file->file.name.data;
2969 ls->line = cf->conf_file->line; 2979 ls->line = cf->conf_file->line;
2970 ls->conf.backlog = NGX_LISTEN_BACKLOG; 2980 ls->conf.backlog = NGX_LISTEN_BACKLOG;
2971 ls->conf.rcvbuf = -1; 2981 ls->conf.rcvbuf = -1;
2972 ls->conf.sndbuf = -1; 2982 ls->conf.sndbuf = -1;
2973 2983
2974 n = ngx_inet_ntop(AF_INET, &ls->addr, ls->conf.addr, INET_ADDRSTRLEN + 6); 2984 n = ngx_inet_ntop(AF_INET, &ls->addr, ls->conf.addr, NGX_INET_ADDRSTRLEN);
2975 ngx_sprintf(&ls->conf.addr[n], ":%ui", ls->port); 2985 ngx_sprintf(&ls->conf.addr[n], ":%ui", ls->port);
2976 2986
2977 if (cf->args->nelts == 2) { 2987 if (cf->args->nelts == 2) {
2978 return NGX_CONF_OK; 2988 return NGX_CONF_OK;
2979 } 2989 }
3092 3102
3093 value = cf->args->elts; 3103 value = cf->args->elts;
3094 3104
3095 ch = value[1].data[0]; 3105 ch = value[1].data[0];
3096 3106
3097 if (cscf->server_name.data == NULL && value[1].len) { 3107 if (cscf->server_name.data == NULL) {
3098 name = value[1]; 3108 if (value[1].len) {
3099 3109 name = value[1];
3100 if (ch == '.') { 3110
3101 name.len--; 3111 if (ch == '.') {
3102 name.data++; 3112 name.len--;
3103 } 3113 name.data++;
3104 3114 }
3105 cscf->server_name.len = name.len; 3115
3106 cscf->server_name.data = ngx_pstrdup(cf->pool, &name); 3116 cscf->server_name.len = name.len;
3107 if (cscf->server_name.data == NULL) { 3117 cscf->server_name.data = ngx_pstrdup(cf->pool, &name);
3118 if (cscf->server_name.data == NULL) {
3119 return NGX_CONF_ERROR;
3120 }
3121
3122 } else {
3123 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3124 "the first server name must not be empty");
3108 return NGX_CONF_ERROR; 3125 return NGX_CONF_ERROR;
3109 } 3126 }
3110 } 3127 }
3111 3128
3112 for (i = 1; i < cf->args->nelts; i++) { 3129 for (i = 1; i < cf->args->nelts; i++) {
3113 3130
3114 ch = value[i].data[0]; 3131 ch = value[i].data[0];
3115 3132
3116 if (value[i].len == 0 3133 if ((ch == '*' && (value[i].len < 3 || value[i].data[1] != '.'))
3117 || (ch == '*' && (value[i].len < 3 || value[i].data[1] != '.'))
3118 || (ch == '.' && value[i].len < 2)) 3134 || (ch == '.' && value[i].len < 2))
3119 { 3135 {
3120 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 3136 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3121 "server name \"%V\" is invalid", &value[i]); 3137 "server name \"%V\" is invalid", &value[i]);
3122 return NGX_CONF_ERROR; 3138 return NGX_CONF_ERROR;
3745 #if (NGX_HTTP_GZIP) 3761 #if (NGX_HTTP_GZIP)
3746 3762
3747 static char * 3763 static char *
3748 ngx_http_gzip_disable(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 3764 ngx_http_gzip_disable(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
3749 { 3765 {
3766 ngx_http_core_loc_conf_t *clcf = conf;
3767
3750 #if (NGX_PCRE) 3768 #if (NGX_PCRE)
3751 ngx_http_core_loc_conf_t *clcf = conf;
3752 3769
3753 ngx_str_t err, *value; 3770 ngx_str_t err, *value;
3754 ngx_uint_t i; 3771 ngx_uint_t i;
3755 ngx_regex_elt_t *re; 3772 ngx_regex_elt_t *re;
3756 u_char errstr[NGX_MAX_CONF_ERRSTR]; 3773 u_char errstr[NGX_MAX_CONF_ERRSTR];
3768 err.len = NGX_MAX_CONF_ERRSTR; 3785 err.len = NGX_MAX_CONF_ERRSTR;
3769 err.data = errstr; 3786 err.data = errstr;
3770 3787
3771 for (i = 1; i < cf->args->nelts; i++) { 3788 for (i = 1; i < cf->args->nelts; i++) {
3772 3789
3790 if (ngx_strcmp(value[1].data, "msie6") == 0) {
3791 clcf->gzip_disable_msie6 = 1;
3792 continue;
3793 }
3794
3773 re = ngx_array_push(clcf->gzip_disable); 3795 re = ngx_array_push(clcf->gzip_disable);
3774 if (re == NULL) { 3796 if (re == NULL) {
3775 return NGX_CONF_ERROR; 3797 return NGX_CONF_ERROR;
3776 } 3798 }
3777 3799
3787 } 3809 }
3788 3810
3789 return NGX_CONF_OK; 3811 return NGX_CONF_OK;
3790 3812
3791 #else 3813 #else
3814 ngx_str_t *value;
3815
3816 value = cf->args->elts;
3817
3818 if (cf->args->nelts == 2 && ngx_strcmp(value[1].data, "msie6") == 0) {
3819 clcf->gzip_disable_msie6 = 1;
3820 return NGX_CONF_OK;
3821 }
3822
3792 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 3823 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3793 "\"gzip_disable\" requires PCRE library"); 3824 "without PCRE library \"gzip_disable\" supports "
3825 "builtin \"msie6\" mask only");
3794 3826
3795 return NGX_CONF_ERROR; 3827 return NGX_CONF_ERROR;
3796 #endif 3828 #endif
3797 } 3829 }
3798 3830