Welcome! Log In Create A New Profile

Advanced

upstream_response_length yields zero, need content-length

Anonymous User
May 19, 2010 08:56AM
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 _______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

upstream_response_length yields zero, need content-length

Anonymous User May 19, 2010 08:56AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 301
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready