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

Mirko Dziadzka mirko.dziadzka at googlemail.com
Mon Aug 30 23:33:20 MSD 2010


Hi

On 30.08.2010, at 21:00, Maxim Dounin wrote:
> On Mon, Aug 30, 2010 at 06:31:13PM +0200, Mirko Dziadzka wrote:
>> 
>> 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.

I see.

What is the recommended way to create a POST sub-request? 
Should I create a new request line and let uri and method_name point to this line?

like:

u_char * request_line = "POST /foo HTTP/1.0";
ngx_str_t uri;
ngx_str_t method_name;
method_name.data = request_line;
method_name.len = 4;
uri.data = request_line + 5;
uri.len  = 4;


Greetings

    Mirko








More information about the nginx-devel mailing list