Strange behavior (BUG?) for setting r->headers_in.method_name in a subrequest

Maxim Dounin mdounin at mdounin.ru
Mon Aug 30 23:00:22 MSD 2010


Hello!

On Mon, Aug 30, 2010 at 06:31:13PM +0200, Mirko Dziadzka wrote:

> Hi all
> 
> I'm using nginx-0.7.66 and am trying to create a POST sub-request:
> 
> res = ngx_http_subrequest(r, uri, NULL , &sr, psr, flags);
> sr->method = NGX_HTTP_POST;
> sr->method_name.data = (u_char *)"POST";
> sr->method_name.len = 4;
> 
> The uri is then forwarded via proxy_pass to another server.
> 
> With wireshark, I see the following bytes on the network:
> 
> 00000000  50 4f 53 54 00 2f 64 65  63 69 64 65 2e 63 67 69 POST./de
> 
> Please note the 00-byte after the POST. If I change the code to
> 
> res = ngx_http_subrequest(r, uri, NULL , &sr, psr, flags);
> sr->method = NGX_HTTP_POST;
> sr->method_name.data = (u_char *)"POST "; // note the SPACE after POST
> sr->method_name.len = 4;
> 
> it will work as expected and I see a space. I did not dig further into
> nginx code but it looks like the 5-th byte from "POST" is used in the
> new request - which is probably a bug.

r->method_name expected to point into request line, and the use of 
the following byte is intentional.

Maxim Dounin



More information about the nginx-devel mailing list