Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: def7fbf4a3
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 99 lines (87 sloc) 2.907 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
Index: nginx-catap/nginx/src/event/ngx_event_pipe.c
===================================================================
--- nginx-catap.orig/nginx/src/event/ngx_event_pipe.c
+++ nginx-catap/nginx/src/event/ngx_event_pipe.c
@@ -312,22 +312,26 @@ ngx_event_pipe_read_upstream(ngx_event_p
 
             if (n >= size) {
                 cl->buf->last = cl->buf->end;
-
- /* STUB */ cl->buf->num = p->num++;
-
- if (p->input_filter(p, cl->buf) == NGX_ERROR) {
- return NGX_ABORT;
- }
-
                 n -= size;
- ln = cl;
- cl = cl->next;
- ngx_free_chain(p->pool, ln);
 
             } else {
                 cl->buf->last += n;
                 n = 0;
+
+ if (cl->buf->last - cl->buf->pos < p->length) {
+ continue;
+ }
+ }
+
+ /* STUB */ cl->buf->num = p->num++;
+
+ if (p->input_filter(p, cl->buf) == NGX_ERROR) {
+ return NGX_ABORT;
             }
+
+ ln = cl;
+ cl = cl->next;
+ ngx_free_chain(p->pool, ln);
         }
 
         if (cl) {
@@ -392,6 +396,9 @@ ngx_event_pipe_read_upstream(ngx_event_p
                        cl->buf->file_last - cl->buf->file_pos);
     }
 
+ ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0,
+ "pipe length: %O", p->length);
+
 #endif
 
     if ((p->upstream_eof || p->upstream_error) && p->free_raw_bufs) {
@@ -848,6 +855,16 @@ ngx_event_pipe_copy_input_filter(ngx_eve
     }
     p->last_in = &cl->next;
 
+ if (p->length == NGX_MAX_OFF_T_VALUE) {
+ return NGX_OK;
+ }
+
+ p->length -= b->last - b->pos;
+
+ if (p->length <= 0) {
+ p->upstream_done = 1;
+ }
+
     return NGX_OK;
 }
 
Index: nginx-catap/nginx/src/event/ngx_event_pipe.h
===================================================================
--- nginx-catap.orig/nginx/src/event/ngx_event_pipe.h
+++ nginx-catap/nginx/src/event/ngx_event_pipe.h
@@ -65,6 +65,7 @@ struct ngx_event_pipe_s {
     ssize_t busy_size;
 
     off_t read_length;
+ off_t length;
 
     off_t max_temp_file_size;
     ssize_t temp_file_write_size;
Index: nginx-catap/nginx/src/http/ngx_http_upstream.c
===================================================================
--- nginx-catap.orig/nginx/src/http/ngx_http_upstream.c
+++ nginx-catap/nginx/src/http/ngx_http_upstream.c
@@ -2366,6 +2366,13 @@ ngx_http_upstream_send_response(ngx_http
     p->pool = r->pool;
     p->log = c->log;
 
+ if (r->headers_out.content_length_n != -1) {
+ p->length = r->headers_out.content_length_n;
+
+ } else {
+ p->length = NGX_MAX_OFF_T_VALUE;
+ }
+
     p->cacheable = u->cacheable || u->store;
 
     p->temp_file = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t));
Something went wrong with that request. Please try again.