Close connection without response on status code 444#1134
Close connection without response on status code 444#1134fredrikekre wants to merge 1 commit intomasterfrom
Conversation
This patch adds the ability for stream handlers to bail out on a request and tell the internal HTTP.jl code to simply close the connection and to ignore any remaining data to be read or written. This is done by setting the response status code to the non-standard value 444, just like in nginx. If the status code is set to 444 when the request handler returns, the internal server code simply closes the connection. In particular this will skip calling `closeread` and `closewrite`, which both do some "consistency checks" that can't be avoided by using something like ```julia HTTP.setstatus(http, 444) close(http.stream) ``` inside the request handler function directly.
|
This seems fine to me; could you expound just a bit more on why it's beneficial to just close and ignore vs. the normal calling closeread/closewrite? |
|
With this server we get with curl for example: but also on the Julia server logs there is for the first request. Like in nginx, the 444 code can now be used to just close and move on, without even bothering sending response headers, reading request data, etc. |
|
It seems convenient to be able to bail out completely, but is it only nginx that uses 444 like this? I can't seem to find any other references to this practice. Since the status is code isn't even sent to the client why use a status code at all? Perhaps a custom exception "throw(BailOutError())" would make the intention more explicit? Could the docs include some comment on a scenario for the intended usage of such functionality? |
This patch adds the ability for stream handlers to bail out on a request and tell the internal HTTP.jl code to simply close the connection and to ignore any remaining data to be read or written.
This is done by setting the response status code to the non-standard value 444, just like in nginx. If the status code is set to 444 when the request handler returns, the internal server code simply closes the connection. In particular this will skip calling
closereadandclosewrite, which both do some "consistency checks" that can't be avoided by using something likeinside the request handler function directly.