bugfix: exec should return 200 if client doesn't upgrade proto #515
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Wei Fu [email protected]
1.Describe what this PR did
If user calls
/exec/execid/start
without upgrade header, the pouchd should return 200 status.But now, the pouchd always return 101 switch protocol. This PR is to fix this bug.
2.Does this pull request fix one issue?
fixes #494
3.Describe how you did it
For the AttachConfig, the
Upgrade
field should check header from request.4.Describe how to verify it
I have added the test for this.
5.Special notes for reviews
In this PR, I upgrades the
request.Hijack
function and add more comments here:For hijack request, the server can return 200 status or 101 switch proto.
If http-client doesn't switch proto, the
Do
function will return error caused byErrPersistEOF
.As the RFC 2616, section 4.4 mentioned, if there is no Content-Length or chunked Transfer-Encoding on a *Response and the status is not 1xx, 204 or 304, then the body is unbounded. And the response is always terminated by the first empty line after the header fields.
In our case, the 200 response is like:
The golang http client does follow the RFC 2616. More detail is here:
For this case, both status and header has been read into response. And the [raw-data] will be read from hijack.reader. So we can ignore the
ErrPersistEOF
here.cc @allencloud and @Letty5411