Skip to content

Stop parsing headers when switching to unknown protocols - #899

Closed
mkauf wants to merge 1 commit into
curl:masterfrom
mkauf:101_upgrade_headers
Closed

mkauf wants to merge 1 commit into
curl:masterfrom
mkauf:101_upgrade_headers

Conversation

@mkauf

@mkauf mkauf commented Jun 28, 2016

Copy link
Copy Markdown
Contributor
  • unknown protocols probably won't send more headers (e.g. WebSocket)
  • improved comments and moved them to the correct case statements

- unknown protocols probably won't send more headers (e.g. WebSocket)
- improved comments and moved them to the correct case statements
@mkauf
mkauf force-pushed the 101_upgrade_headers branch from b379813 to c8a077a Compare June 28, 2016 20:58
@jay

jay commented Jun 28, 2016

Copy link
Copy Markdown
Member

Can you explain what you are trying to do here, isn't it correct to continue to read headers on 101? For example consider this server response (cribbed from wikipedia)

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=
Sec-WebSocket-Protocol: chat

@bagder

bagder commented Jun 28, 2016

Copy link
Copy Markdown
Member

Exactly, the new protocol doesn't actually start until after the set of HTTP/1 headers. Explained in RFC 7230 section 6.7.

But exactly how libcurl should behave in the case of a protocol upgrade to a protocol libcurl doesn't understand has never been defined and documented clearly.

@mkauf

mkauf commented Jun 28, 2016

Copy link
Copy Markdown
Contributor Author

The code that I have changed gets executed after an empty header line (= end of headers) has been read. It's inside the "if" starting at https://github.com/mkauf/curl/blob/c8a077a2ecc12a7b601a00b3531b79c106b4e49e/lib/http.c#L3022

So the k->header flag controls whether curl expects another set of headers.

But exactly how libcurl should behave in the case of a protocol upgrade to a protocol libcurl doesn't understand has never been defined and documented clearly.

That's right... but probably this protocol does not use HTTP headers (e.g. WebSocket)

@bagder bagder closed this in 7bda07b Aug 25, 2016
@mkauf
mkauf deleted the 101_upgrade_headers branch August 29, 2016 12:16
@lock lock Bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants