Error code redirect when returning a response with chunked encoding?

六眼飞鱼酱① 提交于 2019-12-13 14:38:25

问题


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.


回答1:


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:

http://tools.ietf.org/html/rfc2616#section-3.6.1

Here's an example:

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



来源:https://stackoverflow.com/questions/5707291/error-code-redirect-when-returning-a-response-with-chunked-encoding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!