'Content-Length' header for POSTs

agentzh agentzh at gmail.com
Thu Nov 5 04:56:26 MSK 2009


On Wed, Nov 4, 2009 at 12:17 AM, joejacobs <nginx-forum at nginx.us> wrote:
> Let me know if you do end up writing it. I really need to use it
>

I've come up with this (naive) plan to add support for chunked request
body without patching nginx:

   location /foo {
      echo_read_chunked_request_body;
      echo_exec @foo;
   }
   location @foo {
       # your original settings here...no matter proxy_pass, rewrite
or custom handlers
   }

The idea is to introduce an "echo_read_chunked_request_body" directive
in my "echo" module to read the client request body *before* other
modules, like "http-proxy", call the
"ngx_http_read_client_request_body" function, and buffer the decoded
request body in r->request_body, to effectively turn
"ngx_http_read_client_request_body" a no-op. And yeah, you'll have to
recompile nginx with the "echo" module anyway.

I'll try a quick implementation by this weekend or possibly the next
week, but no promise :)

I know that a better solution might be implementing it as a
rewrite-phase (or some other earlier phase) handler, but it's a TODO
far-away.

As a side product, it will also give me a basic input filter mechanism
for client request bodies so that I can later implement dynamic
charset conversion input filter, as well as
json/xml/csv/other-data-format decoding filters.

Cheers,
-agentzh





More information about the nginx mailing list