upstream split a header line in FastCGI records

Igor Sysoev is at rambler-co.ru
Tue Aug 4 16:24:26 MSD 2009


On Tue, Aug 04, 2009 at 08:05:07AM -0400, matrix wrote:

> Thank you for the patch Igor.
> 
> I have applied the patch against nginx-0.8.7.
> 
> The good news is that instead of getting "502 Bad Gateway" errors, I now get a valid HTML response from the server, every time. This is great.
> 
> The not so good news is that on some requests the debug information from FirePHP doesn't show in Firebug console. The chance of that happening appears to be the same as with the 502 error I had earlier. The HTML does get shown though.
> 
> http://matrix.alpha-force.net/debug/patch1_req1.txt (good response)
> http://matrix.alpha-force.net/debug/patch1_req2.txt (bad response)
> 
> The patch certainly is a step in the right direction.

Backout the previous patch and try the attached new one.


-- 
Igor Sysoev
http://sysoev.ru/en/
-------------- next part --------------
Index: src/http/modules/ngx_http_fastcgi_module.c
===================================================================
--- src/http/modules/ngx_http_fastcgi_module.c	(revision 2329)
+++ src/http/modules/ngx_http_fastcgi_module.c	(revision 2331)
@@ -1065,7 +1065,7 @@
 static ngx_int_t
 ngx_http_fastcgi_process_header(ngx_http_request_t *r)
 {
-    u_char                         *p, *start, *last, *part_start;
+    u_char                         *p, *start, *last, *part_start, *part_end;
     size_t                          size;
     ngx_str_t                      *status_line, line, *pattern;
     ngx_int_t                       rc, status;
@@ -1237,6 +1237,7 @@
         for ( ;; ) {
 
             part_start = u->buffer.pos;
+            part_end = u->buffer.last;
 
             rc = ngx_http_parse_header_line(r, &u->buffer, 1);
 
@@ -1437,8 +1438,12 @@
         part = ngx_array_push(f->split_parts);
 
         part->start = part_start;
-        part->end = u->buffer.last;
+        part->end = part_end;
 
+        if (u->buffer.pos < u->buffer.last) {
+            continue;
+        }
+
         return NGX_AGAIN;
     }
 }


More information about the nginx mailing list