-
Notifications
You must be signed in to change notification settings - Fork 7.9k
http_fopen_wrapper.c: Handle HTTP 101 #6730
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
Conversation
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.
Thanks for the PR, but the solution doesn't look right. I assume that you're facing the issue that there is no following HTTP/1
status line, so all headers will be skipped. Instead looking for that HTTP/1
, we should be looking for an empty line which terminates the 1xx response, and try to get the response status from the following line. It seems to me the current code for handling 101 is a bug, so a PR may target PHP-7.4.
There should also be a mechanism to get the actual headers of 101 responses (maybe 1xx in general?) I'm not sure which mechanism, though.
I wanted to fetch the headers from the 101 response, because that's what I'm interested in. Everything after the 101 response + headers is protocol specific and shouldn't be handled by PHP imho. With this patch it was easily possible to implement a WebSocket handler on top of Guzzle.
Actually that was my intention but I somehow messed up.
Imho this condition should solely check for HTTP 100-continue but that might break things |
Thanks for the clarification!
Yes, that's why I suggested to implement some mechanism to be able to get the headers of such requests. Maybe something like Anyhow, I don't think that we actually break anything in practice with your patch (in theory maybe upgrade requests from HTTP/1.0 to HTTP/1.1, but 1xx responses are not supposed to be sent to HTTP/1.0 clients anyway). But I'm not sure. Could you please file a respective bug ticket for easier reference. And, if possible, adding a test case would be great as well. |
Adding a new stream context option should be do-able. Something like
Sure |
Something like this, or maybe the other way round, e.g. |
Don't wait for further responses after a HTTP 101 (Switching Protocols) response
I've added the requested bug report and a unit test. |
Thank you! |
Don't wait for further responses after a HTTP 101 (Switching Protocols) response