How nignx handled the header to the client in this situation

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How nignx handled the header to the client in this situation

redflag
I understand the nginx would proxy the header first and then the body, in
the case the connection with the upstream is broken during the transfer of
body, what status code the client would get? since the nginx would proxy the
200 OK from upstream first to the client, but will nginx send another 5xx
header to the client if the upstream connetction is broken?

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,287990,287990#msg-287990

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: How nignx handled the header to the client in this situation

redflag
Will nginx buffer the header before receiving of the whole body?
If not, what if error happens in the middle of body receiving? nginx has no
chance to resend the error status then.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,287990,288039#msg-288039

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: How nignx handled the header to the client in this situation

Francis Daly
On Fri, May 15, 2020 at 01:51:13AM -0400, allenhe wrote:

Hi there,

> Will nginx buffer the header before receiving of the whole body?
> If not, what if error happens in the middle of body receiving? nginx has no
> chance to resend the error status then.

What do you want your nginx to do, in that case?

I suspect that what nginx does do,  depends on things like
http://nginx.org/r/proxy_buffering

As you suggest: if nginx gets the entire response before sending anything
to the client, it can send a suitable response code.

If nginx is told to stream the response "live", then if the response is
http 200 plus half the intended body, that is what the client will get.

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: How nignx handled the header to the client in this situation

redflag
Hi Francis,

Thanks for the reply!
w.r.t. the "http://nginx.org/r/proxy_buffering", the doc does not mention if
the buffering works for header, body or both, I'm wondering if nginx can
postpone the sending of upstream header in any ways? otherwise the client
will get wrong status code in this case.

Allen
BR

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,287990,288056#msg-288056

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: How nignx handled the header to the client in this situation

Francis Daly
On Fri, May 15, 2020 at 11:09:53PM -0400, allenhe wrote:

Hi there,

> w.r.t. the "http://nginx.org/r/proxy_buffering", the doc does not mention if
> the buffering works for header, body or both,

It's "the response".

It sounds like it should be fairly straightforward to test on your setup,
if you want to convince yourself what it does -- make an upstream that
receives a request, waits 5 second, sends the response header, waits 10
seconds, sends some of the response body, waits 10 seconds, and sends
the rest of the response body.

Then make a request directly to that upstream, and see that you see
something after 5, 15, and 25 seconds.

Then make a request through nginx, and see if you see anything before
25 seconds (all buffered); or see something after 5 seconds (header sent
early) or after 15 (header and start of body sent early).

> I'm wondering if nginx can
> postpone the sending of upstream header in any ways?

Can you show the request that you make and the response that you get
that is not the response that you want?

Good luck with it,

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx