HTTP: error during reply after 200 OK status code

微笑、不失礼 提交于 2019-12-04 02:51:45
Dan

I have pushed the similar question to be answered, so here you can find that there is no solution:

How to tell there's something wrong with the server during response that started as 200 OK. Fail gracefully

I finally found a possible solution for this: HTTP 1.1 Trailer headers.

In chunked encoded bodies, HTTP 1.1 allows the sender to add data after the last (empty) chunk, in the form of a block of headers. The specification hints some use-cases like computing on the fly a md5 of the body, and send it after the body so the client can check its integrity.

I think it could be used for error reporting, even if I haven't found anything about this kind of usage.

The issues I see with this are:

  • this requires using chunked encoding (but it's not much of an issue)
  • trailers support is probably very low:
    • server-side (it could be bypassed by manually creating the chunked encoding, but since it's applied after the content-encoding (gzip), it would require a lot of reimplementation)
    • client-side (bugs fixed only in 2010 in curl for example)
    • and on proxies (that could then loose the trailers if not properly implemented)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!