Bug 85737
| Summary: | WebSocket-Protocol header not implemented correctly | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Markus Fenske <fenske> |
| Component: | WebCore Misc. | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED WONTFIX | ||
| Severity: | Normal | CC: | ap, li.yin, yutak |
| Priority: | P2 | ||
| Version: | 528+ (Nightly build) | ||
| Hardware: | All | ||
| OS: | All | ||
Markus Fenske
Hi,
I am reporting a bug in qt-everywhere-opensource-src-4.7.4.tar.gz. I am not quite sure, if this belongs in this bug tracker.
I am using capybara-webkit (ruby stuff) to test against jetty websocket server. I am using the following javascript:
socket = new WebSocket("ws://localhost:8888/api/v1/driver", "myprotocol");
The console returns: "Error during WebSocket handshake: protocol mismatch: myprotocol != "
If I look in the packet dumps, I see, that Qt Websocket is sending:
GET /api/v1/driver HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
Host: 127.0.0.1:8888
Origin: http://127.0.0.1:59227
WebSocket-Protocol: myprotocol
And the Server is responding:
HTTP/1.1 101 Web Socket Protocol Handshake
Upgrade: WebSocket
Connection: Upgrade
WebSocket-Origin: http://127.0.0.1:59227
WebSocket-Location: ws://127.0.0.1:8888/api/v1/driver
There is no WebSocket-Protocol Header from the server, because according to the RFCs I found, it is only needed if the server does use a protocol not specified by the client. In this case, the Server uses the "myprotocol" protocol, so no WebSocket-Protocol header is needed. I tracked down the issue to qt-everywhere-opensource-src-4.7.4/src/3rdparty/webkit/WebCore/websockets/WebSocketHandshake.cpp. The following patch fixes it.
--- WebSocketHandshake.cpp.old 2012-05-06 18:35:33.659494866 +0200
+++ WebSocketHandshake.cpp 2012-05-06 18:35:36.179513204 +0200
@@ -491,7 +491,7 @@
m_context->addMessage(ConsoleDestination, JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: location mismatch: " + clientLocation() + " != " + m_wsLocation, 0, clientOrigin());
return;
}
- if (!m_clientProtocol.isEmpty() && m_clientProtocol != m_wsProtocol) {
+ if (!m_wsProtocol.isEmpty() && m_clientProtocol != m_wsProtocol) {
m_context->addMessage(ConsoleDestination, JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: protocol mismatch: " + m_clientProtocol + " != " + m_wsProtocol, 0, clientOrigin());
return;
}
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Li Yin
(In reply to comment #0)
> Hi,
>
> I am reporting a bug in qt-everywhere-opensource-src-4.7.4.tar.gz. I am not quite sure, if this belongs in this bug tracker.
>
> I am using capybara-webkit (ruby stuff) to test against jetty websocket server. I am using the following javascript:
>
> socket = new WebSocket("ws://localhost:8888/api/v1/driver", "myprotocol");
>
> The console returns: "Error during WebSocket handshake: protocol mismatch: myprotocol != "
>
> If I look in the packet dumps, I see, that Qt Websocket is sending:
>
> GET /api/v1/driver HTTP/1.1
> Upgrade: WebSocket
> Connection: Upgrade
> Host: 127.0.0.1:8888
> Origin: http://127.0.0.1:59227
> WebSocket-Protocol: myprotocol
>
>
> And the Server is responding:
>
> HTTP/1.1 101 Web Socket Protocol Handshake
> Upgrade: WebSocket
> Connection: Upgrade
> WebSocket-Origin: http://127.0.0.1:59227
> WebSocket-Location: ws://127.0.0.1:8888/api/v1/driver
>
> There is no WebSocket-Protocol Header from the server, because according to the RFCs I found, it is only needed if the server does use a protocol not specified by the client. In this case, the Server uses the "myprotocol" protocol, so no WebSocket-Protocol header is needed. I tracked down the issue to qt-everywhere-opensource-src-4.7.4/src/3rdparty/webkit/WebCore/websockets/WebSocketHandshake.cpp. The following patch fixes it.
>
>
> --- WebSocketHandshake.cpp.old 2012-05-06 18:35:33.659494866 +0200
> +++ WebSocketHandshake.cpp 2012-05-06 18:35:36.179513204 +0200
> @@ -491,7 +491,7 @@
> m_context->addMessage(ConsoleDestination, JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: location mismatch: " + clientLocation() + " != " + m_wsLocation, 0, clientOrigin());
> return;
> }
> - if (!m_clientProtocol.isEmpty() && m_clientProtocol != m_wsProtocol) {
> + if (!m_wsProtocol.isEmpty() && m_clientProtocol != m_wsProtocol) {
> m_context->addMessage(ConsoleDestination, JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: protocol mismatch: " + m_clientProtocol + " != " + m_wsProtocol, 0, clientOrigin());
> return;
> }
You are working on Hixie76Protocol, maybe it will be abandoned by webkit in the near future.
We are working on the new WebSocket protocol RFC6455 http://tools.ietf.org/html/rfc6455
Yuta Kitamura
Right, the old protocol isn't used anymore (Qt has switched the protocol recently), and we are going to vanish code and tests for the old protocol soon.
So, I'm resolving this issue as WONTFIX. If there's an issue with the RFC protocol version, please speak up or open a new bug.
Furthermore, if you are going to contribute a patch in the future, please follow the instruction at http://www.webkit.org/coding/contributing.html and upload your patch to the bugzilla (instead of pasting the diff in comments) so we can review it smoothly.