返回带有分块编码的响应时,错误代码重定向?

编程入门 行业动态 更新时间:2024-10-28 03:33:36
本文介绍了返回带有分块编码的响应时,错误代码重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

tools.ietf/html/rfc2616#section- 3.6.1

这是一个例子:

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

更多推荐

返回带有分块编码的响应时,错误代码重定向?

本文发布于:2023-10-09 21:09:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1476791.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   错误代码

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!