async-http icon indicating copy to clipboard operation
async-http copied to clipboard

Avoid writing to the body after full hijack

Open yard opened this issue 1 year ago • 1 comments

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

yard avatar Mar 13 '24 13:03 yard

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

ioquatix avatar Mar 19 '24 06:03 ioquatix

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.

yard avatar Apr 03 '24 14:04 yard

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

ioquatix avatar Apr 03 '24 23:04 ioquatix

As soon as https://github.com/socketry/protocol-http1/pull/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.

yard avatar Apr 04 '24 18:04 yard

protocol-http1 v0.19.0 was released.

ioquatix avatar Apr 05 '24 11:04 ioquatix

Updated this PR to match

yard avatar Apr 05 '24 11:04 yard

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

ioquatix avatar Apr 08 '24 21:04 ioquatix