Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error code redirect when returning a response with chunked encoding?

My web application uses chunked encoding. I'd like to have the behavior where if any chunk generates an error, I can properly set the error code and redirect to an error page using that. Right now it seems like that can only happen if the error occurs during the first chunk because the response headers must be sent in the first chunk. Is there any way to make this work or get the behavior that I want? Thanks.

like image 428
Heinrich Schmetterling Avatar asked May 02 '26 11:05

Heinrich Schmetterling


1 Answers

The HTTP spec allows you to provide additional headers as a "trailer" after your last chunk, which should be treated just like headers at the top of the response:

https://www.rfc-editor.org/rfc/rfc2616#section-3.6.1

Here's an example:

http://www.jmarshall.com/easy/http/#http1.1c2

like image 175
Klaus Avatar answered May 05 '26 02:05

Klaus