返回带有分块编码的响应时,错误代码重定向? [英] Error code redirect when returning a response with chunked encoding?

查看:116
本文介绍了返回带有分块编码的响应时,错误代码重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的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.

推荐答案

HTTP规范允许您在最后一个块之后提供其他标头作为预告片",应将其像响应顶部的标头一样对待:

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

这是一个例子:

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

这篇关于返回带有分块编码的响应时,错误代码重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