Large downloads getting truncated when Content-Length missing

Skip to first unread message

Shreesha K.K

Nov 17, 2023, 6:17:11 AM11/17/23
to openresty
We are using using nginx with lua open resty.

We are using Open Resty httpc:request method with a read timeout of 5 minutes.

For requests involving large contents approximately 5MB and above we see that Browser is not getting the full content of the file inspite seeing a 200 OK response when Content-Length not present in response header.

Method httpc:set_keepalive after request method gives Error - Error: unread data in buffer 

What could be the reason for these issues. what should be the ideal way of retrieving full file content from server.

Upstream server is outside our control, so we are restricted with not having Content-Length in response header.

Ron Yu

Nov 20, 2023, 5:29:12 AM11/20/23
to openresty
When buffering is enabled, nginx receives a response from the proxied server as soon as possible, saving it into the buffers set by the proxy_buffer_size and proxy_buffers directives. If the whole response does not fit into memory, a part of it can be saved to a temporary file on the disk. 

I think this is the reason why you can't get comlete response. Check nginx directives about proxy buffer for detail.


Feb 3, 2024, 11:02:28 PMFeb 3
to openresty
1,浏览器发起请求到nginx server;
2,这个nginx server有一些lua代码,lua代码又通过httpc:request,请求后端服务的一个文件,返回给浏览器;

这里 有几个问题呀,
1,nginx server配置的给浏览器的超时时间是多少;
Reply all
Reply to author
0 new messages