upstream_response_length yields zero, need content-length

mail at a.host.name mail at a.host.name
Wed May 19 16:52:49 MSD 2010


hi all :-)

i am trying to inject a content-length header into a response from an upstream because the upstream is not capable of sending a content-length since the size of the body is not known until the end is actually reached.

my current config is:

location / {
  proxy_buffering on;
  proxy_pass http://upstream;
  chunked_transfer_encoding off;
  add_header Content-Length $upstream_response_length;
}

now when using upstream_response_length in the log_format i get a non-zero value but when used in add_header its zero.
i needed to turn off chunked_transfer_encoding because otherwise the client will choke.

nginx gives the warn log: an upstream response is buffered to a temporary file /var/tmp/nginx/proxy/1/00/0000000001 while reading upstream, [...] so the response length should be known in this case.
but i guess the problem is since this is with headers the response would have to be split first which should then yield a (new) variable like upstream_body_size or similar.

any help is highly appreciated.

thanks in advance.

greets,
elm0 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20100519/528251df/attachment.html>


More information about the nginx mailing list