]> git.kaiwu.me - nginx.git/commitdiff
nginx-0.0.3-2004-03-23-09:01:52 import
authorIgor Sysoev <igor@sysoev.ru>
Tue, 23 Mar 2004 06:01:52 +0000 (06:01 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Tue, 23 Mar 2004 06:01:52 +0000 (06:01 +0000)
20 files changed:
src/core/ngx_hunk.h
src/core/ngx_output_chain.c
src/core/ngx_regex.c
src/event/ngx_event_pipe.c
src/http/modules/ngx_http_gzip_filter.c
src/http/modules/ngx_http_static_handler.c
src/http/modules/proxy/ngx_http_proxy_handler.h
src/http/modules/proxy/ngx_http_proxy_header.c
src/http/modules/proxy/ngx_http_proxy_upstream.c
src/http/ngx_http_core_module.c
src/http/ngx_http_header_filter.c
src/http/ngx_http_headers.c
src/http/ngx_http_log_handler.c
src/http/ngx_http_output_filter.c
src/http/ngx_http_request.c
src/http/ngx_http_request.h
src/http/ngx_http_request_body.c
src/http/ngx_http_special_response.c
src/os/win32/ngx_socket.h
src/os/win32/ngx_win32_config.h

index ab32e45fb43751d120978e1baf48bc90e7a37380..afeca1e93b096c45f8ba5432ed73729769477b2e 100644 (file)
@@ -92,7 +92,7 @@ typedef struct {
     ngx_hunk_tag_t               tag;
 
     ngx_output_chain_filter_pt   output_filter;
-    void                        *output_ctx;
+    void                        *filter_ctx;
 } ngx_output_chain_ctx_t;
 
 
index 55c4a50a39ebd8126d04cf32f0fc1c8bc6a0d3a4..285bd834035c8e5dcdcfd3f3203c3573387d130c 100644 (file)
@@ -28,13 +28,13 @@ int ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
     if (ctx->in == NULL) {
 
         if (in == NULL) {
-            return ctx->output_filter(ctx->output_ctx, in);
+            return ctx->output_filter(ctx->filter_ctx, in);
         }
 
         if (in->next == NULL
             && (!ngx_output_chain_need_to_copy(ctx, in->hunk)))
         {
-            return ctx->output_filter(ctx->output_ctx, in);
+            return ctx->output_filter(ctx->filter_ctx, in);
         }
     }
 
@@ -153,7 +153,7 @@ int ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
             return last;
         }
 
-        last = ctx->output_filter(ctx->output_ctx, out);
+        last = ctx->output_filter(ctx->filter_ctx, out);
 
         ngx_chain_update_chains(&ctx->free, &ctx->busy, &out, ctx->tag);
         last_out = &out;
index 1627f9fa6899e90e9c66b48e4a9fd278eafc65a3..617fddcbb91bfedbe92d0e5e9c337e50bc3a1f19 100644 (file)
@@ -42,6 +42,10 @@ ngx_regex_t *ngx_regex_compile(ngx_str_t *pattern, ngx_int_t options,
         }
     }
 
+    /* ensure that there is no current pool */
+
+    ngx_pcre_pool = NULL;
+
     return re;
 }
 
@@ -64,7 +68,11 @@ ngx_int_t ngx_regex_exec(ngx_regex_t *re, ngx_str_t *s,
 
 static void *ngx_regex_malloc(size_t size)
 {
-    return ngx_palloc(ngx_pcre_pool, size);
+    if (ngx_pcre_pool) {
+        return ngx_palloc(ngx_pcre_pool, size);
+    }
+
+    return NULL;
 }
 
 
index b7cb6b6ae9489bc8f940e3c9a6a177a6b6e548ec..f2545171a19aac5357b3eafef614426a50c6149c 100644 (file)
@@ -377,12 +377,16 @@ int ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p)
         bsize = 0;
         to_write = 0;
 
+#if 0
         if (!(p->upstream_eof || p->upstream_error || p->upstream_done)) {
+#endif
             for (cl = p->busy; cl; cl = cl->next) {
                 bsize += cl->hunk->end - cl->hunk->start;
                 to_write += ngx_hunk_size(cl->hunk);
             }
+#if 0
         }
