aboutsummaryrefslogtreecommitdiff
path: root/src/http
diff options
context:
space:
mode:
Diffstat (limited to 'src/http')
-rw-r--r--src/http/modules/ngx_http_dav_module.c6
-rw-r--r--src/http/modules/ngx_http_fastcgi_module.c9
-rw-r--r--src/http/modules/ngx_http_static_module.c8
-rw-r--r--src/http/modules/perl/ngx_http_perl_module.c6
-rw-r--r--src/http/ngx_http_parse.c16
-rw-r--r--src/http/ngx_http_request.c24
6 files changed, 40 insertions, 29 deletions
diff --git a/src/http/modules/ngx_http_dav_module.c b/src/http/modules/ngx_http_dav_module.c
index e60b8cf34..b41bd8e46 100644
--- a/src/http/modules/ngx_http_dav_module.c
+++ b/src/http/modules/ngx_http_dav_module.c
@@ -116,10 +116,6 @@ ngx_http_dav_handler(ngx_http_request_t *r)
return NGX_DECLINED;
}
- if (r->headers_in.content_length_n < 0) {
- return NGX_HTTP_BAD_REQUEST;
- }
-
r->request_body_in_file_only = 1;
r->request_body_in_persistent_file = 1;
r->request_body_delete_incomplete_file = 1;
@@ -312,6 +308,8 @@ ok:
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
return;
}
+
+ r->headers_out.content_length_n = 0;
}
r->headers_out.status = status;
diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c
index f901a5223..ff5511804 100644
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -1173,6 +1173,11 @@ ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
if (f->type == NGX_HTTP_FASTCGI_STDERR) {
if (f->length) {
+
+ if (f->pos == f->last) {
+ break;
+ }
+
line.data = f->pos;
if (f->pos + f->length <= f->last) {
@@ -1212,6 +1217,10 @@ ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
/* f->type == NGX_HTTP_FASTCGI_STDOUT */
+ if (f->pos == f->last) {
+ break;
+ }
+
if (p->free) {
b = p->free->buf;
p->free = p->free->next;
diff --git a/src/http/modules/ngx_http_static_module.c b/src/http/modules/ngx_http_static_module.c
index 0dbec5093..3399e5098 100644
--- a/src/http/modules/ngx_http_static_module.c
+++ b/src/http/modules/ngx_http_static_module.c
@@ -86,6 +86,10 @@ ngx_http_static_handler(ngx_http_request_t *r)
ngx_pool_cleanup_file_t *clnf;
ngx_http_core_loc_conf_t *clcf;
+ if (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) {
+ return NGX_HTTP_NOT_ALLOWED;
+ }
+
if (r->uri.data[r->uri.len - 1] == '/') {
return NGX_DECLINED;
}
@@ -95,10 +99,6 @@ ngx_http_static_handler(ngx_http_request_t *r)
return NGX_DECLINED;
}
- if (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) {
- return NGX_HTTP_NOT_ALLOWED;
- }
-
rc = ngx_http_discard_body(r);
if (rc != NGX_OK && rc != NGX_AGAIN) {
diff --git a/src/http/modules/perl/ngx_http_perl_module.c b/src/http/modules/perl/ngx_http_perl_module.c
index 136bac397..aa0e41d25 100644
--- a/src/http/modules/perl/ngx_http_perl_module.c
+++ b/src/http/modules/perl/ngx_http_perl_module.c
@@ -483,8 +483,10 @@ ngx_http_perl_init_interpreter(ngx_conf_t *cf, ngx_http_perl_main_conf_t *pmcf)
}
#endif
- if (ngx_conf_full_name(cf->cycle, &pmcf->modules) != NGX_OK) {
- return NGX_CONF_ERROR;
+ if (pmcf->modules.data) {
+ if (ngx_conf_full_name(cf->cycle, &pmcf->modules) != NGX_OK) {
+ return NGX_CONF_ERROR;
+ }
}
PERL_SYS_INIT(&ngx_argc, &ngx_argv);
diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c
index 11c163290..1b1e963ad 100644
--- a/src/http/ngx_http_parse.c
+++ b/src/http/ngx_http_parse.c
@@ -67,17 +67,18 @@ ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b)
r->method_end = p - 1;
m = r->request_start;
- if (p - m == 3) {
+ switch (p - m) {
+ case 3:
if (m[0] == 'G' && m[1] == 'E' && m[2] == 'T') {
r->method = NGX_HTTP_GET;
} else if (m[0] == 'P' && m[1] == 'U' && m[2] == 'T') {
r->method = NGX_HTTP_PUT;
}
+ break;
- } else if (p - m == 4) {
-
+ case 4:
if (m[0] == 'P' && m[1] == 'O'
&& m[2] == 'S' && m[3] == 'T')
{
@@ -88,22 +89,23 @@ ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b)
{
r->method = NGX_HTTP_HEAD;
}
+ break;
- } else if (p - m == 5) {
-
+ case 5:
if (m[0] == 'M' && m[1] == 'K'
&& m[2] == 'C' && m[3] == 'O' && m[4] == 'L')
{
r->method = NGX_HTTP_MKCOL;
}
+ break;
- } else if (p - m == 6) {
-
+ case 6:
if (m[0] == 'D' && m[1] == 'E' && m[2] == 'L'
&& m[3] == 'E' && m[4] == 'T' && m[5] == 'E')
{
r->method = NGX_HTTP_DELETE;
}
+ break;
}
state = sw_spaces_before_uri;
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 6bbaf446a..615ae7511 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1218,7 +1218,9 @@ ngx_http_process_request_header(ngx_http_request_t *r)
}
}
- if (r->method == NGX_HTTP_POST && r->headers_in.content_length_n == -1) {
+ if (r->method & (NGX_HTTP_POST|NGX_HTTP_PUT)
+ && r->headers_in.content_length_n == -1)
+ {
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
"client sent POST method without \"Content-Length\" header");
ngx_http_finalize_request(r, NGX_HTTP_LENGTH_REQUIRED);
@@ -1432,7 +1434,6 @@ ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
}
ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc));
-
return;
}
@@ -2154,19 +2155,11 @@ ngx_http_post_action(ngx_http_request_t *r)
static void
ngx_http_close_request(ngx_http_request_t *r, ngx_int_t error)
{
- ngx_connection_t *c;
- ngx_http_cleanup_t *cln;
+ ngx_connection_t *c;
c = r->connection;
- r = r->main;
-
- for (cln = r->cleanup; cln; cln = cln->next) {
- if (cln->handler) {
- cln->handler(cln->data);
- }
- }
- ngx_http_request_done(r, error);
+ ngx_http_request_done(r->main, error);
ngx_http_close_connection(c);
}
@@ -2177,6 +2170,7 @@ ngx_http_request_done(ngx_http_request_t *r, ngx_int_t error)
ngx_log_t *log;
ngx_uint_t i, n;
struct linger linger;
+ ngx_http_cleanup_t *cln;
ngx_http_log_ctx_t *ctx;
ngx_http_handler_pt *log_handler;
ngx_http_core_loc_conf_t *clcf;
@@ -2191,6 +2185,12 @@ ngx_http_request_done(ngx_http_request_t *r, ngx_int_t error)
return;
}
+ for (cln = r->cleanup; cln; cln = cln->next) {
+ if (cln->handler) {
+ cln->handler(cln->data);
+ }
+ }
+
#if (NGX_STAT_STUB)
if (r->stat_reading) {