Abort HTTP chunk encoded response with Error Page

烂漫一生 提交于 2019-12-11 00:59:24

问题


I'm extending this previous question: Aborting a HTTP/1.1 chunk encoded response

When I abort a chunked response Chrome displays a blank page and the dev console reports net::ERR_INCOMPLETE_CHUNKED_ENCODING. IE displays the incomplete page. Is there a way to send the user to an actual 500 error page?

Can I output something that corrupts the document so the browser won't use it? If so, what's the shortest string I can send to achieve this?


回答1:


Unfortunately, there is no chunk you can send that says to the browser "Hey, forget everything I sent so far - something went wrong". Sending a TCP reset packet will cause most browsers to display a "Server reset connection" page, but that requires access to one level down the network stack.

The only other I can think of is to try sending a chunk with a negative length. I don't know how browsers react to that.




回答2:


Here's something interesting I discovered. I'm not sure if it should be applied here, but for consideration:

The HTTP Trailer header might be a way to insert an invalidating header after the response.

The Trailer general field value indicates that the given set of header fields is present in the trailer of a message encoded with chunked transfer coding.

Another consideration is the Content-MD5 header. An aborted response won't validate. I'm not sure how browsers handle this.



来源:https://stackoverflow.com/questions/27018966/abort-http-chunk-encoded-response-with-error-page

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