nginx-0.1.39-RELEASE import

*) The changes in the ngx_http_charset_module: the "default_charset"
       directive was canceled; the "charset" directive sets the response
       charset; the "source_charset" directive sets the source charset only.

    *) Bugfix: the backend "WWW-Authenticate" header line did not
       transferred while the 401 response code redirecting.

    *) Bugfix: the ngx_http_proxy_module and ngx_http_fastcgi_module may
       close a connection before anything was transferred to a client; the
       bug had appeared in 0.1.38.

    *) Workaround: the Linux glibc crypt_r() initialization bug.

    *) Bugfix: the ngx_http_ssi_module did not support the relative URI in
       the "include virtual" command.

    *) Bugfix: if the backend response had the "Location" header line and
       nginx should not rewrite this line, then the 500 code response body
       was transferred; the bug had appeared in 0.1.29.

    *) Bugfix: some directives of the ngx_http_proxy_module and
       ngx_http_fastcgi_module were not inherited from the server to the
       location level; the bug had appeared in 0.1.29.

    *) Bugfix: the ngx_http_ssl_module did not support the certificate
       chain.

    *) Bugfix: the ngx_http_autoindex_module did not show correctly the
       long file names; the bug had appeared in 0.1.38.

    *) Bugfixes in IMAP/POP3 proxy in interaction with a backend at the
       login state.
This commit is contained in:
Igor Sysoev 2005-07-14 12:51:53 +00:00
parent b3ad9f30d9
commit 187b7d9558
17 changed files with 506 additions and 245 deletions

View File

@ -225,6 +225,10 @@ cat << END
--http-fastcgi-temp-path=PATH set path to the http fastcgi temporary --http-fastcgi-temp-path=PATH set path to the http fastcgi temporary
files path files path
--without-http disable HTTP server
--with-imap enable IMAP4/POP3 proxy module
--with-cc=PATH set path to C compiler --with-cc=PATH set path to C compiler
--with-cpp=PATH set path to C preprocessor --with-cpp=PATH set path to C preprocessor
--with-cc-opt=OPTIONS set additional options for C compiler --with-cc-opt=OPTIONS set additional options for C compiler

View File

