fix style, some names, and building by MSVC8

This commit is contained in:
Igor Sysoev 2010-06-01 16:00:42 +00:00
parent 6d7beea1ce
commit 670cdbba61

View File

@ -23,11 +23,10 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*
*
* heavily based on Manlio's mod_scgi, mod_fastcgi and mod_proxy of nginx 0.7.x
*/
@ -35,8 +34,10 @@
#include <ngx_core.h>
#include <ngx_http.h>
#define NGX_HTTP_UWSGI_TEMP_PATH "uwsgi_temp"
typedef struct {
ngx_http_upstream_conf_t upstream;
@ -52,7 +53,6 @@ typedef struct {
u_char modifier1;
u_char modifier2;
} ngx_http_uwsgi_loc_conf_t;
typedef struct {
@ -62,7 +62,9 @@ typedef struct {
u_char *status_end;
} ngx_http_uwsgi_ctx_t;
#define NGX_HTTP_XCGI_PARSE_NO_HEADER 20
#define NGX_HTTP_UWSGI_PARSE_NO_HEADER 20
#ifndef NGX_HAVE_LITTLE_ENDIAN
static uint16_t
@ -80,8 +82,7 @@ static ngx_int_t ngx_http_uwsgi_create_request (ngx_http_request_t * r);
static ngx_int_t ngx_http_uwsgi_reinit_request(ngx_http_request_t *r);
static ngx_int_t ngx_http_uwsgi_process_status_line(ngx_http_request_t *r);
static ngx_int_t ngx_http_uwsgi_parse_status_line(ngx_http_request_t *r,
ngx_http_uwsgi_ctx_t *
ctx);
ngx_http_uwsgi_ctx_t *ctx);
static ngx_int_t ngx_http_uwsgi_process_header(ngx_http_request_t *r);
static ngx_int_t ngx_http_uwsgi_process_header(ngx_http_request_t *r);
static void ngx_http_uwsgi_abort_request(ngx_http_request_t *r);
@ -96,8 +97,8 @@ static char *ngx_http_uwsgi_modifier2 (ngx_conf_t * cf, ngx_command_t * cmd,
static ngx_int_t ngx_http_uwsgi_add_variables(ngx_conf_t *cf);
static void *ngx_http_uwsgi_create_loc_conf(ngx_conf_t *cf);
static char *ngx_http_uwsgi_merge_loc_conf (ngx_conf_t * cf,
void *parent, void *child);
static char *ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent,
void *child);
static char *ngx_http_uwsgi_pass(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
@ -138,168 +139,147 @@ static ngx_command_t ngx_http_uwsgi_commands[] = {
NULL },
{ ngx_string("uwsgi_modifier1"),
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_http_uwsgi_modifier1,
NGX_HTTP_LOC_CONF_OFFSET,
0,
NULL },
{ ngx_string("uwsgi_modifier2"),
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_http_uwsgi_modifier2,
NGX_HTTP_LOC_CONF_OFFSET,
0,
NULL },
{ ngx_string("uwsgi_ignore_client_abort"),
NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
NGX_CONF_FLAG,
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_uwsgi_loc_conf_t, upstream.ignore_client_abort),
NULL },
{ ngx_string("uwsgi_connect_timeout"),
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_msec_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.connect_timeout),
NULL },
{ ngx_string("uwsgi_send_timeout"),
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_msec_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.send_timeout),
NULL },
{ ngx_string("uwsgi_buffer_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_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.buffer_size),
NULL },
{ ngx_string("uwsgi_pass_request_headers"),
NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
NGX_CONF_FLAG,
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_uwsgi_loc_conf_t, upstream.pass_request_headers),
NULL },
{ ngx_string("uwsgi_pass_request_body"),
NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
NGX_CONF_FLAG,
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_uwsgi_loc_conf_t, upstream.pass_request_body),
NULL },
{ ngx_string("uwsgi_intercept_errors"),
NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
NGX_CONF_FLAG,
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_uwsgi_loc_conf_t, upstream.intercept_errors),
NULL },
{ ngx_string("uwsgi_read_timeout"),
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_msec_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.read_timeout),
NULL },
{ ngx_string("uwsgi_buffers"),
NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
NGX_CONF_TAKE2,
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
ngx_conf_set_bufs_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.bufs),
NULL },
{ ngx_string("uwsgi_busy_buffers_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_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.busy_buffers_size_conf),
NULL },
{ ngx_string("uwsgi_temp_path"),
NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
NGX_CONF_TAKE1234,
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234,
ngx_conf_set_path_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.temp_path),
NULL },
{ ngx_string("uwsgi_max_temp_file_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_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.max_temp_file_size_conf),
NULL },
{ ngx_string("uwsgi_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_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.temp_file_write_size_conf),
NULL },
{ ngx_string("uwsgi_next_upstream"),
NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
NGX_CONF_1MORE,
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
ngx_conf_set_bitmask_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.next_upstream),
&ngx_http_uwsgi_next_upstream_masks },
{ ngx_string("uwsgi_param"),
NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
NGX_CONF_TAKE2,
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
ngx_conf_set_keyval_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_uwsgi_loc_conf_t, params_source),
NULL },
{ ngx_string("uwsgi_string"),
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_str_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_uwsgi_loc_conf_t, uwsgi_string),
NULL },
{ ngx_string("uwsgi_pass_header"),
NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
NGX_CONF_FLAG,
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
ngx_conf_set_str_array_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.pass_headers),
NULL },
{ ngx_string("uwsgi_hide_header"),
NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
NGX_CONF_FLAG,
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
ngx_conf_set_str_array_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.hide_headers),
NULL },
{ ngx_string("uwsgi_ignore_headers"),
NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
NGX_CONF_1MORE,
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
ngx_conf_set_bitmask_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.ignore_headers),
@ -367,13 +347,13 @@ ngx_http_uwsgi_handler (ngx_http_request_t * r)
{
ngx_int_t rc;
ngx_http_upstream_t *u;
ngx_http_uwsgi_ctx_t *f;
ngx_http_uwsgi_ctx_t *ctx;
ngx_http_uwsgi_loc_conf_t *uwcf;
if (r->subrequest_in_memory) {
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
"ngx_http_uwsgi_module does not support "
"subrequest in memory");
"subrequests in memory");
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
@ -381,12 +361,12 @@ ngx_http_uwsgi_handler (ngx_http_request_t * r)
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
f = ngx_pcalloc (r->pool, sizeof (ngx_http_uwsgi_ctx_t));
if (f == NULL) {
ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_uwsgi_ctx_t));
if (ctx == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
ngx_http_set_ctx (r, f, ngx_http_uwsgi_module);
ngx_http_set_ctx(r, ctx, ngx_http_uwsgi_module);
uwcf = ngx_http_get_module_loc_conf(r, ngx_http_uwsgi_module);
@ -439,7 +419,9 @@ ngx_http_uwsgi_eval (ngx_http_request_t * r, ngx_http_uwsgi_loc_conf_t * uwcf)
ngx_memzero(&u, sizeof(ngx_url_t));
if (ngx_http_script_run(r, &u.url, uwcf->uwsgi_lengths->elts, 0,
uwcf->uwsgi_values->elts) == NULL) {
uwcf->uwsgi_values->elts)
== NULL)
{
return NGX_ERROR;
}
@ -461,8 +443,7 @@ ngx_http_uwsgi_eval (ngx_http_request_t * r, ngx_http_uwsgi_loc_conf_t * uwcf)
}
r->upstream->resolved = ngx_pcalloc(r->pool,
sizeof
(ngx_http_upstream_resolved_t));
sizeof(ngx_http_upstream_resolved_t));
if (r->upstream->resolved == NULL) {
return NGX_ERROR;
}
@ -473,8 +454,7 @@ ngx_http_uwsgi_eval (ngx_http_request_t * r, ngx_http_uwsgi_loc_conf_t * uwcf)
r->upstream->resolved->naddrs = 1;
r->upstream->resolved->host = u.addrs[0].name;
}
else {
} else {
r->upstream->resolved->host = u.host;
r->upstream->resolved->port = u.port;
}
@ -522,7 +502,8 @@ ngx_http_uwsgi_create_request (ngx_http_request_t * r)
}
le.ip += sizeof(uintptr_t);
uwsgi_pkt_size += 2 + key_len + 2 + val_len;
uwsgi_pkt_size = (uint16_t)
(uwsgi_pkt_size + 2 + key_len + 2 + val_len);
}
}
@ -543,23 +524,23 @@ ngx_http_uwsgi_create_request (ngx_http_request_t * r)
i = 0;
}
uwsgi_pkt_size +=
2 + 5 + header[i].key.len + 2 + header[i].value.len;
uwsgi_pkt_size = (uint16_t) (uwsgi_pkt_size
+ 2 + 5 + header[i].key.len + 2 + header[i].value.len);
}
}
if (uwcf->uwsgi_string.data && uwcf->uwsgi_string.len) {
uwsgi_pkt_size += uwcf->uwsgi_string.len ;
uwsgi_pkt_size = (uint16_t) (uwsgi_pkt_size + uwcf->uwsgi_string.len);
}
/* allow custom uwsgi packet
#if 0
/* allow custom uwsgi packet */
if (uwsgi_pkt_size > 0 && uwsgi_pkt_size < 2) {
ngx_log_error (NGX_LOG_ALERT, r->connection->log, 0,
"uwsgi request is too little: %uz", uwsgi_pkt_size);
return NGX_ERROR;
}
*/
#endif
b = ngx_create_temp_buf(r->pool, uwsgi_pkt_size + 4);
if (b == NULL) {
@ -604,7 +585,7 @@ ngx_http_uwsgi_create_request (ngx_http_request_t * r)
#ifndef NGX_HAVE_LITTLE_ENDIAN
uwsgi_strlen = uwsgi_swap16(key_len);
#else
uwsgi_strlen = key_len;
uwsgi_strlen = (uint16_t) key_len;
#endif
e.pos = ngx_cpymem(e.pos, &uwsgi_strlen, 2);
@ -616,8 +597,8 @@ ngx_http_uwsgi_create_request (ngx_http_request_t * r)
pos = e.pos - val_len;
/* move memory */
for (i = 0; i < val_len; i += 2) {
e.pos = ngx_cpymem (tmp, pos + (i) + 2, 2);
e.pos = ngx_cpymem (pos + (i) + 2, pos, 2);
e.pos = ngx_cpymem(tmp, pos + i + 2, 2);
e.pos = ngx_cpymem(pos + i + 2, pos, 2);
e.pos = ngx_cpymem(pos, tmp, 2);
}
@ -626,20 +607,17 @@ ngx_http_uwsgi_create_request (ngx_http_request_t * r)
#ifndef NGX_HAVE_LITTLE_ENDIAN
uwsgi_strlen = uwsgi_swap16(val_len);
#else
uwsgi_strlen = val_len;
uwsgi_strlen = (uint16_t) val_len;
#endif
e.pos = ngx_cpymem(e.pos, &uwsgi_strlen, 2);
e.pos += val_len;
e.ip += sizeof(uintptr_t);
}
b->last = e.pos;
}
if (uwcf->upstream.pass_request_headers) {
part = &r->headers_in.headers.part;
@ -660,7 +638,7 @@ ngx_http_uwsgi_create_request (ngx_http_request_t * r)
#ifndef NGX_HAVE_LITTLE_ENDIAN
uwsgi_strlen = uwsgi_swap16(5 + header[i].key.len);
#else
uwsgi_strlen = 5 + header[i].key.len;
uwsgi_strlen = (uint16_t) (5 + header[i].key.len);
#endif
b->last = ngx_cpymem(b->last, &uwsgi_strlen, 2);
b->last = ngx_cpymem(b->last, "HTTP_", 5);
@ -670,8 +648,7 @@ ngx_http_uwsgi_create_request (ngx_http_request_t * r)
if (ch >= 'a' && ch <= 'z') {
ch &= ~0x20;
}
else if (ch == '-') {
} else if (ch == '-') {
ch = '_';
}
@ -680,20 +657,17 @@ ngx_http_uwsgi_create_request (ngx_http_request_t * r)
#ifndef NGX_HAVE_LITTLE_ENDIAN
uwsgi_strlen = uwsgi_swap16 (header[i].value.len);
#else
uwsgi_strlen = header[i].value.len;
uwsgi_strlen = (uint16_t) header[i].value.len;
#endif
b->last = ngx_cpymem(b->last, &uwsgi_strlen, 2);
b->last =
ngx_copy(b->last, header[i].value.data, header[i].value.len);
}
}
if (uwcf->uwsgi_string.data && uwcf->uwsgi_string.len) {
b->last = ngx_copy(b->last, uwcf->uwsgi_string.data, uwcf->uwsgi_string.len);
b->last = ngx_copy(b->last, uwcf->uwsgi_string.data,
uwcf->uwsgi_string.len);
}
if (uwcf->upstream.pass_request_body) {
@ -721,8 +695,7 @@ ngx_http_uwsgi_create_request (ngx_http_request_t * r)
b->flush = 1;
}
else {
} else {
r->upstream->request_bufs = cl;
}
@ -735,19 +708,18 @@ ngx_http_uwsgi_create_request (ngx_http_request_t * r)
static ngx_int_t
ngx_http_uwsgi_reinit_request(ngx_http_request_t *r)
{
ngx_http_uwsgi_ctx_t *ctx;
ngx_http_uwsgi_ctx_t *s;
ctx = ngx_http_get_module_ctx(r, ngx_http_uwsgi_module);
s = ngx_http_get_module_ctx (r, ngx_http_uwsgi_module);
if (s == NULL) {
if (ctx == NULL) {
return NGX_OK;
}
s->status = 0;
s->status_count = 0;
s->status_start = NULL;
s->status_end = NULL;
ctx->status = 0;
ctx->status_count = 0;
ctx->status_start = NULL;
ctx->status_end = NULL;
r->upstream->process_header = ngx_http_uwsgi_process_status_line;
@ -793,7 +765,7 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
state = sw_H;
break;
default:
return NGX_HTTP_XCGI_PARSE_NO_HEADER;
return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
break;
@ -803,7 +775,7 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
state = sw_HT;
break;
default:
return NGX_HTTP_XCGI_PARSE_NO_HEADER;
return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
break;
@ -813,7 +785,7 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
state = sw_HTT;
break;
default:
return NGX_HTTP_XCGI_PARSE_NO_HEADER;
return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
break;
@ -823,7 +795,7 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
state = sw_HTTP;
break;
default:
return NGX_HTTP_XCGI_PARSE_NO_HEADER;
return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
break;
@ -833,14 +805,14 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
state = sw_first_major_digit;
break;
default:
return NGX_HTTP_XCGI_PARSE_NO_HEADER;
return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
break;
/* the first digit of major HTTP version */
case sw_first_major_digit:
if (ch < '1' || ch > '9') {
return NGX_HTTP_XCGI_PARSE_NO_HEADER;
return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
state = sw_major_digit;
@ -854,7 +826,7 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
}
if (ch < '0' || ch > '9') {
return NGX_HTTP_XCGI_PARSE_NO_HEADER;
return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
break;
@ -862,7 +834,7 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
/* the first digit of minor HTTP version */
case sw_first_minor_digit:
if (ch < '0' || ch > '9') {
return NGX_HTTP_XCGI_PARSE_NO_HEADER;
return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
state = sw_minor_digit;
@ -876,7 +848,7 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
}
if (ch < '0' || ch > '9') {
return NGX_HTTP_XCGI_PARSE_NO_HEADER;
return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
break;
@ -888,7 +860,7 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
}
if (ch < '0' || ch > '9') {
return NGX_HTTP_XCGI_PARSE_NO_HEADER;
return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
ctx->status = ctx->status * 10 + ch - '0';
@ -915,7 +887,7 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
case LF:
goto done;
default:
return NGX_HTTP_XCGI_PARSE_NO_HEADER;
return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
break;
@ -938,7 +910,7 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
case LF:
goto done;
default:
return NGX_HTTP_XCGI_PARSE_NO_HEADER;
return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
}
}
@ -983,7 +955,7 @@ ngx_http_uwsgi_process_status_line (ngx_http_request_t * r)
u = r->upstream;
if (rc == NGX_HTTP_XCGI_PARSE_NO_HEADER) {
if (rc == NGX_HTTP_UWSGI_PARSE_NO_HEADER) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"upstream sent no valid HTTP/1.0 header");
@ -1003,8 +975,7 @@ ngx_http_uwsgi_process_status_line (ngx_http_request_t * r)
u->headers_in.status_line.len = ctx->status_end - ctx->status_start;
u->headers_in.status_line.data = ngx_pnalloc(r->pool,
u->headers_in.
status_line.len);
u->headers_in.status_line.len);
if (u->headers_in.status_line.data == NULL) {
return NGX_ERROR;
}
@ -1051,8 +1022,8 @@ ngx_http_uwsgi_process_header (ngx_http_request_t * r)
h->value.len = r->header_end - r->header_start;
h->key.data = ngx_pnalloc(r->pool,
h->key.len + 1 + h->value.len + 1 +
h->key.len);
h->key.len + 1 + h->value.len + 1
+ h->key.len);
if (h->key.data == NULL) {
return NGX_ERROR;
}
@ -1066,8 +1037,7 @@ ngx_http_uwsgi_process_header (ngx_http_request_t * r)
if (h->key.len == r->lowcase_index) {
ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len);
}
else {
} else {
ngx_strlow(h->lowcase_key, h->key.data, h->key.len);
}
@ -1079,8 +1049,7 @@ ngx_http_uwsgi_process_header (ngx_http_request_t * r)
}
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"http uwsgi header: \"%V: %V\"",
&h->key, &h->value);
"http uwsgi header: \"%V: %V\"", &h->key, &h->value);
continue;
}
@ -1103,11 +1072,8 @@ ngx_http_uwsgi_process_header (ngx_http_request_t * r)
return NGX_ERROR;
}
h->hash =
ngx_hash (ngx_hash
(ngx_hash
(ngx_hash (ngx_hash ('s', 'e'), 'r'),
'v'), 'e'), 'r');
h->hash = ngx_hash(ngx_hash(ngx_hash(ngx_hash(
ngx_hash ('s', 'e'), 'r'), 'v'), 'e'), 'r');
h->key.len = sizeof("Server") - 1;
h->key.data = (u_char *) "Server";
@ -1300,23 +1266,23 @@ ngx_http_uwsgi_merge_loc_conf (ngx_conf_t * cf, void *parent, void *child)
if (conf->upstream.busy_buffers_size_conf == NGX_CONF_UNSET_SIZE) {
conf->upstream.busy_buffers_size = 2 * size;
}
else {
} else {
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,
"\"uwsgi_busy_buffers_size\" must be equal or bigger than "
"maximum of the value of \"uwsgi_buffer_size\" and "
"\"uwsgi_busy_buffers_size\" must be equal or bigger "
"than maximum of the value of \"uwsgi_buffer_size\" and "
"one of the \"uwsgi_buffers\"");
return NGX_CONF_ERROR;
}
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,
"\"uwsgi_busy_buffers_size\" must be less than "
"the size of all \"uwsgi_buffers\" minus one buffer");
@ -1331,8 +1297,7 @@ ngx_http_uwsgi_merge_loc_conf (ngx_conf_t * cf, void *parent, void *child)
if (conf->upstream.temp_file_write_size_conf == NGX_CONF_UNSET_SIZE) {
conf->upstream.temp_file_write_size = 2 * size;
}
else {
} else {
conf->upstream.temp_file_write_size =
conf->upstream.temp_file_write_size_conf;
}
@ -1353,8 +1318,7 @@ ngx_http_uwsgi_merge_loc_conf (ngx_conf_t * cf, void *parent, void *child)
if (conf->upstream.max_temp_file_size_conf == NGX_CONF_UNSET_SIZE) {
conf->upstream.max_temp_file_size = 1024 * 1024 * 1024;
}
else {
} else {
conf->upstream.max_temp_file_size =
conf->upstream.max_temp_file_size_conf;
}
@ -1389,7 +1353,9 @@ ngx_http_uwsgi_merge_loc_conf (ngx_conf_t * cf, void *parent, void *child)
if (ngx_conf_merge_path_value(cf, &conf->upstream.temp_path,
prev->upstream.temp_path,
&ngx_http_uwsgi_temp_path) != NGX_OK) {
&ngx_http_uwsgi_temp_path)
!= NGX_OK)
{
return NGX_CONF_ERROR;
}
@ -1409,8 +1375,9 @@ ngx_http_uwsgi_merge_loc_conf (ngx_conf_t * cf, void *parent, void *child)
if (ngx_http_upstream_hide_headers_hash(cf, &conf->upstream,
&prev->upstream,
ngx_http_uwsgi_hide_headers,
&hash) != NGX_OK) {
ngx_http_uwsgi_hide_headers, &hash)
!= NGX_OK)
{
return NGX_CONF_ERROR;
}
@ -1466,7 +1433,6 @@ ngx_http_uwsgi_merge_loc_conf (ngx_conf_t * cf, void *parent, void *child)
ngx_http_script_copy_len_code;
copy->len = src[i].key.len;
copy = ngx_array_push_n(conf->params_len,
sizeof(ngx_http_script_copy_code_t));
if (copy == NULL) {
@ -1495,8 +1461,7 @@ ngx_http_uwsgi_merge_loc_conf (ngx_conf_t * cf, void *parent, void *child)
p = ngx_cpymem(p, src[i].key.data, src[i].key.len);
ngx_memcpy(p, src[i].value.data, src[i].value.len);
}
else {
} else {
copy = ngx_array_push_n(conf->params_len,
sizeof(ngx_http_script_copy_code_t));
if (copy == NULL) {
@ -1624,6 +1589,7 @@ ngx_http_uwsgi_pass (ngx_conf_t * cf, ngx_command_t * cmd, void *conf)
return NGX_CONF_OK;
}
static char *
ngx_http_uwsgi_modifier1(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
@ -1637,6 +1603,7 @@ ngx_http_uwsgi_modifier1 (ngx_conf_t * cf, ngx_command_t * cmd, void *conf)
return NGX_CONF_OK;
}
static char *
ngx_http_uwsgi_modifier2(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
@ -1648,6 +1615,5 @@ ngx_http_uwsgi_modifier2 (ngx_conf_t * cf, ngx_command_t * cmd, void *conf)
uwcf->modifier2 = (u_char) ngx_atoi(value[1].data, value[1].len);
return NGX_CONF_OK;
}