Heinrich Schmetterling
Heinrich Schmetterling

Reputation: 6884

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.

Upvotes: 3

Views: 1808

Answers (1)

Klaus
Klaus

Reputation: 724

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

Upvotes: 3

Related Questions