@ -25,8 +25,7 @@ http {
server { server {
listen 80; listen 80;
charset on; charset koi8-r;
source_charset koi8-r;
#access_log logs/access.log; #access_log logs/access.log;

View File

@ -9,6 +9,125 @@
<title lang="en">nginx changelog</title> <title lang="en">nginx changelog</title>
<changes ver="0.1.39" date="14.07.2005">
<change>
<para lang="ru">
éÚÍÅÎÅÎÉÑ × ÍÏÄÕÌÅ ngx_http_charset_module:
ÄÉÒÅËÔÉ×Á default_charset ÕÐÒÁÚÄÎÅÎÁ;
ÄÉÒÅËÔÉ×Á charset ÚÁÄÁ£Ô ËÏÄÉÒÏ×ËÕ ÏÔ×ÅÔÁ;
ÄÉÒÅËÔÉ×Á source_charset ÚÁÄÁ£Ô ÔÏÌØËÏ ÉÓÈÏÄÎÕÀ ËÏÄÉÒÏ×ËÕ.
</para>
<para lang="en">
The changes in the ngx_http_charset_module:
the "default_charset" directive is canceled;
the "charset" directive sets the response charset;
the "source_charset" directive sets the source charset only.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ÐÒÉ ÐÅÒÅÎÁÐÒÁ×ÌÅÎÉÉ ÏÛÉÂËÉ 401, ÐÏÌÕÞÅÎÎÏÊ ÏÔ ÂÜËÅÎÄÁ, ÎÅ ÐÅÒÅÄÁ×ÁÌÁÓØ
ÓÔÒÏËÁ ÚÁÇÏÌÏ×ËÁ "WWW-Authenticate".
</para>
<para lang="en">
the backend "WWW-Authenticate" header line did not transferred while
the 401 response code redirecting.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ÍÏÄÕÌÉ ngx_http_proxy_module É ngx_http_fastcgi_module ÍÏÇÌÉ ÚÁËÒÙÔØ
ÓÏÅÄÉÎÅÎÉÅ ÄÏ ÔÏÇÏ, ËÁË ÞÔÏ-ÎÉÂÕÄØ ÂÙÌÏ ÐÅÒÅÄÁÎÏ ËÌÉÅÎÔÕ;
ÏÛÉÂËÁ ÐÏÑ×ÉÌÁÓØ × 0.1.38.
</para>
<para lang="en">
the ngx_http_proxy_module and ngx_http_fastcgi_module may close
a connection before anything was transferred to a client;
bug appeared in 0.1.38.
</para>
</change>
<change type="workaround">
<para lang="ru">
ÏÂÒÁÂÏÔËÁ ÏÛÉÂËÉ ÉÎÉÃÉÁÌÉÚÁÃÉÉ × crypt_r() × Linux glibc.
</para>
<para lang="en">
the Linux glibc crypt_r() initialization bug.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ÍÏÄÕÌØ ngx_http_ssi_module ÎÅ ÐÏÄÄÅÒÖÉ×ÁÌ ÏÔÎÏÓÉÔÅÌØÎÙÅ URI ×
ËÏÍÁÎÄÅ include virtual.
</para>
<para lang="en">
the ngx_http_ssi_module did not support the relative URI in
the "include virtual" command.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ÅÓÌÉ × ÓÔÒÏËÅ ÚÁÇÏÌÏ×ËÁ ÏÔ×ÅÔÁ ÂÜËÅÎÄÁ ÂÙÌÁ ÓÔÒÏËÁ "Location",
ËÏÔÏÒÕÀ nginx ÎÅ ÄÏÌÖÅÎ ÂÙÌ ÉÚÍÅÎÑÔØ, ÔÏ × ÏÔ×ÅÔÅ ÐÅÒÅÄÁ×ÁÌÏÓØ ÔÅÌÏ 500 ÏÛÉÂËÉ;
ÏÛÉÂËÁ ÐÏÑ×ÉÌÁÓØ × 0.1.29.
</para>
<para lang="en">
if the backend response had the "Location" header line and nginx
should not rewrite this line, then the 500 code response body was transferred;
bug appeared in 0.1.29.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ÎÅËÏÔÏÒÙÅ ÄÉÒÅËÔÉ×Ù ÍÏÄÕÌÅÊ ngx_http_proxy_module É ngx_http_fastcgi_module
ÎÅ ÎÁÓÌÅÄÏ×ÁÌÉÓØ Ó ÕÒÏ×ÎÑ server ÎÁ ÕÒÏ×ÅÎØ location;
ÏÛÉÂËÁ ÐÏÑ×ÉÌÁÓØ × 0.1.29.
</para>
<para lang="en">
some directives of the ngx_http_proxy_module and ngx_http_fastcgi_module
were not inherited from the server to the location level;
bug appeared in 0.1.29.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ÍÏÄÕÌØ ngx_http_ssl_module ÎÅ ÐÏÄÄÅÒÖÉ×ÁÌ ÃÅÐÏÞËÉ ÓÅÒÔÉÆÉËÁÔÏ×.
</para>
<para lang="en">
the ngx_http_ssl_module did not support the certificate chain.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ÏÛÉÂËÁ × ÍÏÄÕÌÅ ngx_http_autoindex_module ÐÒÉ ÐÏËÁÚÅ ÄÌÉÎÎÙÈ ÉͣΠÆÁÊÌÏ×;
ÏÛÉÂËÁ ÐÏÑ×ÉÌÁÓØ × 0.1.38.
</para>
<para lang="en">
the ngx_http_autoindex_module did not show correctly the long file names;
bug appeared in 0.1.38.
</para>
</change>
<change>
<para lang="ru">
éÓÐÒÁ×ÌÅÎÉÑ × IMAP/POP3 ÐÒÏËÓÉ ÐÒÉ ×ÚÁÉÍÏÄÅÊÓÔ×ÉÉ Ó ÂÜËÅÎÄÏÍ ÎÁ ÓÔÁÄÉÉ login.
</para>
<para lang="en">
Bugfixes in IMAP/POP3 proxy in interaction with a backend at the login state.
</para>
</change>
</changes>
<changes ver="0.1.38" date="08.07.2005"> <changes ver="0.1.38" date="08.07.2005">
<change type="feature"> <change type="feature">

View File

@ -8,7 +8,7 @@
#define _NGINX_H_INCLUDED_ #define _NGINX_H_INCLUDED_
#define NGINX_VER "nginx/0.1.38" #define NGINX_VER "nginx/0.1.39"
#define NGINX_VAR "NGINX" #define NGINX_VAR "NGINX"
#define NGX_NEWPID_EXT ".newbin" #define NGX_NEWPID_EXT ".newbin"

View File

@ -315,16 +315,16 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
entry->name.len = len; entry->name.len = len;
entry->escape = 2 * ngx_escape_uri(NULL, ngx_de_name(&dir), len, entry->name.data = ngx_palloc(pool, len + 1);
NGX_ESCAPE_HTML);
entry->name.data = ngx_palloc(pool, len + entry->escape + 1);
if (entry->name.data == NULL) { if (entry->name.data == NULL) {
return ngx_http_autoindex_error(r, &dir, dname.data); return ngx_http_autoindex_error(r, &dir, dname.data);
} }
ngx_cpystrn(entry->name.data, ngx_de_name(&dir), len + 1); ngx_cpystrn(entry->name.data, ngx_de_name(&dir), len + 1);
entry->escape = 2 * ngx_escape_uri(NULL, ngx_de_name(&dir), len,
NGX_ESCAPE_HTML);
if (r->utf8) { if (r->utf8) {
entry->utf_len = ngx_utf_length(&entry->name); entry->utf_len = ngx_utf_length(&entry->name);
} else { } else {
@ -353,14 +353,14 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
entry = entries.elts; entry = entries.elts;
for (i = 0; i < entries.nelts; i++) { for (i = 0; i < entries.nelts; i++) {
len += sizeof("<a href=\"") - 1 len += sizeof("<a href=\"") - 1
+ 1 /* 1 is for "/" */
+ entry[i].name.len + entry[i].escape + entry[i].name.len + entry[i].escape
+ 1 /* 1 is for "/" */
+ sizeof("\">") - 1 + sizeof("\">") - 1
+ entry[i].name.len - entry[i].utf_len + entry[i].name.len - entry[i].utf_len
+ NGX_HTTP_AUTOINDEX_NAME_LEN + sizeof("&gt;") - 2 + NGX_HTTP_AUTOINDEX_NAME_LEN + sizeof("&gt;") - 2
+ sizeof("</a>") - 1 + sizeof("</a>") - 1
+ sizeof(" 28-Sep-1970 12:00 ") - 1 + sizeof(" 28-Sep-1970 12:00 ") - 1
+ 20 + 20 /* the file size */
+ 2; + 2;
} }
@ -407,7 +407,7 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
len = entry[i].utf_len; len = entry[i].utf_len;
if (len) { if (entry[i].name.len - len) {
if (len > NGX_HTTP_AUTOINDEX_NAME_LEN) { if (len > NGX_HTTP_AUTOINDEX_NAME_LEN) {
copy = NGX_HTTP_AUTOINDEX_NAME_LEN - 3 + 1; copy = NGX_HTTP_AUTOINDEX_NAME_LEN - 3 + 1;

View File

@ -9,15 +9,23 @@
#include <ngx_http.h> #include <ngx_http.h>
#define NGX_HTTP_NO_CHARSET -2
typedef struct { typedef struct {
char **tables; char **tables;
ngx_str_t name; ngx_str_t name;
unsigned server:1; ngx_uint_t utf8; /* unsigned utf8:1; */
unsigned utf8:1;
} ngx_http_charset_t; } ngx_http_charset_t;
typedef struct {
ngx_int_t src;
ngx_int_t dst;
} ngx_http_charset_recode_t;
typedef struct { typedef struct {
ngx_int_t src; ngx_int_t src;
ngx_int_t dst; ngx_int_t dst;
@ -29,13 +37,12 @@ typedef struct {
typedef struct { typedef struct {
ngx_array_t charsets; /* ngx_http_charset_t */ ngx_array_t charsets; /* ngx_http_charset_t */
ngx_array_t tables; /* ngx_http_charset_tables_t */ ngx_array_t tables; /* ngx_http_charset_tables_t */
ngx_array_t recodes; /* ngx_http_charset_recode_t */
} ngx_http_charset_main_conf_t; } ngx_http_charset_main_conf_t;
typedef struct { typedef struct {
ngx_flag_t enable; ngx_int_t charset;
ngx_int_t default_charset;
ngx_int_t source_charset; ngx_int_t source_charset;
} ngx_http_charset_loc_conf_t; } ngx_http_charset_loc_conf_t;
@ -46,7 +53,7 @@ typedef struct {
} ngx_http_charset_ctx_t; } ngx_http_charset_ctx_t;
static ngx_uint_t ngx_charset_recode(ngx_buf_t *b, char *table); static ngx_uint_t ngx_http_charset_recode(ngx_buf_t *b, char *table);
static char *ngx_charset_map_block(ngx_conf_t *cf, ngx_command_t *cmd, static char *ngx_charset_map_block(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf); void *conf);
@ -59,14 +66,30 @@ static ngx_int_t ngx_http_add_charset(ngx_array_t *charsets, ngx_str_t *name);
static ngx_int_t ngx_http_charset_filter_init(ngx_cycle_t *cycle); static ngx_int_t ngx_http_charset_filter_init(ngx_cycle_t *cycle);
static void *ngx_http_charset_create_main_conf(ngx_conf_t *cf); static void *ngx_http_charset_create_main_conf(ngx_conf_t *cf);
static char *ngx_http_charset_init_main_conf(ngx_conf_t *cf, void *conf);
static void *ngx_http_charset_create_loc_conf(ngx_conf_t *cf); static void *ngx_http_charset_create_loc_conf(ngx_conf_t *cf);
static char *ngx_http_charset_merge_loc_conf(ngx_conf_t *cf, static char *ngx_http_charset_merge_loc_conf(ngx_conf_t *cf,
void *parent, void *child); void *parent, void *child);
static ngx_int_t ngx_http_charset_postconfiguration(ngx_conf_t *cf);
static ngx_command_t ngx_http_charset_filter_commands[] = { static ngx_command_t ngx_http_charset_filter_commands[] = {
{ ngx_string("charset"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_SIF_CONF
|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1,
ngx_http_set_charset_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_charset_loc_conf_t, charset),
NULL },
{ ngx_string("source_charset"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_SIF_CONF
|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1,
ngx_http_set_charset_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_charset_loc_conf_t, source_charset),
NULL },
{ ngx_string("charset_map"), { ngx_string("charset_map"),
NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_TAKE2, NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_TAKE2,
ngx_charset_map_block, ngx_charset_map_block,
@ -74,37 +97,16 @@ static ngx_command_t ngx_http_charset_filter_commands[] = {
0, 0,
NULL }, NULL },
{ ngx_string("default_charset"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_http_set_charset_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_charset_loc_conf_t, default_charset),
NULL },
{ ngx_string("source_charset"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_http_set_charset_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_charset_loc_conf_t, source_charset),
NULL },
{ ngx_string("charset"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
ngx_conf_set_flag_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_charset_loc_conf_t, enable),
NULL },
ngx_null_command ngx_null_command
}; };
static ngx_http_module_t ngx_http_charset_filter_module_ctx = { static ngx_http_module_t ngx_http_charset_filter_module_ctx = {
NULL, /* preconfiguration */ NULL, /* preconfiguration */
NULL, /* postconfiguration */ ngx_http_charset_postconfiguration, /* postconfiguration */
ngx_http_charset_create_main_conf, /* create main configuration */ ngx_http_charset_create_main_conf, /* create main configuration */
ngx_http_charset_init_main_conf, /* init main configuration */ NULL, /* init main configuration */
NULL, /* create server configuration */ NULL, /* create server configuration */
NULL, /* merge server configuration */ NULL, /* merge server configuration */
@ -139,7 +141,7 @@ ngx_http_charset_header_filter(ngx_http_request_t *r)
mcf = ngx_http_get_module_main_conf(r, ngx_http_charset_filter_module); mcf = ngx_http_get_module_main_conf(r, ngx_http_charset_filter_module);
lcf = ngx_http_get_module_loc_conf(r, ngx_http_charset_filter_module); lcf = ngx_http_get_module_loc_conf(r, ngx_http_charset_filter_module);
if (lcf->enable == 0) { if (lcf->charset == NGX_HTTP_NO_CHARSET) {
return ngx_http_next_header_filter(r); return ngx_http_next_header_filter(r);
} }
@ -176,10 +178,12 @@ ngx_http_charset_header_filter(ngx_http_request_t *r)
} }
charsets = mcf->charsets.elts; charsets = mcf->charsets.elts;
r->headers_out.charset = charsets[lcf->default_charset].name; r->headers_out.charset = charsets[lcf->charset].name;
r->utf8 = charsets[lcf->default_charset].utf8; r->utf8 = charsets[lcf->charset].utf8;
if (lcf->default_charset == lcf->source_charset) { if (lcf->source_charset == NGX_CONF_UNSET
|| lcf->source_charset == lcf->charset)
{
return ngx_http_next_header_filter(r); return ngx_http_next_header_filter(r);
} }
@ -218,10 +222,10 @@ ngx_http_charset_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
lcf = ngx_http_get_module_loc_conf(r, ngx_http_charset_filter_module); lcf = ngx_http_get_module_loc_conf(r, ngx_http_charset_filter_module);
charsets = mcf->charsets.elts; charsets = mcf->charsets.elts;
table = charsets[lcf->source_charset].tables[lcf->default_charset]; table = charsets[lcf->source_charset].tables[lcf->charset];
for (cl = in; cl; cl = cl->next) { for (cl = in; cl; cl = cl->next) {
ngx_charset_recode(cl->buf, table); ngx_http_charset_recode(cl->buf, table);
} }
return ngx_http_next_body_filter(r, in); return ngx_http_next_body_filter(r, in);
@ -229,7 +233,7 @@ ngx_http_charset_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
static ngx_uint_t static ngx_uint_t
ngx_charset_recode(ngx_buf_t *b, char *table) ngx_http_charset_recode(ngx_buf_t *b, char *table)
{ {
u_char *p; u_char *p;
ngx_uint_t change; ngx_uint_t change;
@ -385,7 +389,6 @@ ngx_http_set_charset_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_int_t *cp; ngx_int_t *cp;
ngx_str_t *value; ngx_str_t *value;
ngx_http_charset_t *charset;
ngx_http_charset_main_conf_t *mcf; ngx_http_charset_main_conf_t *mcf;
cp = (ngx_int_t *) (p + cmd->offset); cp = (ngx_int_t *) (p + cmd->offset);
@ -394,21 +397,23 @@ ngx_http_set_charset_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return "is duplicate"; return "is duplicate";
} }
value = cf->args->elts;
if (cmd->offset == offsetof(ngx_http_charset_loc_conf_t, charset)
&& ngx_strcmp(value[1].data, "off") == 0)
{
*cp = NGX_HTTP_NO_CHARSET;
return NGX_CONF_OK;
}
mcf = ngx_http_conf_get_module_main_conf(cf, mcf = ngx_http_conf_get_module_main_conf(cf,
ngx_http_charset_filter_module); ngx_http_charset_filter_module);
value = cf->args->elts;
*cp = ngx_http_add_charset(&mcf->charsets, &value[1]); *cp = ngx_http_add_charset(&mcf->charsets, &value[1]);
if (*cp == NGX_ERROR) { if (*cp == NGX_ERROR) {
return NGX_CONF_ERROR; return NGX_CONF_ERROR;
} }
if (cmd->offset == offsetof(ngx_http_charset_loc_conf_t, source_charset)) {
charset = mcf->charsets.elts;
charset[*cp].server = 1;
}
return NGX_CONF_OK; return NGX_CONF_OK;
} }
@ -441,7 +446,6 @@ ngx_http_add_charset(ngx_array_t *charsets, ngx_str_t *name)
c->tables = NULL; c->tables = NULL;
c->name = *name; c->name = *name;
c->server = 0;
if (ngx_strcasecmp(name->data, "utf-8") == 0) { if (ngx_strcasecmp(name->data, "utf-8") == 0) {
c->utf8 = 1; c->utf8 = 1;
@ -475,82 +479,27 @@ ngx_http_charset_create_main_conf(ngx_conf_t *cf)
} }
if (ngx_array_init(&mcf->charsets, cf->pool, 2, sizeof(ngx_http_charset_t)) if (ngx_array_init(&mcf->charsets, cf->pool, 2, sizeof(ngx_http_charset_t))
== NGX_ERROR) == NGX_ERROR)
{ {
return NGX_CONF_ERROR; return NGX_CONF_ERROR;
} }
if (ngx_array_init(&mcf->tables, cf->pool, 4, if (ngx_array_init(&mcf->tables, cf->pool, 1,
sizeof(ngx_http_charset_tables_t)) == NGX_ERROR) sizeof(ngx_http_charset_tables_t)) == NGX_ERROR)
{ {
return NGX_CONF_ERROR; return NGX_CONF_ERROR;
} }
if (ngx_array_init(&mcf->recodes, cf->pool, 2,
sizeof(ngx_http_charset_recode_t)) == NGX_ERROR)
{
return NGX_CONF_ERROR;
}
return mcf; return mcf;
} }
static char *
ngx_http_charset_init_main_conf(ngx_conf_t *cf, void *conf)
{
ngx_http_charset_main_conf_t *mcf = conf;
ngx_uint_t i, n;
ngx_http_charset_t *charset;
ngx_http_charset_tables_t *tables;
tables = mcf->tables.elts;
charset = mcf->charsets.elts;
for (i = 0; i < mcf->charsets.nelts; i++) {
if (!charset[i].server) {
continue;
}
charset[i].tables = ngx_pcalloc(cf->pool,
sizeof(char *) * mcf->charsets.nelts);
if (charset[i].tables == NULL) {
return NGX_CONF_ERROR;
}
for (n = 0; n < mcf->tables.nelts; n++) {
if ((ngx_int_t) i == tables[n].src) {
charset[i].tables[tables[n].dst] = tables[n].src2dst;
continue;
}
if ((ngx_int_t) i == tables[n].dst) {
charset[i].tables[tables[n].src] = tables[n].dst2src;
}
}
}
for (i = 0; i < mcf->charsets.nelts; i++) {
if (!charset[i].server) {
continue;
}
for (n = 0; n < mcf->charsets.nelts; n++) {
if (i == n) {
continue;
}
if (charset[i].tables[n]) {
continue;
}
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
" no \"charset_map\" between the charsets "
"\"%V\" and \"%V\"",
&charset[i].name, &charset[n].name);
return NGX_CONF_ERROR;
}
}
return NGX_CONF_OK;
}
static void * static void *
ngx_http_charset_create_loc_conf(ngx_conf_t *cf) ngx_http_charset_create_loc_conf(ngx_conf_t *cf)
{ {
@ -561,8 +510,7 @@ ngx_http_charset_create_loc_conf(ngx_conf_t *cf)
return NGX_CONF_ERROR; return NGX_CONF_ERROR;
} }
lcf->enable = NGX_CONF_UNSET; lcf->charset = NGX_CONF_UNSET;
lcf->default_charset = NGX_CONF_UNSET;
lcf->source_charset = NGX_CONF_UNSET; lcf->source_charset = NGX_CONF_UNSET;
return lcf; return lcf;
@ -575,37 +523,95 @@ ngx_http_charset_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_http_charset_loc_conf_t *prev = parent; ngx_http_charset_loc_conf_t *prev = parent;
ngx_http_charset_loc_conf_t *conf = child; ngx_http_charset_loc_conf_t *conf = child;
ngx_conf_merge_value(conf->enable, prev->enable, 0); ngx_uint_t i;
ngx_http_charset_recode_t *recode;
ngx_http_charset_main_conf_t *mcf;
if (conf->default_charset == NGX_CONF_UNSET) { ngx_conf_merge_value(conf->charset, prev->charset, NGX_HTTP_NO_CHARSET);
conf->default_charset = prev->default_charset;
}
if (conf->source_charset == NGX_CONF_UNSET) { if (conf->source_charset == NGX_CONF_UNSET) {
conf->source_charset = prev->source_charset; conf->source_charset = prev->source_charset;
} }
if (conf->default_charset == NGX_CONF_UNSET if (conf->charset == NGX_HTTP_NO_CHARSET
&& conf->source_charset != NGX_CONF_UNSET) || conf->source_charset == NGX_CONF_UNSET
|| conf->charset == conf->source_charset)
{ {
conf->default_charset = conf->source_charset; return NGX_CONF_OK;
} }
if (conf->source_charset == NGX_CONF_UNSET mcf = ngx_http_conf_get_module_main_conf(cf,
&& conf->default_charset != NGX_CONF_UNSET) ngx_http_charset_filter_module);
{ recode = mcf->recodes.elts;
conf->source_charset = conf->default_charset; for (i = 0; i < mcf->recodes.nelts; i++) {
if (conf->source_charset == recode[i].src
&& conf->charset == recode[i].dst)
{
return NGX_CONF_OK;
}
} }
if (conf->enable recode = ngx_array_push(&mcf->recodes);
&& (conf->default_charset == NGX_CONF_UNSET if (recode == NULL) {
|| conf->source_charset == NGX_CONF_UNSET))
{
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"the \"source_charset\" or \"default_charset\" "
"must be specified when \"charset\" is on");
return NGX_CONF_ERROR; return NGX_CONF_ERROR;
} }
recode->src = conf->source_charset;
recode->dst = conf->charset;
return NGX_CONF_OK; return NGX_CONF_OK;
} }
static ngx_int_t
ngx_http_charset_postconfiguration(ngx_conf_t *cf)
{
ngx_int_t c;
ngx_uint_t i, t;
ngx_http_charset_t *charset;
ngx_http_charset_recode_t *recode;
ngx_http_charset_tables_t *tables;
ngx_http_charset_main_conf_t *mcf;
mcf = ngx_http_conf_get_module_main_conf(cf,
ngx_http_charset_filter_module);
recode = mcf->recodes.elts;
tables = mcf->tables.elts;
charset = mcf->charsets.elts;
for (i = 0; i < mcf->recodes.nelts; i++) {
c = recode[i].src;
charset[c].tables = ngx_pcalloc(cf->pool,
sizeof(char *) * mcf->charsets.nelts);
if (charset[c].tables == NULL) {
return NGX_ERROR;
}
for (t = 0; t < mcf->tables.nelts; t++) {
if (c == tables[t].src && recode[i].dst == tables[t].dst) {
charset[c].tables[tables[t].dst] = tables[t].src2dst;
goto next;
}
if (c == tables[t].dst && recode[i].dst == tables[t].src) {
charset[c].tables[tables[t].src] = tables[t].dst2src;
goto next;
}
}
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
" no \"charset_map\" between the charsets "
"\"%V\" and \"%V\"",
&charset[c].name, &charset[recode[i].dst].name);
return NGX_ERROR;
next:
continue;
}
return NGX_OK;
}

View File

@ -277,7 +277,7 @@ static ngx_command_t ngx_http_fastcgi_commands[] = {
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_size_slot, ngx_conf_set_size_slot,
NGX_HTTP_LOC_CONF_OFFSET, NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_fastcgi_loc_conf_t, upstream.busy_buffers_size), offsetof(ngx_http_fastcgi_loc_conf_t, upstream.busy_buffers_size_conf),
NULL }, NULL },
{ ngx_string("fastcgi_temp_path"), { ngx_string("fastcgi_temp_path"),
@ -291,14 +291,14 @@ static ngx_command_t ngx_http_fastcgi_commands[] = {
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_size_slot, ngx_conf_set_size_slot,
NGX_HTTP_LOC_CONF_OFFSET, NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_fastcgi_loc_conf_t, upstream.max_temp_file_size), offsetof(ngx_http_fastcgi_loc_conf_t, upstream.max_temp_file_size_conf),
NULL }, NULL },
{ ngx_string("fastcgi_temp_file_write_size"), { ngx_string("fastcgi_temp_file_write_size"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_size_slot, ngx_conf_set_size_slot,
NGX_HTTP_LOC_CONF_OFFSET, NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_fastcgi_loc_conf_t, upstream.temp_file_write_size), offsetof(ngx_http_fastcgi_loc_conf_t, upstream.temp_file_write_size_conf),
NULL }, NULL },
{ ngx_string("fastcgi_next_upstream"), { ngx_string("fastcgi_next_upstream"),
@ -1001,16 +1001,16 @@ ngx_http_fastcgi_process_header(ngx_http_request_t *r)
return NGX_HTTP_INTERNAL_SERVER_ERROR; return NGX_HTTP_INTERNAL_SERVER_ERROR;
} }
r->headers_out.status = status; u->headers_in.status_n = status;
r->headers_out.status_line = *status_line; u->headers_in.status_line = *status_line;
} else { } else {
r->headers_out.status = 200; u->headers_in.status_n = 200;
r->headers_out.status_line.len = sizeof("200 OK") - 1; u->headers_in.status_line.len = sizeof("200 OK") - 1;
r->headers_out.status_line.data = (u_char *) "200 OK"; u->headers_in.status_line.data = (u_char *) "200 OK";
} }
u->state->status = r->headers_out.status; u->state->status = u->headers_in.status_n;
#if 0 #if 0
if (u->cachable) { if (u->cachable) {
u->cachable = ngx_http_upstream_is_cachable(r); u->cachable = ngx_http_upstream_is_cachable(r);
@ -1452,9 +1452,10 @@ ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf)
conf->upstream.send_lowat = NGX_CONF_UNSET_SIZE; conf->upstream.send_lowat = NGX_CONF_UNSET_SIZE;
conf->upstream.header_buffer_size = NGX_CONF_UNSET_SIZE; conf->upstream.header_buffer_size = NGX_CONF_UNSET_SIZE;
conf->upstream.busy_buffers_size = NGX_CONF_UNSET_SIZE;
conf->upstream.max_temp_file_size = NGX_CONF_UNSET_SIZE; conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE;
conf->upstream.temp_file_write_size = NGX_CONF_UNSET_SIZE; conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE;
conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE;
conf->upstream.pass_unparsed_uri = NGX_CONF_UNSET; conf->upstream.pass_unparsed_uri = NGX_CONF_UNSET;
conf->upstream.method = NGX_CONF_UNSET_UINT; conf->upstream.method = NGX_CONF_UNSET_UINT;
@ -1523,23 +1524,28 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
} }
ngx_conf_merge_size_value(conf->upstream.busy_buffers_size, ngx_conf_merge_size_value(conf->upstream.busy_buffers_size_conf,
prev->upstream.busy_buffers_size, prev->upstream.busy_buffers_size_conf,
NGX_CONF_UNSET_SIZE); NGX_CONF_UNSET_SIZE);
if (conf->upstream.busy_buffers_size == NGX_CONF_UNSET_SIZE) { if (conf->upstream.busy_buffers_size_conf == NGX_CONF_UNSET_SIZE) {
conf->upstream.busy_buffers_size = 2 * size; conf->upstream.busy_buffers_size = 2 * size;
} else {
conf->upstream.busy_buffers_size =
conf->upstream.busy_buffers_size_conf;
}
} else if (conf->upstream.busy_buffers_size < size) { if (conf->upstream.busy_buffers_size < size) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"\"fastcgi_busy_buffers_size\" must be equal or bigger than " "\"fastcgi_busy_buffers_size\" must be equal or bigger than "
"maximum of the value of \"fastcgi_header_buffer_size\" and " "maximum of the value of \"fastcgi_header_buffer_size\" and "
"one of the \"fastcgi_buffers\""); "one of the \"fastcgi_buffers\"");
return NGX_CONF_ERROR; return NGX_CONF_ERROR;
}
} else if (conf->upstream.busy_buffers_size if (conf->upstream.busy_buffers_size
> (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size) > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size)
{ {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"\"fastcgi_busy_buffers_size\" must be less than " "\"fastcgi_busy_buffers_size\" must be less than "
@ -1549,14 +1555,18 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
} }
ngx_conf_merge_size_value(conf->upstream.temp_file_write_size, ngx_conf_merge_size_value(conf->upstream.temp_file_write_size_conf,
prev->upstream.temp_file_write_size, prev->upstream.temp_file_write_size_conf,
NGX_CONF_UNSET_SIZE); NGX_CONF_UNSET_SIZE);
if (conf->upstream.temp_file_write_size == NGX_CONF_UNSET_SIZE) { if (conf->upstream.temp_file_write_size_conf == NGX_CONF_UNSET_SIZE) {
conf->upstream.temp_file_write_size = 2 * size; conf->upstream.temp_file_write_size = 2 * size;
} else {
conf->upstream.temp_file_write_size =
conf->upstream.temp_file_write_size_conf;
}
} else if (conf->upstream.temp_file_write_size < size) { if (conf->upstream.temp_file_write_size < size) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"\"fastcgi_temp_file_write_size\" must be equal or bigger than " "\"fastcgi_temp_file_write_size\" must be equal or bigger than "
"maximum of the value of \"fastcgi_header_buffer_size\" and " "maximum of the value of \"fastcgi_header_buffer_size\" and "
@ -1566,16 +1576,19 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
} }
ngx_conf_merge_size_value(conf->upstream.max_temp_file_size, ngx_conf_merge_size_value(conf->upstream.max_temp_file_size_conf,
prev->upstream.max_temp_file_size, prev->upstream.max_temp_file_size_conf,
NGX_CONF_UNSET_SIZE); NGX_CONF_UNSET_SIZE);
if (conf->upstream.max_temp_file_size == NGX_CONF_UNSET_SIZE) { if (conf->upstream.max_temp_file_size_conf == NGX_CONF_UNSET_SIZE) {
conf->upstream.max_temp_file_size = 1024 * 1024 * 1024; conf->upstream.max_temp_file_size = 1024 * 1024 * 1024;
} else {
conf->upstream.max_temp_file_size =
conf->upstream.max_temp_file_size_conf;
}
} else if (conf->upstream.max_temp_file_size != 0 if (conf->upstream.max_temp_file_size != 0
&& conf->upstream.max_temp_file_size < size) && conf->upstream.max_temp_file_size < size)
{ {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"\"fastcgi_max_temp_file_size\" must be equal to zero to disable " "\"fastcgi_max_temp_file_size\" must be equal to zero to disable "
@ -1598,7 +1611,7 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
NGX_HTTP_FASTCGI_TEMP_PATH, 1, 2, 0, NGX_HTTP_FASTCGI_TEMP_PATH, 1, 2, 0,
ngx_garbage_collector_temp_handler, cf); ngx_garbage_collector_temp_handler, cf);
ngx_conf_merge_msec_value(conf->upstream.pass_unparsed_uri, ngx_conf_merge_value(conf->upstream.pass_unparsed_uri,
prev->upstream.pass_unparsed_uri, 0); prev->upstream.pass_unparsed_uri, 0);
if (conf->upstream.pass_unparsed_uri && conf->upstream.location->len > 1) { if (conf->upstream.pass_unparsed_uri && conf->upstream.location->len > 1) {
@ -1617,10 +1630,10 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_value(conf->upstream.pass_request_body, ngx_conf_merge_value(conf->upstream.pass_request_body,
prev->upstream.pass_request_body, 1); prev->upstream.pass_request_body, 1);
ngx_conf_merge_msec_value(conf->upstream.redirect_errors, ngx_conf_merge_value(conf->upstream.redirect_errors,
prev->upstream.redirect_errors, 0); prev->upstream.redirect_errors, 0);
ngx_conf_merge_msec_value(conf->upstream.pass_x_powered_by, ngx_conf_merge_value(conf->upstream.pass_x_powered_by,
prev->upstream.pass_x_powered_by, 1); prev->upstream.pass_x_powered_by, 1);
@ -1628,7 +1641,6 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
if (conf->peers == NULL) { if (conf->peers == NULL) {
conf->peers = prev->peers; conf->peers = prev->peers;
conf->upstream = prev->upstream;
} }
if (conf->params_source == NULL) { if (conf->params_source == NULL) {

View File

@ -174,7 +174,7 @@ static ngx_command_t ngx_http_gzip_filter_commands[] = {
NULL }, NULL },
{ ngx_string("gzip_http_version"), { ngx_string("gzip_http_version"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_ANY, NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_enum_slot, ngx_conf_set_enum_slot,
NGX_HTTP_LOC_CONF_OFFSET, NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_gzip_conf_t, http_version), offsetof(ngx_http_gzip_conf_t, http_version),

View File

@ -219,7 +219,7 @@ static ngx_command_t ngx_http_proxy_commands[] = {
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_size_slot, ngx_conf_set_size_slot,
NGX_HTTP_LOC_CONF_OFFSET, NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_proxy_loc_conf_t, upstream.busy_buffers_size), offsetof(ngx_http_proxy_loc_conf_t, upstream.busy_buffers_size_conf),
NULL }, NULL },
{ ngx_string("proxy_temp_path"), { ngx_string("proxy_temp_path"),
@ -233,14 +233,14 @@ static ngx_command_t ngx_http_proxy_commands[] = {
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_size_slot, ngx_conf_set_size_slot,
NGX_HTTP_LOC_CONF_OFFSET, NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_proxy_loc_conf_t, upstream.max_temp_file_size), offsetof(ngx_http_proxy_loc_conf_t, upstream.max_temp_file_size_conf),
NULL }, NULL },
{ ngx_string("proxy_temp_file_write_size"), { ngx_string("proxy_temp_file_write_size"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_size_slot, ngx_conf_set_size_slot,
NGX_HTTP_LOC_CONF_OFFSET, NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_proxy_loc_conf_t, upstream.temp_file_write_size), offsetof(ngx_http_proxy_loc_conf_t, upstream.temp_file_write_size_conf),
NULL }, NULL },
{ ngx_string("proxy_next_upstream"), { ngx_string("proxy_next_upstream"),
@ -720,21 +720,21 @@ ngx_http_proxy_process_status_line(ngx_http_request_t *r)
return NGX_OK; return NGX_OK;
} }
r->headers_out.status = p->status; u->headers_in.status_n = p->status;
u->state->status = p->status; u->state->status = p->status;
r->headers_out.status_line.len = p->status_end - p->status_start; u->headers_in.status_line.len = p->status_end - p->status_start;
r->headers_out.status_line.data = ngx_palloc(r->pool, u->headers_in.status_line.data = ngx_palloc(r->pool,
r->headers_out.status_line.len); u->headers_in.status_line.len);
if (r->headers_out.status_line.data == NULL) { if (u->headers_in.status_line.data == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR; return NGX_HTTP_INTERNAL_SERVER_ERROR;
} }
ngx_memcpy(r->headers_out.status_line.data, p->status_start, ngx_memcpy(u->headers_in.status_line.data, p->status_start,
r->headers_out.status_line.len); u->headers_in.status_line.len);
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"http proxy status %ui \"%V\"", "http proxy status %ui \"%V\"",
r->headers_out.status, &r->headers_out.status_line); u->headers_in.status, &u->headers_in.status_line);
u->process_header = ngx_http_proxy_process_header; u->process_header = ngx_http_proxy_process_header;
@ -1301,9 +1301,10 @@ ngx_http_proxy_create_loc_conf(ngx_conf_t *cf)
conf->upstream.send_lowat = NGX_CONF_UNSET_SIZE; conf->upstream.send_lowat = NGX_CONF_UNSET_SIZE;
conf->upstream.header_buffer_size = NGX_CONF_UNSET_SIZE; conf->upstream.header_buffer_size = NGX_CONF_UNSET_SIZE;
conf->upstream.busy_buffers_size = NGX_CONF_UNSET_SIZE;
conf->upstream.max_temp_file_size = NGX_CONF_UNSET_SIZE; conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE;
conf->upstream.temp_file_write_size = NGX_CONF_UNSET_SIZE; conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE;
conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE;
conf->upstream.pass_unparsed_uri = NGX_CONF_UNSET; conf->upstream.pass_unparsed_uri = NGX_CONF_UNSET;
conf->upstream.method = NGX_CONF_UNSET_UINT; conf->upstream.method = NGX_CONF_UNSET_UINT;
@ -1374,23 +1375,28 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
} }
ngx_conf_merge_size_value(conf->upstream.busy_buffers_size, ngx_conf_merge_size_value(conf->upstream.busy_buffers_size_conf,
prev->upstream.busy_buffers_size, prev->upstream.busy_buffers_size_conf,
NGX_CONF_UNSET_SIZE); NGX_CONF_UNSET_SIZE);
if (conf->upstream.busy_buffers_size == NGX_CONF_UNSET_SIZE) { if (conf->upstream.busy_buffers_size_conf == NGX_CONF_UNSET_SIZE) {
conf->upstream.busy_buffers_size = 2 * size; conf->upstream.busy_buffers_size = 2 * size;
} else {
} else if (conf->upstream.busy_buffers_size < size) { conf->upstream.busy_buffers_size =
conf->upstream.busy_buffers_size_conf;
}
if (conf->upstream.busy_buffers_size < size) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"\"proxy_busy_buffers_size\" must be equal or bigger than " "\"proxy_busy_buffers_size\" must be equal or bigger than "
"maximum of the value of \"proxy_header_buffer_size\" and " "maximum of the value of \"proxy_header_buffer_size\" and "
"one of the \"proxy_buffers\""); "one of the \"proxy_buffers\"");
return NGX_CONF_ERROR; return NGX_CONF_ERROR;
}
} else if (conf->upstream.busy_buffers_size if (conf->upstream.busy_buffers_size
> (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size) > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size)
{ {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"\"proxy_busy_buffers_size\" must be less than " "\"proxy_busy_buffers_size\" must be less than "
@ -1398,16 +1404,20 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
return NGX_CONF_ERROR; return NGX_CONF_ERROR;
} }
ngx_conf_merge_size_value(conf->upstream.temp_file_write_size,
prev->upstream.temp_file_write_size, ngx_conf_merge_size_value(conf->upstream.temp_file_write_size_conf,
prev->upstream.temp_file_write_size_conf,
NGX_CONF_UNSET_SIZE); NGX_CONF_UNSET_SIZE);
if (conf->upstream.temp_file_write_size == NGX_CONF_UNSET_SIZE) { if (conf->upstream.temp_file_write_size_conf == NGX_CONF_UNSET_SIZE) {
conf->upstream.temp_file_write_size = 2 * size; conf->upstream.temp_file_write_size = 2 * size;
} else {
} else if (conf->upstream.temp_file_write_size < size) { conf->upstream.temp_file_write_size =
conf->upstream.temp_file_write_size_conf;
}
if (conf->upstream.temp_file_write_size < size) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"\"proxy_temp_file_write_size\" must be equal or bigger than " "\"proxy_temp_file_write_size\" must be equal or bigger than "
"maximum of the value of \"proxy_header_buffer_size\" and " "maximum of the value of \"proxy_header_buffer_size\" and "
@ -1416,17 +1426,19 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
return NGX_CONF_ERROR; return NGX_CONF_ERROR;
} }
ngx_conf_merge_size_value(conf->upstream.max_temp_file_size_conf,
ngx_conf_merge_size_value(conf->upstream.max_temp_file_size, prev->upstream.max_temp_file_size_conf,
prev->upstream.max_temp_file_size,
NGX_CONF_UNSET_SIZE); NGX_CONF_UNSET_SIZE);
if (conf->upstream.max_temp_file_size == NGX_CONF_UNSET_SIZE) { if (conf->upstream.max_temp_file_size_conf == NGX_CONF_UNSET_SIZE) {
conf->upstream.max_temp_file_size = 1024 * 1024 * 1024; conf->upstream.max_temp_file_size = 1024 * 1024 * 1024;
} else {
conf->upstream.max_temp_file_size =
conf->upstream.max_temp_file_size_conf;
}
} else if (conf->upstream.max_temp_file_size != 0 if (conf->upstream.max_temp_file_size != 0
&& conf->upstream.max_temp_file_size < size) && conf->upstream.max_temp_file_size < size)
{ {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"\"fastcgi_max_temp_file_size\" must be equal to zero to disable " "\"fastcgi_max_temp_file_size\" must be equal to zero to disable "
@ -1437,6 +1449,7 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
return NGX_CONF_ERROR; return NGX_CONF_ERROR;
} }
ngx_conf_merge_bitmask_value(conf->upstream.next_upstream, ngx_conf_merge_bitmask_value(conf->upstream.next_upstream,
prev->upstream.next_upstream, prev->upstream.next_upstream,
(NGX_CONF_BITMASK_SET (NGX_CONF_BITMASK_SET
@ -1448,7 +1461,7 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
NGX_HTTP_PROXY_TEMP_PATH, 1, 2, 0, NGX_HTTP_PROXY_TEMP_PATH, 1, 2, 0,
ngx_garbage_collector_temp_handler, cf); ngx_garbage_collector_temp_handler, cf);
ngx_conf_merge_msec_value(conf->upstream.pass_unparsed_uri, ngx_conf_merge_value(conf->upstream.pass_unparsed_uri,
prev->upstream.pass_unparsed_uri, 0); prev->upstream.pass_unparsed_uri, 0);
if (conf->upstream.pass_unparsed_uri && conf->upstream.location->len > 1) { if (conf->upstream.pass_unparsed_uri && conf->upstream.location->len > 1) {
@ -1467,14 +1480,14 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_value(conf->upstream.pass_request_body, ngx_conf_merge_value(conf->upstream.pass_request_body,
prev->upstream.pass_request_body, 1); prev->upstream.pass_request_body, 1);
ngx_conf_merge_msec_value(conf->upstream.redirect_errors, ngx_conf_merge_value(conf->upstream.redirect_errors,
prev->upstream.redirect_errors, 0); prev->upstream.redirect_errors, 0);
ngx_conf_merge_msec_value(conf->upstream.pass_x_powered_by, ngx_conf_merge_value(conf->upstream.pass_x_powered_by,
prev->upstream.pass_x_powered_by, 1); prev->upstream.pass_x_powered_by, 1);
ngx_conf_merge_msec_value(conf->upstream.pass_server, ngx_conf_merge_value(conf->upstream.pass_server,
prev->upstream.pass_server, 0); prev->upstream.pass_server, 0);
ngx_conf_merge_msec_value(conf->upstream.pass_x_accel_expires, ngx_conf_merge_value(conf->upstream.pass_x_accel_expires,
prev->upstream.pass_x_accel_expires, 0); prev->upstream.pass_x_accel_expires, 0);
@ -1508,7 +1521,6 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
if (conf->peers == NULL) { if (conf->peers == NULL) {
conf->peers = prev->peers; conf->peers = prev->peers;
conf->upstream = prev->upstream;
} }
if (conf->headers_source == NULL) { if (conf->headers_source == NULL) {

View File

@ -1373,8 +1373,8 @@ static ngx_int_t
ngx_http_ssi_include(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, ngx_http_ssi_include(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
ngx_str_t **params) ngx_str_t **params)
{ {
u_char ch, *p, **value; u_char ch, *p, **value, *data;
size_t *size, len; size_t *size, len, prefix;
ngx_uint_t i, j, n, bracket; ngx_uint_t i, j, n, bracket;
ngx_str_t uri, args, name; ngx_str_t uri, args, name;
ngx_array_t lengths, values; ngx_array_t lengths, values;
@ -1385,6 +1385,7 @@ ngx_http_ssi_include(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
uri = *params[NGX_HTTP_SSI_INCLUDE_VIRTUAL]; uri = *params[NGX_HTTP_SSI_INCLUDE_VIRTUAL];
args.len = 0; args.len = 0;
args.data = NULL; args.data = NULL;
prefix = 0;
n = ngx_http_script_variables_count(&uri); n = ngx_http_script_variables_count(&uri);
@ -1497,6 +1498,24 @@ ngx_http_ssi_include(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
*value = name.data; *value = name.data;
} }
size = lengths.elts;
value = values.elts;
for (i = 0; i < values.nelts; i++) {
if (size[i] != 0) {
if (*value[i] != '/') {
for (prefix = r->uri.len; prefix; prefix--) {
if (r->uri.data[prefix - 1] == '/') {
len += prefix;
break;
}
}
}
break;
}
}
p = ngx_palloc(r->pool, len); p = ngx_palloc(r->pool, len);
if (p == NULL) { if (p == NULL) {
return NGX_HTTP_SSI_ERROR; return NGX_HTTP_SSI_ERROR;
@ -1505,12 +1524,37 @@ ngx_http_ssi_include(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
uri.len = len; uri.len = len;
uri.data = p; uri.data = p;
size = lengths.elts; if (prefix) {
value = values.elts; p = ngx_cpymem(p, r->uri.data, prefix);
}
for (i = 0; i < values.nelts; i++) { for (i = 0; i < values.nelts; i++) {
p = ngx_cpymem(p, value[i], size[i]); p = ngx_cpymem(p, value[i], size[i]);
} }
} else {
if (uri.data[0] != '/') {
for (prefix = r->uri.len; prefix; prefix--) {
if (r->uri.data[prefix - 1] == '/') {
break;
}
}
if (prefix) {
len = prefix + uri.len;
data = ngx_palloc(r->pool, len);
if (data == NULL) {
return NGX_HTTP_SSI_ERROR;
}
p = ngx_cpymem(data, r->uri.data, prefix);
ngx_memcpy(p, uri.data, uri.len);
uri.len = len;
uri.data = data;
}
}
} }
for (i = 0; i < uri.len; i++) { for (i = 0; i < uri.len; i++) {

View File

@ -221,18 +221,19 @@ ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
} }
} }
if (SSL_CTX_use_certificate_file(conf->ssl_ctx, if (SSL_CTX_use_certificate_chain_file(conf->ssl_ctx,
(char *) conf->certificate.data, (char *) conf->certificate.data) == 0)
SSL_FILETYPE_PEM) == 0) { {
ngx_ssl_error(NGX_LOG_EMERG, cf->log, 0, ngx_ssl_error(NGX_LOG_EMERG, cf->log, 0,
"SSL_CTX_use_certificate_file(\"%s\") failed", "SSL_CTX_use_certificate_chain_file(\"%s\") failed",
conf->certificate.data); conf->certificate.data);
return NGX_CONF_ERROR; return NGX_CONF_ERROR;
} }
if (SSL_CTX_use_PrivateKey_file(conf->ssl_ctx, if (SSL_CTX_use_PrivateKey_file(conf->ssl_ctx,
(char *) conf->certificate_key.data, (char *) conf->certificate_key.data,
SSL_FILETYPE_PEM) == 0) { SSL_FILETYPE_PEM) == 0)
{
ngx_ssl_error(NGX_LOG_EMERG, cf->log, 0, ngx_ssl_error(NGX_LOG_EMERG, cf->log, 0,
"SSL_CTX_use_PrivateKey_file(\"%s\") failed", "SSL_CTX_use_PrivateKey_file(\"%s\") failed",
conf->certificate_key.data); conf->certificate_key.data);

View File

@ -103,6 +103,11 @@ ngx_http_upstream_header_t ngx_http_upstream_headers_in[] = {
ngx_http_upstream_conditional_copy_header_line, ngx_http_upstream_conditional_copy_header_line,
offsetof(ngx_http_upstream_conf_t, pass_server), 0 }, offsetof(ngx_http_upstream_conf_t, pass_server), 0 },
{ ngx_string("WWW-Authenticate"),
ngx_http_upstream_process_header_line,
offsetof(ngx_http_upstream_headers_in_t, www_authenticate),
ngx_http_upstream_copy_header_line, 0, 0 },
{ ngx_string("Location"), { ngx_string("Location"),
ngx_http_upstream_ignore_header_line, 0, ngx_http_upstream_ignore_header_line, 0,
ngx_http_upstream_rewrite_location, 0, 0 }, ngx_http_upstream_rewrite_location, 0, 0 },
@ -113,7 +118,7 @@ ngx_http_upstream_header_t ngx_http_upstream_headers_in[] = {
{ ngx_string("Set-Cookie"), { ngx_string("Set-Cookie"),
ngx_http_upstream_ignore_header_line, 0, ngx_http_upstream_ignore_header_line, 0,
ngx_http_upstream_copy_header_line, 0, 1 }, ngx_http_upstream_copy_header_line, 0, 0 },
{ ngx_string("Cache-Control"), { ngx_string("Cache-Control"),
ngx_http_upstream_process_multi_header_lines, ngx_http_upstream_process_multi_header_lines,
@ -386,9 +391,6 @@ ngx_http_upstream_check_broken_connection(ngx_http_request_t *r,
return; return;
} }
ev->eof = 1;
c->closed = 1;
if (n == -1) { if (n == -1) {
if (err == NGX_EAGAIN) { if (err == NGX_EAGAIN) {
return; return;
@ -400,6 +402,9 @@ ngx_http_upstream_check_broken_connection(ngx_http_request_t *r,
err = 0; err = 0;
} }
ev->eof = 1;
c->closed = 1;
if (!u->cachable && u->peer.connection) { if (!u->cachable && u->peer.connection) {
ngx_log_error(NGX_LOG_INFO, ev->log, err, ngx_log_error(NGX_LOG_INFO, ev->log, err,
"client closed prematurely connection, " "client closed prematurely connection, "
@ -851,7 +856,7 @@ ngx_http_upstream_process_header(ngx_event_t *rev)
/* rc == NGX_OK */ /* rc == NGX_OK */
if (r->headers_out.status == NGX_HTTP_INTERNAL_SERVER_ERROR) { if (u->headers_in.status_n == NGX_HTTP_INTERNAL_SERVER_ERROR) {
if (u->peer.tries > 1 if (u->peer.tries > 1
&& (u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_HTTP_500)) && (u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_HTTP_500))
@ -867,14 +872,14 @@ ngx_http_upstream_process_header(ngx_event_t *rev)
&& (u->conf->use_stale & NGX_HTTP_UPSTREAM_FT_HTTP_500)) && (u->conf->use_stale & NGX_HTTP_UPSTREAM_FT_HTTP_500))
{ {
ngx_http_upstream_finalize_request(r, u, ngx_http_upstream_finalize_request(r, u,
ngx_http_send_cached_response(r)); ngx_http_send_cached_response(r));
return; return;
} }
#endif #endif
} }
if (r->headers_out.status == NGX_HTTP_NOT_FOUND if (u->headers_in.status_n == NGX_HTTP_NOT_FOUND
&& u->peer.tries > 1 && u->peer.tries > 1
&& u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_HTTP_404) && u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_HTTP_404)
{ {
@ -883,7 +888,7 @@ ngx_http_upstream_process_header(ngx_event_t *rev)
} }
if (r->headers_out.status >= NGX_HTTP_BAD_REQUEST if (u->headers_in.status_n >= NGX_HTTP_BAD_REQUEST
&& u->conf->redirect_errors && u->conf->redirect_errors
&& r->err_ctx == NULL) && r->err_ctx == NULL)
{ {
@ -893,9 +898,25 @@ ngx_http_upstream_process_header(ngx_event_t *rev)
err_page = clcf->error_pages->elts; err_page = clcf->error_pages->elts;
for (i = 0; i < clcf->error_pages->nelts; i++) { for (i = 0; i < clcf->error_pages->nelts; i++) {
if (err_page[i].status == (ngx_int_t) r->headers_out.status) { if (err_page[i].status == (ngx_int_t) u->headers_in.status_n) {
if (u->headers_in.status_n == NGX_HTTP_UNAUTHORIZED) {
r->headers_out.www_authenticate =
ngx_list_push(&r->headers_out.headers);
if (r->headers_out.www_authenticate == NULL) {
ngx_http_upstream_finalize_request(r, u,
NGX_HTTP_INTERNAL_SERVER_ERROR);
return;
}
*r->headers_out.www_authenticate =
*u->headers_in.www_authenticate;
}
ngx_http_upstream_finalize_request(r, u, ngx_http_upstream_finalize_request(r, u,
r->headers_out.status); u->headers_in.status_n);
return; return;
} }
} }
@ -938,8 +959,6 @@ ngx_http_upstream_process_header(ngx_event_t *rev)
} }
} }
r->headers_out.status_line.len = 0;
ngx_http_internal_redirect(r, ngx_http_internal_redirect(r,
&r->upstream->headers_in.x_accel_redirect->value, &r->upstream->headers_in.x_accel_redirect->value,
NULL); NULL);
@ -1001,6 +1020,9 @@ ngx_http_upstream_send_response(ngx_http_request_t *r, ngx_http_upstream_t *u)
} }
} }
r->headers_out.status = u->headers_in.status_n;
r->headers_out.status_line = u->headers_in.status_line;
rc = ngx_http_send_header(r); rc = ngx_http_send_header(r);
if (rc == NGX_ERROR || rc > NGX_OK) { if (rc == NGX_ERROR || rc > NGX_OK) {
@ -1622,6 +1644,10 @@ ngx_http_upstream_rewrite_location(ngx_http_request_t *r, ngx_table_elt_t *h,
if (r->upstream->rewrite_redirect) { if (r->upstream->rewrite_redirect) {
rc = r->upstream->rewrite_redirect(r, ho, 0); rc = r->upstream->rewrite_redirect(r, ho, 0);
if (rc == NGX_DECLINED) {
return NGX_OK;
}
if (rc == NGX_OK) { if (rc == NGX_OK) {
r->headers_out.location = ho; r->headers_out.location = ho;
@ -1667,6 +1693,10 @@ ngx_http_upstream_rewrite_refresh(ngx_http_request_t *r, ngx_table_elt_t *h,
return NGX_OK; return NGX_OK;
} }
if (rc == NGX_DECLINED) {
return NGX_OK;
}
#if (NGX_DEBUG) #if (NGX_DEBUG)
if (rc == NGX_OK) { if (rc == NGX_OK) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,

View File

@ -52,10 +52,15 @@ typedef struct {
size_t send_lowat; size_t send_lowat;
size_t header_buffer_size; size_t header_buffer_size;
size_t busy_buffers_size; size_t busy_buffers_size;
size_t max_temp_file_size; size_t max_temp_file_size;
size_t temp_file_write_size; size_t temp_file_write_size;
size_t busy_buffers_size_conf;
size_t max_temp_file_size_conf;
size_t temp_file_write_size_conf;
ngx_uint_t next_upstream; ngx_uint_t next_upstream;
ngx_uint_t method; ngx_uint_t method;
@ -95,6 +100,9 @@ typedef struct {
typedef struct { typedef struct {
ngx_list_t headers; ngx_list_t headers;
ngx_uint_t status_n;
ngx_str_t status_line;
ngx_table_elt_t *status; ngx_table_elt_t *status;
ngx_table_elt_t *date; ngx_table_elt_t *date;
ngx_table_elt_t *server; ngx_table_elt_t *server;
@ -112,6 +120,7 @@ typedef struct {
ngx_table_elt_t *last_modified; ngx_table_elt_t *last_modified;
ngx_table_elt_t *location; ngx_table_elt_t *location;
ngx_table_elt_t *accept_ranges; ngx_table_elt_t *accept_ranges;
ngx_table_elt_t *www_authenticate;
#if (NGX_HTTP_GZIP) #if (NGX_HTTP_GZIP)
ngx_table_elt_t *content_encoding; ngx_table_elt_t *content_encoding;

View File

@ -16,7 +16,7 @@ static ngx_int_t ngx_imap_read_command(ngx_imap_session_t *s);
static ngx_str_t greetings[] = { static ngx_str_t greetings[] = {
ngx_string("+OK POP3 ready" CRLF), ngx_string("+OK POP3 ready" CRLF),
ngx_string("* OK IMAP ready" CRLF) ngx_string("* OK IMAP4 ready" CRLF)
}; };
static ngx_str_t internal_server_errors[] = { static ngx_str_t internal_server_errors[] = {
@ -27,7 +27,7 @@ static ngx_str_t internal_server_errors[] = {
static u_char pop3_ok[] = "+OK" CRLF; static u_char pop3_ok[] = "+OK" CRLF;
static u_char pop3_invalid_command[] = "-ERR invalid command" CRLF; static u_char pop3_invalid_command[] = "-ERR invalid command" CRLF;
static u_char imap_ok[] = "OK" CRLF; static u_char imap_ok[] = "OK completed" CRLF;
static u_char imap_next[] = "+ OK" CRLF; static u_char imap_next[] = "+ OK" CRLF;
static u_char imap_bye[] = "* BYE" CRLF; static u_char imap_bye[] = "* BYE" CRLF;
static u_char imap_invalid_command[] = "BAD invalid command" CRLF; static u_char imap_invalid_command[] = "BAD invalid command" CRLF;

View File

@ -252,7 +252,7 @@ ngx_int_t ngx_imap_parse_command(ngx_imap_session_t *s)
goto invalid; goto invalid;
case sw_literal_argument: case sw_literal_argument:
if (--s->literal_len) { if (s->literal_len && --s->literal_len) {
break; break;
} }
@ -281,7 +281,8 @@ ngx_int_t ngx_imap_parse_command(ngx_imap_session_t *s)
case LF: case LF:
goto done; goto done;
default: default:
goto invalid; state = sw_spaces_before_argument;
break;
} }
break; break;

View File

@ -169,11 +169,21 @@ ngx_imap_proxy_imap_handler(ngx_event_t *rev)
return; return;
} }
if (rc == NGX_ERROR) { if (rc == NGX_ERROR || rc == NGX_IMAP_PROXY_INVALID) {
ngx_imap_proxy_internal_server_error(s); ngx_imap_proxy_internal_server_error(s);
return; return;
} }
if (rc == NGX_IMAP_PROXY_ERROR) {
s->connection->read->handler = ngx_imap_proxy_handler;
s->connection->write->handler = ngx_imap_proxy_handler;
rev->handler = ngx_imap_proxy_handler;
c->write->handler = ngx_imap_proxy_handler;
ngx_imap_proxy_handler(c->read);
return;
}
switch (s->imap_state) { switch (s->imap_state) {
case ngx_imap_start: case ngx_imap_start:
@ -198,14 +208,14 @@ ngx_imap_proxy_imap_handler(ngx_event_t *rev)
case ngx_imap_login: case ngx_imap_login:
ngx_log_debug0(NGX_LOG_DEBUG_IMAP, rev->log, 0, "imap proxy send user"); ngx_log_debug0(NGX_LOG_DEBUG_IMAP, rev->log, 0, "imap proxy send user");
line.len = s->login.len + 1 + NGX_SIZE_T_LEN + 1 + 2; line.len = s->login.len + 1 + 1 + NGX_SIZE_T_LEN + 1 + 2;
line.data = ngx_palloc(c->pool, line.len); line.data = ngx_palloc(c->pool, line.len);
if (line.data == NULL) { if (line.data == NULL) {
ngx_imap_proxy_internal_server_error(s); ngx_imap_proxy_internal_server_error(s);
return; return;
} }
line.len = ngx_sprintf(line.data, "%V{%uz}" CRLF, line.len = ngx_sprintf(line.data, "%V {%uz}" CRLF,
&s->login, s->passwd.len) &s->login, s->passwd.len)
- line.data; - line.data;
@ -298,11 +308,21 @@ ngx_imap_proxy_pop3_handler(ngx_event_t *rev)
return; return;
} }
if (rc == NGX_ERROR) { if (rc == NGX_ERROR || rc == NGX_IMAP_PROXY_INVALID) {
ngx_imap_proxy_internal_server_error(s); ngx_imap_proxy_internal_server_error(s);
return; return;
} }
if (rc == NGX_IMAP_PROXY_ERROR) {
s->connection->read->handler = ngx_imap_proxy_handler;
s->connection->write->handler = ngx_imap_proxy_handler;
rev->handler = ngx_imap_proxy_handler;
c->write->handler = ngx_imap_proxy_handler;
ngx_imap_proxy_handler(c->read);
return;
}
switch (s->imap_state) { switch (s->imap_state) {
case ngx_pop3_start: case ngx_pop3_start:
@ -424,13 +444,17 @@ ngx_imap_proxy_read_response(ngx_imap_session_t *s, ngx_uint_t what)
} }
} else { } else {
if (p[0] == 'N' && p[1] == 'O') {
return NGX_IMAP_PROXY_ERROR;
}
if (what == NGX_IMAP_WAIT_OK) { if (what == NGX_IMAP_WAIT_OK) {
if (p[0] == '*' && p[1] == ' ' && p[2] == 'O' && p[3] == 'K') { if (p[0] == '*' && p[1] == ' ' && p[2] == 'O' && p[3] == 'K') {
return NGX_OK; return NGX_OK;
} }
} else { } else {
if (p[0] == '+' && p[1] == ' ' && p[2] == 'O' && p[3] == 'K') { if (p[0] == '+') {
return NGX_OK; return NGX_OK;
} }
} }
@ -528,7 +552,7 @@ ngx_imap_proxy_handler(ngx_event_t *ev)
if (n == NGX_AGAIN || n < (ssize_t) size) { if (n == NGX_AGAIN || n < (ssize_t) size) {
if (ngx_handle_write_event(dst->write, /* TODO: LOWAT */ 0) if (ngx_handle_write_event(dst->write, /* TODO: LOWAT */ 0)
== NGX_ERROR) == NGX_ERROR)
{ {
ngx_imap_proxy_close_session(s); ngx_imap_proxy_close_session(s);
return; return;

View File

@ -33,8 +33,8 @@ ngx_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, u_char **encrypted)
ngx_set_errno(0); ngx_set_errno(0);
cd.initialized = 0; cd.initialized = 0;
/* work around the glibc-2.2.5 bug */ /* work around the glibc bug */
cd.current_saltbits = 0; cd.current_salt[0] = ~salt[0];
value = crypt_r((char *) key, (char *) salt, &cd); value = crypt_r((char *) key, (char *) salt, &cd);