New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abort streamed request #112
Comments
This can also be useful when e.g. you'd want to halt the processing based on headers or status. For instance, if one wants to use streaming to compute a checksum of the data, but only compute it if the status is 200, and ignore otherwise (or follow a redirect header etc). |
You cannot abort HTTP/1 requests, the only thing you can do is close the connection. If you want to make a choice based on the headers you should use With HTTP/2 you can abort requests, Mint exposes that through |
Thanks! To simulate the abortion, is there a recommended way to close an HTTP/1 connection inside a |
Sorry to bump this issue, but I was also curious if there is recommended way to close a connection inside a |
To expand on this, when streaming in finch we pass a reducing function for status, headers and data. This underlying mint connection is not available inside these calls, would adding the mint connection to the call make the functionality possible? Before:
After:
|
If you throw inside the streaming function the connection will be closed (for HTTP/1.1) and the request will be cancelled: https://github.com/sneako/finch/blob/main/test/finch/http1/integration_test.exs#L83 |
Thanks for the response! I saw the integration test but it's great to get a confirmation this is expected. |
Say I'm using Finch to proxy some request to an upstream http server I might want to stop the stream if the caller closed the connection:
The text was updated successfully, but these errors were encountered: