使用分块编码返回响应时出现错误代码重定向?
我的 Web 应用程序使用分块编码。我希望有这样的行为:如果任何块生成错误,我可以正确设置错误代码并使用它重定向到错误页面。现在看来,只有在第一个块期间发生错误时才会发生这种情况,因为响应标头必须在第一个块中发送。有什么办法可以让这个工作或得到我想要的行为吗?谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HTTP 规范允许您在最后一个块之后提供额外的标头作为“预告片”,应将其视为响应顶部的标头:
https://www.rfc-editor.org/rfc/rfc2616#section-3.6.1
这是一个示例:
http://www.jmarshall.com/easy/http/#http1.1c2
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