Discussion:
subrequest and POST
Roman Vasilyev
2011-06-14 17:43:23 UTC
Permalink
Hi,

I'm writing code, which making decision to accept or not rest of request
in NGINX. For that I've created 2 modules, one subrequest module,
another one accepting "client_max_body_size_var".

Everything works fine, except POST data, I can get result of subrequest
only when POST finished,
can I get subrequest data before accepting or declining request_body?

Regards
Roman Vasilyev
Roman Vasilyev
2011-06-14 23:35:07 UTC
Permalink
Hi,

Whan to add that fixed it by removing all headers from main request.

sr->headers_in.headers.part.nelts=0;

Is it correct? Or exists more clear way to do that?
Post by Roman Vasilyev
Hi,
I'm writing code, which making decision to accept or not rest of
request in NGINX. For that I've created 2 modules, one subrequest
module, another one accepting "client_max_body_size_var".
Everything works fine, except POST data, I can get result of
subrequest only when POST finished,
can I get subrequest data before accepting or declining request_body?
Regards
Roman Vasilyev
_______________________________________________
nginx mailing list
http://nginx.org/mailman/listinfo/nginx
Roman Vasilyev
2011-06-14 23:37:08 UTC
Permalink
Post by Roman Vasilyev
Hi,
Whan to add that fixed it by removing all headers from main request.
Sorry, removing from *subrequest*.
Post by Roman Vasilyev
sr->headers_in.headers.part.nelts=0;
Is it correct? Or exists more clear way to do that?
Post by Roman Vasilyev
Hi,
I'm writing code, which making decision to accept or not rest of
request in NGINX. For that I've created 2 modules, one subrequest
module, another one accepting "client_max_body_size_var".
Everything works fine, except POST data, I can get result of
subrequest only when POST finished,
can I get subrequest data before accepting or declining request_body?
Regards
Roman Vasilyev
_______________________________________________
nginx mailing list
http://nginx.org/mailman/listinfo/nginx
_______________________________________________
nginx mailing list
http://nginx.org/mailman/listinfo/nginx
Maxim Dounin
2011-06-15 00:01:59 UTC
Permalink
Hello!
Post by Roman Vasilyev
Post by Roman Vasilyev
Hi,
Whan to add that fixed it by removing all headers from main request.
Sorry, removing from *subrequest*.
Post by Roman Vasilyev
sr->headers_in.headers.part.nelts=0;
Is it correct? Or exists more clear way to do that?
This isn't correct (in both meanings: it doesn't correctly remove
headers from subrequest and not a correct way to prevent body from
being read before subrequest).

I would recommend adding fake body to subrequest instead, see
example here:

http://mdounin.ru/hg/ngx_http_auth_request_module/file/a29d74804ff1/ngx_http_auth_request_module.c#l193

Note that it may be also needed to instruct backend to not expect
body, i.e. if you proxy_pass such subrequest you should either use

proxy_pass_request_headers off;

or

proxy_set_header Content-Length "";

Maxim Dounin
Post by Roman Vasilyev
Post by Roman Vasilyev
Post by Roman Vasilyev
Hi,
I'm writing code, which making decision to accept or not rest of
request in NGINX. For that I've created 2 modules, one
subrequest module, another one accepting
"client_max_body_size_var".
Everything works fine, except POST data, I can get result of
subrequest only when POST finished,
can I get subrequest data before accepting or declining request_body?
Regards
Roman Vasilyev
_______________________________________________
nginx mailing list
http://nginx.org/mailman/listinfo/nginx
_______________________________________________
nginx mailing list
http://nginx.org/mailman/listinfo/nginx
_______________________________________________
nginx mailing list
http://nginx.org/mailman/listinfo/nginx
Roman Vasilyev
2011-06-15 23:27:53 UTC
Permalink
Thank you,
it was very helpful.
Post by Maxim Dounin
Hello!
Post by Roman Vasilyev
Post by Roman Vasilyev
Hi,
Whan to add that fixed it by removing all headers from main request.
Sorry, removing from *subrequest*.
Post by Roman Vasilyev
sr->headers_in.headers.part.nelts=0;
Is it correct? Or exists more clear way to do that?
This isn't correct (in both meanings: it doesn't correctly remove
headers from subrequest and not a correct way to prevent body from
being read before subrequest).
I would recommend adding fake body to subrequest instead, see
http://mdounin.ru/hg/ngx_http_auth_request_module/file/a29d74804ff1/ngx_http_auth_request_module.c#l193
Note that it may be also needed to instruct backend to not expect
body, i.e. if you proxy_pass such subrequest you should either use
proxy_pass_request_headers off;
or
proxy_set_header Content-Length "";
Maxim Dounin
Post by Roman Vasilyev
Post by Roman Vasilyev
Post by Roman Vasilyev
Hi,
I'm writing code, which making decision to accept or not rest of
request in NGINX. For that I've created 2 modules, one
subrequest module, another one accepting
"client_max_body_size_var".
Everything works fine, except POST data, I can get result of
subrequest only when POST finished,
can I get subrequest data before accepting or declining request_body?
Regards
Roman Vasilyev
_______________________________________________
nginx mailing list
http://nginx.org/mailman/listinfo/nginx
_______________________________________________
nginx mailing list
http://nginx.org/mailman/listinfo/nginx
_______________________________________________
nginx mailing list
http://nginx.org/mailman/listinfo/nginx
_______________________________________________
nginx mailing list
http://nginx.org/mailman/listinfo/nginx
Loading...