2

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?

Community
  • 1
  • 1
skibulk
  • 3,088
  • 1
  • 34
  • 42

2 Answers2

2

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.

Craig S. Anderson
  • 6,966
  • 4
  • 33
  • 46
  • Is there any way to initiate a TCP reset through PHP? Maybe by calling an Apache function or exec or something? – skibulk Nov 24 '14 at 14:56
0

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.

skibulk
  • 3,088
  • 1
  • 34
  • 42