summaryrefslogtreecommitdiffhomepage
path: root/src/http/ngx_http_request_body.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2005-03-19 12:38:37 +0000
committerIgor Sysoev <igor@sysoev.ru>2005-03-19 12:38:37 +0000
commitc15717285d2157a603bb1b130b26d7baa549be7e (patch)
tree56dc8346b22bb2660eecd3bc086d263ac6d67326 /src/http/ngx_http_request_body.c
parente12fbfe82a176cd386cdcecfeabf43ac8fd870a4 (diff)
downloadnginx-release-0.1.25.tar.gz
nginx-release-0.1.25.tar.bz2
nginx-0.1.25-RELEASE importrelease-0.1.25
*) Bugfix: nginx did run on Linux parisc. *) Feature: nginx now does not start under FreeBSD if the sysctl kern.ipc.somaxconn value is too big. *) Bugfix: if a request was internally redirected by the ngx_http_index_module module to the ngx_http_proxy_module or ngx_http_fastcgi_module modules, then the index file was not closed after request completion. *) Feature: the "proxy_pass" can be used in location with regular expression. *) Feature: the ngx_http_rewrite_filter_module module supports the condition like "if ($HTTP_USER_AGENT ~ MSIE)". *) Bugfix: nginx started too slow if the large number of addresses and text values were used in the "geo" directive. *) Change: a variable name must be declared as "$name" in the "geo" directive. The previous variant without "$" is still supported, but will be removed soon. *) Feature: the "%{VARIABLE}v" logging parameter. *) Feature: the "set $name value" directive. *) Bugfix: gcc 4.0 compatibility. *) Feature: the --with-openssl-opt=OPTIONS autoconfiguration directive.
Diffstat (limited to '')
-rw-r--r--src/http/ngx_http_request_body.c54
1 files changed, 38 insertions, 16 deletions
diff --git a/src/http/ngx_http_request_body.c b/src/http/ngx_http_request_body.c
index 59f72208d..eeffd8afd 100644
--- a/src/http/ngx_http_request_body.c
+++ b/src/http/ngx_http_request_body.c
@@ -12,7 +12,7 @@
static void ngx_http_read_client_request_body_handler(ngx_event_t *rev);
static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r,
- ngx_connection_t *c);
+ ngx_connection_t *c);
/*
* on completion ngx_http_read_client_request_body() adds to
@@ -21,22 +21,35 @@ static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r,
* *) one memory or file buf that contains the rest of the body
*/
-ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r,
- ngx_http_client_body_handler_pt post_handler)
+ngx_int_t
+ngx_http_read_client_request_body(ngx_http_request_t *r,
+ ngx_http_client_body_handler_pt post_handler)
{
ssize_t size;
ngx_buf_t *b;
ngx_chain_t *cl;
+ ngx_connection_t *c;
ngx_http_request_body_t *rb;
ngx_http_core_loc_conf_t *clcf;
- if (!(rb = ngx_pcalloc(r->pool, sizeof(ngx_http_request_body_t)))) {
+ rb = ngx_pcalloc(r->pool, sizeof(ngx_http_request_body_t));
+ if (rb == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
r->request_body = rb;
+ /* STUB */
+ if (r->file.fd != NGX_INVALID_FILE) {
+ if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR) {
+ ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno,
+ ngx_close_file_n " \"%V\" failed", &r->file.name);
+ }
+ r->file.fd = NGX_INVALID_FILE;
+ }
+ /**/
+
if (r->headers_in.content_length_n <= 0) {
post_handler(r);
return NGX_OK;
@@ -58,7 +71,8 @@ ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r,
/* there is the pre-read part of the request body */
- if (!(b = ngx_calloc_buf(r->pool))) {
+ b = ngx_calloc_buf(r->pool);
+ if (b == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
@@ -66,7 +80,8 @@ ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r,
b->start = b->pos = r->header_in->pos;
b->end = b->last = r->header_in->last;
- if (!(rb->bufs = ngx_alloc_chain_link(r->pool))) {
+ rb->bufs = ngx_alloc_chain_link(r->pool);
+ if (rb->bufs == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
@@ -103,11 +118,13 @@ ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r,
size = clcf->client_body_buffer_size;
}
- if (!(rb->buf = ngx_create_temp_buf(r->pool, size))) {
+ rb->buf = ngx_create_temp_buf(r->pool, size);
+ if (rb->buf == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
- if (!(cl = ngx_alloc_chain_link(r->pool))) {
+ cl = ngx_alloc_chain_link(r->pool);
+ if (cl == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
@@ -121,14 +138,16 @@ ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r,
rb->bufs = cl;
}
- r->connection->read->event_handler =
- ngx_http_read_client_request_body_handler;
+ c = r->connection;
- return ngx_http_do_read_client_request_body(r, r->connection);
+ c->read->event_handler = ngx_http_read_client_request_body_handler;
+
+ return ngx_http_do_read_client_request_body(r, c);
}
-static void ngx_http_read_client_request_body_handler(ngx_event_t *rev)
+static void
+ngx_http_read_client_request_body_handler(ngx_event_t *rev)
{
ngx_int_t rc;
ngx_connection_t *c;
@@ -150,8 +169,9 @@ static void ngx_http_read_client_request_body_handler(ngx_event_t *rev)
}
-static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r,
- ngx_connection_t *c)
+static ngx_int_t
+ngx_http_do_read_client_request_body(ngx_http_request_t *r,
+ ngx_connection_t *c)
{
size_t size;
ssize_t n;
@@ -169,7 +189,8 @@ static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r,
if (rb->buf->last == rb->buf->end) {
if (rb->temp_file == NULL) {
- if (!(tf = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t)))) {
+ tf = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t));
+ if (tf == NULL) {
return NGX_ERROR;
}
@@ -268,7 +289,8 @@ static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r,
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
- if (!(b = ngx_calloc_buf(r->pool))) {
+ b = ngx_calloc_buf(r->pool);
+ if (b == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}