Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 118 lines (97 sloc) 3.894 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
diff -ur nginx-1.0.9/src/http/ngx_http_request_body.c nginx-1.0.9-patched/src/http/ngx_http_request_body.c
--- nginx-1.0.9/src/http/ngx_http_request_body.c 2011-09-30 22:36:19.000000000 +0800
+++ nginx-1.0.9-patched/src/http/ngx_http_request_body.c 2011-10-21 21:54:08.460350482 +0800
@@ -38,7 +38,7 @@
 
     r->main->count++;
 
- if (r->request_body || r->discard_body) {
+ if (r->request_body || r->discard_body || r->content_length_n == 0) {
         post_handler(r);
         return NGX_OK;
     }
@@ -440,7 +440,7 @@
     ssize_t size;
     ngx_event_t *rev;
 
- if (r != r->main || r->discard_body) {
+ if (r != r->main || r->discard_body || r->content_length_n == 0) {
         return NGX_OK;
     }
 
@@ -456,20 +456,22 @@
         ngx_del_timer(rev);
     }
 
- if (r->headers_in.content_length_n <= 0 || r->request_body) {
+ r->content_length_n = r->headers_in.content_length_n;
+
+ if (r->content_length_n <= 0 || r->request_body) {
         return NGX_OK;
     }
 
     size = r->header_in->last - r->header_in->pos;
 
     if (size) {
- if (r->headers_in.content_length_n > size) {
+ if (r->content_length_n > size) {
             r->header_in->pos += size;
- r->headers_in.content_length_n -= size;
+ r->content_length_n -= size;
 
         } else {
- r->header_in->pos += (size_t) r->headers_in.content_length_n;
- r->headers_in.content_length_n = 0;
+ r->header_in->pos += (size_t) r->content_length_n;
+ r->content_length_n = 0;
             return NGX_OK;
         }
     }
@@ -568,7 +570,7 @@
                    "http read discarded body");
 
     for ( ;; ) {
- if (r->headers_in.content_length_n == 0) {
+ if (r->content_length_n == 0) {
             r->read_event_handler = ngx_http_block_reading;
             return NGX_OK;
         }
@@ -577,9 +579,9 @@
             return NGX_AGAIN;
         }
 
- size = (r->headers_in.content_length_n > NGX_HTTP_DISCARD_BUFFER_SIZE) ?
+ size = (r->content_length_n > NGX_HTTP_DISCARD_BUFFER_SIZE) ?
                    NGX_HTTP_DISCARD_BUFFER_SIZE:
- (size_t) r->headers_in.content_length_n;
+ (size_t) r->content_length_n;
 
         n = r->connection->recv(r->connection, buffer, size);
 
@@ -596,7 +598,7 @@
             return NGX_OK;
         }
 
- r->headers_in.content_length_n -= n;
+ r->content_length_n -= n;
     }
 }
 
Only in nginx-1.0.9-patched/src/http: ngx_http_request_body.c~
diff -ur nginx-1.0.9/src/http/ngx_http_request.c nginx-1.0.9-patched/src/http/ngx_http_request.c
--- nginx-1.0.9/src/http/ngx_http_request.c 2011-09-30 22:36:19.000000000 +0800
+++ nginx-1.0.9-patched/src/http/ngx_http_request.c 2011-10-21 19:06:38.404350692 +0800
@@ -286,6 +286,8 @@
 
         r->pipeline = hc->pipeline;
 
+ r->content_length_n = -1;
+
         if (hc->nbusy) {
             r->header_in = hc->busy[0];
         }
@@ -297,6 +299,8 @@
             return;
         }
 
+ r->content_length_n = -1;
+
         hc->request = r;
     }
 
Only in nginx-1.0.9-patched/src/http: ngx_http_request.c~
diff -ur nginx-1.0.9/src/http/ngx_http_request.h nginx-1.0.9-patched/src/http/ngx_http_request.h
--- nginx-1.0.9/src/http/ngx_http_request.h 2011-08-29 18:39:23.000000000 +0800
+++ nginx-1.0.9-patched/src/http/ngx_http_request.h 2011-10-21 17:26:13.203807584 +0800
@@ -366,6 +366,9 @@
     ngx_pool_t *pool;
     ngx_buf_t *header_in;
 
+ off_t content_length_n;
+ /* for discarding request body */
+
     ngx_http_headers_in_t headers_in;
     ngx_http_headers_out_t headers_out;
 
Only in nginx-1.0.9-patched/src/http: ngx_http_request.h~
Only in nginx-1.0.9-patched/src/http: tags
Something went wrong with that request. Please try again.