+#endif
 
         out = NULL;
         ll = NULL;
@@ -391,11 +395,17 @@ int ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p)
             if (p->out) {
                 cl = p->out;
 
+#if 0
                 if (!(p->upstream_eof || p->upstream_error || p->upstream_done)
                     && (bsize + ngx_hunk_size(cl->hunk) > p->busy_size))
                 {
                     break;
                 }
+#else
+                if (bsize + ngx_hunk_size(cl->hunk) > p->busy_size) {
+                    break;
+                }
+#endif
 
                 p->out = p->out->next;
                 ngx_event_pipe_free_shadow_raw_hunk(&p->free_raw_hunks,
@@ -404,11 +414,17 @@ int ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p)
             } else if (!p->cachable && p->in) {
                 cl = p->in;
 
+#if 0
                 if (!(p->upstream_eof || p->upstream_error || p->upstream_done)
                     && (bsize + ngx_hunk_size(cl->hunk) > p->busy_size))
                 {
                     break;
                 }
+#else
+                if (bsize + ngx_hunk_size(cl->hunk) > p->busy_size) {
+                    break;
+                }
+#endif
 
                 p->in = p->in->next;
 
index a1cbfb042f7724f674750f76b68a5f91c6713ba5..a1640bd2c6b1f81f6b8e2e36d85d247b381a81de 100644 (file)
@@ -32,7 +32,7 @@ typedef struct {
 
     void                *preallocated;
     char                *free_mem;
-    int                  allocated;
+    ngx_uint_t           allocated;
 
     unsigned             flush:4;
     unsigned             redo:1;
@@ -515,8 +515,8 @@ static void *ngx_http_gzip_filter_alloc(void *opaque, u_int items, u_int size)
 {
     ngx_http_gzip_ctx_t *ctx = opaque;
 
-    int    alloc;
-    void  *p;
+    void        *p;
+    ngx_uint_t   alloc;
 
     alloc = items * size;
     if (alloc % 512 != 0) {
@@ -533,7 +533,7 @@ static void *ngx_http_gzip_filter_alloc(void *opaque, u_int items, u_int size)
         ctx->allocated -= alloc;
 
         ngx_log_debug4(NGX_LOG_DEBUG_HTTP, ctx->request->connection->log, 0,
-                       "gzip alloc: n:%d s:%d a:%d p:%08X",
+                       "gzip alloc: n:%d s:%d a:%d p:" PTR_FMT,
                        items, size, alloc, p);
 
         return p;
index 0576255eba99b4dee2770d4cab8e3c84761d2a55..ae1b8170dc8052fc246b8057f72de54351a566f7 100644 (file)
@@ -89,7 +89,7 @@ static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r)
 
     rc = ngx_http_discard_body(r);
 
-    if (rc != NGX_OK) {
+    if (rc != NGX_OK && rc != NGX_AGAIN) {
         return rc;
     }
 
index ee95f1b44212875bc1bb97d311e6063eab91f72a..210ca89f8b173dabd31349c36710b0a615b759fb 100644 (file)
@@ -108,7 +108,7 @@ typedef struct {
 
 
 typedef struct {
-    ngx_table_t                     *headers;   /* it must be first field */
+    ngx_table_t                      headers;   /* it must be first field */
 
     ngx_table_elt_t                 *date;
     ngx_table_elt_t                 *server;
index 66a6bfe013f15343652c488c273baa834285847f..8c24a065ef1a2bdce4756eebc083b54e37cabc64 100644 (file)
@@ -17,8 +17,8 @@ int ngx_http_proxy_copy_header(ngx_http_proxy_ctx_t *p,
 
     r = p->request;
 
-    h = headers_in->headers->elts;
-    for (i = 0; i < headers_in->headers->nelts; i++) {
+    h = headers_in->headers.elts;
+    for (i = 0; i < headers_in->headers.nelts; i++) {
 
         if (&h[i] == headers_in->connection) {
             continue;
@@ -98,37 +98,43 @@ static int ngx_http_proxy_rewrite_location_header(ngx_http_proxy_ctx_t *p,
                                                   ngx_table_elt_t *loc)
 {
     u_char                          *last;
+    ngx_table_elt_t                 *location;
     ngx_http_request_t              *r;
     ngx_http_proxy_upstream_conf_t  *uc;
 
     r = p->request;
     uc = p->lcf->upstream;
 
-    r->headers_out.location = ngx_http_add_header(&r->headers_out,
-                                                  ngx_http_headers_out);
-    if (r->headers_out.location == NULL) {
+    location = ngx_http_add_header(&r->headers_out, ngx_http_headers_out);
+    if (location == NULL) {
         return NGX_ERROR;
     }
 
+    /*
+     * we do not set r->headers_out.location to avoid the handling
+     * the local redirects without a host name by ngx_http_header_filter()
+     */
+
+#if 0
+    r->headers_out.location = location;
+#endif
+
     if (uc->url.len > loc->value.len
         || ngx_rstrncmp(loc->value.data, uc->url.data, uc->url.len) != 0)
     {
-        *r->headers_out.location = *loc;
+        *location = *loc;
         return NGX_OK;
     }
 
     /* TODO: proxy_reverse */
 
-    r->headers_out.location->value.len = uc->location->len
-                                         + (loc->value.len - uc->url.len) + 1;
-    r->headers_out.location->value.data =
-                       ngx_palloc(r->pool, r->headers_out.location->value.len);
-
-    if (r->headers_out.location->value.data == NULL) {
+    location->value.len = uc->location->len
+                                          + (loc->value.len - uc->url.len) + 1;
+    if (!(location->value.data = ngx_palloc(r->pool, location->value.len))) {
         return NGX_ERROR;
     }
 
-    last = ngx_cpymem(r->headers_out.location->value.data,
+    last = ngx_cpymem(location->value.data,
                       uc->location->data, uc->location->len);
 
     ngx_cpystrn(last, loc->value.data + uc->url.len,
index d72f09e0be65b6c01985b9a59a920bc2893bda96..68c9574083a303205c61504a229e6fe84d730a8d 100644 (file)
@@ -148,8 +148,8 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p)
     }
 
 
-    header = (ngx_table_elt_t *) r->headers_in.headers->elts;
-    for (i = 0; i < r->headers_in.headers->nelts; i++) {
+    header = r->headers_in.headers.elts;
+    for (i = 0; i < r->headers_in.headers.nelts; i++) {
 
         if (&header[i] == r->headers_in.host) {
             continue;
@@ -198,7 +198,7 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p)
 
     h->last = ngx_cpymem(h->last, host_header, sizeof(host_header) - 1);
 
-    if (p->lcf->preserve_host) {
+    if (p->lcf->preserve_host && r->headers_in.host) {
         h->last = ngx_cpymem(h->last, r->headers_in.host->value.data,
                              r->headers_in.host_name_len);
 
@@ -250,7 +250,7 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p)
     }
 
 
-    for (i = 0; i < r->headers_in.headers->nelts; i++) {
+    for (i = 0; i < r->headers_in.headers.nelts; i++) {
 
         if (&header[i] == r->headers_in.host) {
             continue;
@@ -377,7 +377,7 @@ static void ngx_http_proxy_init_upstream(void *data)
         return;
     }
 
-    output->output_ctx = writer;
+    output->filter_ctx = writer;
     writer->pool = r->pool;
 
     if (p->lcf->busy_lock && !p->busy_locked) {
@@ -392,7 +392,6 @@ static void ngx_http_proxy_reinit_upstream(ngx_http_proxy_ctx_t *p)
 {
     ngx_chain_t             *cl;
     ngx_output_chain_ctx_t  *output;
-    ngx_chain_writer_ctx_t  *writer;
 
     output = p->upstream->output_chain_ctx;
 
@@ -400,6 +399,7 @@ static void ngx_http_proxy_reinit_upstream(ngx_http_proxy_ctx_t *p)
 
     for (cl = p->request->request_hunks; cl; cl = cl->next) {
         cl->hunk->pos = cl->hunk->start;
+        cl->hunk->file_pos = 0;
     }
 
     /* reinit the ngx_output_chain() context */
@@ -521,7 +521,7 @@ static void ngx_http_proxy_connect(ngx_http_proxy_ctx_t *p)
     /* init or reinit the ngx_output_chain() and ngx_chain_writer() contexts */
 
     output = p->upstream->output_chain_ctx;
-    writer = output->output_ctx;
+    writer = output->filter_ctx;
     writer->out = NULL;
     writer->last = &writer->out;
     writer->connection = c;
@@ -541,7 +541,6 @@ static void ngx_http_proxy_connect(ngx_http_proxy_ctx_t *p)
         output->hunks = 1;
 
         r->request_body_hunk->pos = r->request_body_hunk->start;
-        r->request_body_hunk->last = r->request_body_hunk->start;
     }
 
     p->request_sent = 0;
@@ -824,14 +823,26 @@ static void ngx_http_proxy_process_upstream_status_line(ngx_event_t *rev)
                    "http proxy status %d \"%s\"",
                    p->upstream->status, p->upstream->status_line.data);
 
-    if (p->upstream->headers_in.headers) {
-        p->upstream->headers_in.headers->nelts = 0;
+
+    /* init or reinit the p->upstream->headers_in.headers table */
+
+    if (p->upstream->headers_in.headers.elts) {
+        p->upstream->headers_in.headers.nelts = 0;
+
     } else {
-        /* TODO: ngx_init_table */
-        p->upstream->headers_in.headers = ngx_create_table(p->request->pool,
-                                                           20);
+        p->upstream->headers_in.headers.elts = ngx_pcalloc(p->request->pool,
+                                                 20 * sizeof(ngx_table_elt_t));
+        if (p->upstream->headers_in.headers.elts == NULL) {
+            ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
+            return;
+        }
+        /* p->upstream->headers_in.headers.nelts = 0; */
+        p->upstream->headers_in.headers.nalloc = 20;
+        p->upstream->headers_in.headers.size = sizeof(ngx_table_elt_t);
+        p->upstream->headers_in.headers.pool = p->request->pool;
     }
 
+
     c->read->event_handler = ngx_http_proxy_process_upstream_headers;
     ngx_http_proxy_process_upstream_headers(rev);
 }
index e3c85986cde4b9c2ab9f312e8dd1e8a0828f56f8..f3f47f8e31b74694850a0a07327416066e47d617 100644 (file)
@@ -537,6 +537,25 @@ int ngx_http_find_location_config(ngx_http_request_t *r)
         r->connection->tcp_nopush = -1;
     }
 
+
+    ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+                   "http cl: " SIZE_T_FMT " max: " SIZE_T_FMT,
+                   r->headers_in.content_length_n,
+                   clcf->client_max_body_size);
+
+    if (r->headers_in.content_length_n != -1
+        && clcf->client_max_body_size
+        && clcf->client_max_body_size < (size_t) r->headers_in.content_length_n)
+    {
+        ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+                      "client intented to send too large body: "
+                      SIZE_T_FMT " bytes",
+                      r->headers_in.content_length_n);
+
+        return NGX_HTTP_REQUEST_ENTITY_TOO_LARGE;
+    }
+
+
     if (auto_redirect) {
         if (!(r->headers_out.location =
                    ngx_http_add_header(&r->headers_out, ngx_http_headers_out)))
index d399daae13fd31786ecb3fb9598633ff3e3c404d..e3bc734d6c94714a6bf222147de86dd6792ea2c9 100644 (file)
@@ -205,8 +205,8 @@ static int ngx_http_header_filter(ngx_http_request_t *r)
         len += sizeof("Connection: closed" CRLF) - 1;
     }
 
-    header = r->headers_out.headers->elts;
-    for (i = 0; i < r->headers_out.headers->nelts; i++) {
+    header = r->headers_out.headers.elts;
+    for (i = 0; i < r->headers_out.headers.nelts; i++) {
         if (header[i].key.len == 0) {
             continue;
         }
@@ -321,7 +321,7 @@ static int ngx_http_header_filter(ngx_http_request_t *r)
                              sizeof("Connection: close" CRLF) - 1);
     }
 
-    for (i = 0; i < r->headers_out.headers->nelts; i++) {
+    for (i = 0; i < r->headers_out.headers.nelts; i++) {
         if (header[i].key.len == 0) {
             continue;
         }
index 900323a969374f49ac997c1f724144250097a19d..57413afaea99370f1241f8f5dd58153ba73a058c 100644 (file)
@@ -60,12 +60,12 @@ ngx_http_header_t  ngx_http_headers_out[] = {
 ngx_table_elt_t *ngx_http_add_header(void *header,
                                      ngx_http_header_t *http_headers)
 {
-    char             *prev;
+    void             *prev;
     ngx_uint_t        i, j;
     ngx_table_t      *headers;
     ngx_table_elt_t  *h, *new;
 
-    headers = *(ngx_table_t **) header;
+    headers = header;
 
     prev = headers->elts;
 
index 3edb55b54e5db156f303354b797b3af18189c9ef..908d6fcdf958edc2a9a6073c72b79b4a7bf668bc 100644 (file)
@@ -327,8 +327,8 @@ static u_char *ngx_http_log_unknown_header_in(ngx_http_request_t *r,
 
     s = (ngx_str_t *) data;
 
-    h = r->headers_in.headers->elts;
-    for (i = 0; i < r->headers_in.headers->nelts; i++) {
+    h = r->headers_in.headers.elts;
+    for (i = 0; i < r->headers_in.headers.nelts; i++) {
         if (h[i].key.len != s->len) {
             continue;
         }
@@ -535,8 +535,8 @@ static u_char *ngx_http_log_unknown_header_out(ngx_http_request_t *r,
 
     s = (ngx_str_t *) data;
 
-    h = r->headers_out.headers->elts;
-    for (i = 0; i < r->headers_out.headers->nelts; i++) {
+    h = r->headers_out.headers.elts;
+    for (i = 0; i < r->headers_out.headers.nelts; i++) {
         if (h[i].key.len != s->len) {
             continue;
         }
index f6cc85d12c474babf79a435f7a11302506601faa..9b871749ef236b2bbe70781504b850bc8f4e9b29 100644 (file)
@@ -77,7 +77,7 @@ int ngx_http_output_filter(ngx_http_request_t *r, ngx_chain_t *in)
 
         ctx->output_filter = (ngx_output_chain_filter_pt)
                                                       ngx_http_top_body_filter;
-        ctx->output_ctx = r;
+        ctx->filter_ctx = r;
 
     }
 
index 1e65a47bb90b71039c1015092954a4212cb7ed66..6562c8d52ea623e9060f94adec3277558f7e7425 100644 (file)
@@ -38,8 +38,7 @@ static char *client_header_errors[] = {
     "client %s sent invalid header, URL: %s",
     "client %s sent too long header line, URL: %s",
     "client %s sent HTTP/1.1 request without \"Host\" header, URL: %s",
-    "client %s sent invalid \"Content-Length\" header, URL: %s",
-    "client %s wanted to send too large body: " SIZE_T_FMT " bytes, URL: %s"
+    "client %s sent invalid \"Content-Length\" header, URL: %s"
 };
 
 
@@ -248,12 +247,21 @@ static void ngx_http_init_request(ngx_event_t *rev)
     r->cleanup.size = sizeof(ngx_http_cleanup_t);
     r->cleanup.pool = r->pool;
 
-    /* TODO: ngx_init_table */
-    if (!(r->headers_out.headers = ngx_create_table(r->pool, 20))) {
+
+    /* init the r->headers_out.headers table */
+
+    r->headers_out.headers.elts = ngx_pcalloc(r->pool,
+                                              20 * sizeof(ngx_table_elt_t));
+    if (r->headers_out.headers.elts == NULL) {
         ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
         ngx_http_close_connection(c);
         return;
     }
+    /* r->headers_out.headers.nelts = 0; */
+    r->headers_out.headers.nalloc = 20;
+    r->headers_out.headers.size = sizeof(ngx_table_elt_t);
+    r->headers_out.headers.pool = r->pool;
+
 
     r->ctx = ngx_pcalloc(r->pool, sizeof(void *) * ngx_http_max_module);
     if (r->ctx == NULL) {
@@ -469,11 +477,26 @@ static void ngx_http_process_request_line(ngx_event_t *rev)
             return;
         }
 
+
+        /* init the r->headers_in.headers table */
+
+        r->headers_in.headers.elts = ngx_pcalloc(r->pool,
+                                                 20 * sizeof(ngx_table_elt_t));
+        if (r->headers_in.headers.elts == NULL) {
+            ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
+            ngx_http_close_connection(c);
+            return;
+        }
+
+        /* r->headers_in.headers.elts = NULL; */
+        /* r->headers_in.headers.nelts = 0; */
+        r->headers_in.headers.size = sizeof(ngx_table_elt_t);
+        r->headers_in.headers.nalloc = 20;
+        r->headers_in.headers.pool = r->pool;
+
         ctx = c->log->data;
         ctx->action = "reading client request headers";
         ctx->url = r->unparsed_uri.data;
-        /* TODO: ngx_init_table */
-        r->headers_in.headers = ngx_create_table(r->pool, 20);
 
         if (cscf->large_client_header
             && r->header_in->pos == r->header_in->last)
@@ -848,21 +871,6 @@ static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r)
         if (r->headers_in.content_length_n == NGX_ERROR) {
             return NGX_HTTP_PARSE_INVALID_CL_HEADER;
         }
-
-        clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
-
-        ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
-                       "http cl: " SIZE_T_FMT " max: " SIZE_T_FMT,
-                       r->headers_in.content_length_n,
-                       clcf->client_max_body_size);
-
-        if (clcf->client_max_body_size
-            && clcf->client_max_body_size
-                                     < (size_t) r->headers_in.content_length_n)
-        {
-            return NGX_HTTP_PARSE_ENTITY_TOO_LARGE;
-        }
-
     }
 
     if (r->headers_in.connection) {
@@ -913,6 +921,12 @@ void ngx_http_finalize_request(ngx_http_request_t *r, int rc)
             ngx_del_timer(r->connection->write);
         }
 
+        if (rc == NGX_HTTP_CLIENT_CLOSED_REQUEST || r->closed) {
+            ngx_http_close_request(r, 0);
+            ngx_http_close_connection(r->connection);
+            return;
+        }
+
         ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc));
 
         return;
@@ -1098,8 +1112,6 @@ int ngx_http_discard_body(ngx_http_request_t *r)
     }
 
     return ngx_http_read_discarded_body(r);
-
-    return NGX_OK;
 }
 
 
@@ -1158,7 +1170,15 @@ static int ngx_http_read_discarded_body(ngx_http_request_t *r)
 
     n = ngx_recv(r->connection, r->discarded_buffer, size);
     if (n == NGX_ERROR) {
-        return NGX_HTTP_BAD_REQUEST;
+
+        r->closed = 1;
+
+        /*
+         * when a client request body is discarded then we already set
+         * some HTTP response code for client and we can ignore the error
+         */
+
+        return NGX_OK;
     }
 
     if (n == NGX_AGAIN) {
@@ -1606,19 +1626,9 @@ static void ngx_http_client_error(ngx_http_request_t *r,
     r->connection->log->handler = NULL;
 
     if (ctx->url) {
-        if (client_error == NGX_HTTP_PARSE_ENTITY_TOO_LARGE) {
-            ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
-                    client_header_errors[client_error - NGX_HTTP_CLIENT_ERROR],
-                    ctx->client, r->headers_in.content_length_n, ctx->url);
-
-            error = NGX_HTTP_REQUEST_ENTITY_TOO_LARGE;
-            r->lingering_close = 1;
-
-        } else {
-            ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+        ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
                     client_header_errors[client_error - NGX_HTTP_CLIENT_ERROR],
                     ctx->client, ctx->url);
-        }
 
     } else {
         if (error == NGX_HTTP_REQUEST_URI_TOO_LARGE) {
index 89cabdb9fcb0bd33288897711d68fe3e2de8719c..ad1afd9b5d07c748850738594ac4d4025eb834de 100644 (file)
@@ -30,7 +30,6 @@
 #define NGX_HTTP_PARSE_TOO_LONG_HEADER     15
 #define NGX_HTTP_PARSE_NO_HOST_HEADER      16
 #define NGX_HTTP_PARSE_INVALID_CL_HEADER   17
-#define NGX_HTTP_PARSE_ENTITY_TOO_LARGE    18
 
 
 #define NGX_HTTP_OK                        200
@@ -87,7 +86,7 @@ typedef struct {
 
 
 typedef struct {
-    ngx_table_t      *headers;   /* it must be first field */
+    ngx_table_t       headers;   /* it must be first field */
 
     ngx_table_elt_t  *host;
     ngx_table_elt_t  *connection;
@@ -137,7 +136,7 @@ typedef struct {
 
 
 typedef struct {
-    ngx_table_t      *headers;   /* it must be first field */
+    ngx_table_t       headers;   /* it must be first field */
 
     int               status;
     ngx_str_t         status_line;
@@ -265,9 +264,7 @@ struct ngx_http_request_s {
     unsigned             header_only:1;
     unsigned             keepalive:1;
     unsigned             lingering_close:1;
-#if 0
     unsigned             closed:1;
-#endif
 
     /* TODO: use the filter flags or the separate bits ???? */
     u_int                filter;
index 2bc63f780b957c88b52977e694af0fc324699cfd..99ac8aad30836662da08e738a78a4b4a15cfefa9 100644 (file)
@@ -12,7 +12,6 @@ static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r);
 ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r,
                                             size_t request_buffer_size)
 {
-    ngx_int_t     rc;
     ssize_t       size;
     ngx_hunk_t   *h;
     ngx_chain_t  *cl;
@@ -143,12 +142,17 @@ static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r)
         }
 
         if (n == 0 || n == NGX_ERROR) {
+            r->closed = 1;
             return NGX_HTTP_BAD_REQUEST;
         }
 
         r->request_body_hunk->last += n;
         r->request_body_len -= n;
 
+        if (r->request_body_len == 0) {
+            break;
+        }
+
         if (r->request_body_hunk->last < r->request_body_hunk->end) {
             break;
         }
index 5ffebb4c2b5393e5e2a769f988b8757a4fa53163..275ae95c9694e14abe3abf0cc667e2d5d3a8fef6 100644 (file)
@@ -185,8 +185,8 @@ int ngx_http_special_response_handler(ngx_http_request_t *r, int error)
 
     rc = ngx_http_discard_body(r);
 
-    if (rc != NGX_OK) {
-        return rc;
+    if (rc == NGX_HTTP_INTERNAL_SERVER_ERROR) {
+        error = NGX_HTTP_INTERNAL_SERVER_ERROR;
     }
 
     r->headers_out.status = error;
index ec519c31c4839dfe4ede7a6d187828c64befb396..4401c3de23f848891bc8a28b5b24f7fc6eccdbc8 100644 (file)
@@ -96,7 +96,7 @@ extern LPFN_GETACCEPTEXSOCKADDRS  getacceptexsockaddrs;
 extern LPFN_TRANSMITFILE          transmitfile;
 
 
-static ngx_inline int ngx_tcp_push(ngx_socket_t s) {
+ngx_inline static int ngx_tcp_push(ngx_socket_t s) {
      return 0;
 }
 
index b6388f5f7c8640c5ae66a6914da85e529571a308..a600952ea7507e51bb0f6542ca944e3df5bd6064 100644 (file)
@@ -50,7 +50,7 @@
 #include <ngx_auto_config.h>
 
 
-#define ngx_inli        __inline
+#define ngx_inline        __inline
 
 
 #ifdef _MSC_VER