-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Allow HTTP/1.1 Upgrades with empty RequestBody #8970
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
base: master
Are you sure you want to change the base?
Conversation
okhttp/src/jvmTest/kotlin/okhttp3/internal/http/HttpUpgradesTest.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think this is right yet. I think as-is the exchange considers the request body stream to be closed, and that will cause us grief when the Socket.source is closed.
okhttp/src/jvmTest/kotlin/okhttp3/internal/http/HttpUpgradesTest.kt
Outdated
Show resolved
Hide resolved
cba33c1
to
5060bd1
Compare
okhttp/src/jvmTest/kotlin/okhttp3/internal/http/HttpUpgradesTest.kt
Outdated
Show resolved
Hide resolved
"SocketSinkStart", | ||
"SocketSinkEnd", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if these events should appear after the RequestBodyEnd event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My preference is that if it’s an upgrade request, we emit a Content-Length: 0
header but ignore the request body, and emit zero events related to it
5060bd1
to
c568801
Compare
/** | ||
* Invoked just prior to sending bytes on the socket. Will only be invoked for upgraded connections. | ||
* | ||
* The connection is implicit, and will generally relate to the last [connectionAcquired] event. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we strengthen this guarantee? Maybe we should pass the connection itself to this method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the checks which ensure that *End happens after *Start, leveraging this generic check?
private var bytesReceived = 0L | ||
private var invokeStartEvent = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this class needs to know if it’s being used for the socket or a regular request body
"SocketSinkStart", | ||
"SocketSinkEnd", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My preference is that if it’s an upgrade request, we emit a Content-Length: 0
header but ignore the request body, and emit zero events related to it
c568801
to
50ea587
Compare
50ea587
to
bec3270
Compare
bec3270
to
df8743f
Compare
df8743f
to
1c94596
Compare
@@ -143,11 +147,10 @@ class Exchange( | |||
fun peekTrailers(): Headers? = codec.peekTrailers() | |||
|
|||
fun upgradeToSocket(): Socket { | |||
isSocket = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might this one fail due to race conditions?
See https://docs.docker.com/reference/api/engine/version/v1.51/#tag/Container/operation/ContainerAttach
The following RFC paragraph might be relevant: https://datatracker.ietf.org/doc/html/rfc9110#section-7.8-15