Skip to content
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

Avoid writing to the body after full hijack #151

Merged
merged 4 commits into from
Apr 5, 2024

Conversation

yard
Copy link
Contributor

@yard yard commented Mar 13, 2024

Whenever the application performs hijacking of http/1.1 connection, the server must not attempt to send any response back to the client. Prior to this change, it was not the case due to imprecise check and has led to an error being logged (the real issue occurred during an attempt to write to a stream that was set to nil, but that's really just a symptom).

The proposed fix simply adds a flag to the connection object so that it is aware of the fact the underlying stream no longer belongs to it and must not be used to send any data over.

Types of Changes

  • Bug fix.

Contribution

@ioquatix
Copy link
Member

This looks okay to me, but my only thought is whether we should move this to protocol-http1.

@yard
Copy link
Contributor Author

yard commented Apr 3, 2024

Actually a good point, maybe we should (since #hijack! is part of protocol-http1). This will, however, require bumping the dependency version here too.

Do lmk if you want me to split this PR into 2 – happy to do that.

@ioquatix
Copy link
Member

ioquatix commented Apr 3, 2024

Yes, let's implement the core functionality in protocol-http1 if possible - thanks!!

@yard
Copy link
Contributor Author

yard commented Apr 4, 2024

As soon as socketry/protocol-http1#30 lands I can update this PR – will only need protocol-http1 to be released so that I can bump the version in this gem.

@ioquatix
Copy link
Member

ioquatix commented Apr 5, 2024

protocol-http1 v0.19.0 was released.

@yard
Copy link
Contributor Author

yard commented Apr 5, 2024

Updated this PR to match

@ioquatix ioquatix merged commit 9b0bf86 into socketry:main Apr 5, 2024
15 of 18 checks passed
@ioquatix ioquatix added this to the v0.64.1 milestone Apr 7, 2024
@ioquatix
Copy link
Member

ioquatix commented Apr 8, 2024

I tried this out and it's working as expected - thanks!

ioquatix pushed a commit to zarqman/async-http that referenced this pull request Apr 23, 2024
* Handling partially and fully hijacked connections gracefully

* A more precise test of hijacked body

* Bumping protocol-http1 and updating hijack check

* Closing the body after hijack

---------

Co-authored-by: Anton Zhuravsky <anton@lunalabs.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants