-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
http_parser takes one byte to much, upgrade websockets #17789
Comments
Can you post steps to reproduce? |
Hmm not really without setting up a whole system.. Server is homeassistant (http://hass.io). Code to trigger error in node:
Tried to debug the internals of node but only got to socketOnData in _http_client.js |
Maybe if one instantiated a http_parser and tried to parse the data i posted it could return the same error.. i'll have to check on that tomorrow. |
A simple test case that starts a server with |
Testcase:
|
Or need can even be a slice of response for better clarity maybe. |
Thanks, I can reproduce and a fix is on the way. I'm surprised this bug managed to stay hidden for so long. I thought at first it must be a recent regression but it seems to have been around for some time. |
I guess people don't often send body data in upgrade requests? Good catch either way. @quazzie thanks for coming up with a testcase! |
This, RFC 6455 (WebSocket) says that data transfer should start only after a successful opening handshake. |
Fix a bug where a connection upgrade response with a Transfer-Encoding header and a body whose first byte is > 127 causes said byte to be dropped on the floor when passing the remainder of the message to the 'upgrade' event listeners. Fixes: nodejs#17789
Fix a bug where a connection upgrade response with a Transfer-Encoding header and a body whose first byte is > 127 causes said byte to be dropped on the floor when passing the remainder of the message to the 'upgrade' event listeners. Fixes: #17789 PR-URL: #17806 Fixes: #17789 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Fix a bug where a connection upgrade response with a Transfer-Encoding header and a body whose first byte is > 127 causes said byte to be dropped on the floor when passing the remainder of the message to the 'upgrade' event listeners. Fixes: #17789 PR-URL: #17806 Fixes: #17789 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Fix a bug where a connection upgrade response with a Transfer-Encoding header and a body whose first byte is > 127 causes said byte to be dropped on the floor when passing the remainder of the message to the 'upgrade' event listeners. Fixes: #17789 PR-URL: #17806 Fixes: #17789 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Fix a bug where a connection upgrade response with a Transfer-Encoding header and a body whose first byte is > 127 causes said byte to be dropped on the floor when passing the remainder of the message to the 'upgrade' event listeners. Fixes: nodejs#17789 PR-URL: nodejs#17806 Fixes: nodejs#17789 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
http_parser takes one byte to much from this:
`HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: upgrade
Transfer-Encoding: chunked
Sec-Websocket-Accept: aFYFO80e6Cf2ijYLvl+mWNmnXtg=
Sec-Websocket-Extensions: permessage-deflate
Content-Type: application/octet-stream
Date: Wed, 20 Dec 2017 14:17:57 GMT
Server: Python/3.6 aiohttp/2.3.5
EndTime: 15:17:58.104
ReceivedBytes: 0
SentBytes: 0
Á+ªV*©,HU²RPJ,-É�ÏÏVÒQPÊH�/K-*ÎÌÏ�I�è�Zê�)Õ� `
Base64 of data:
SFRUUC8xLjEgMTAxIFN3aXRjaGluZyBQcm90b2NvbHMNClVwZ3JhZGU6IHdlYnNvY2tldA0KQ29ubmVjdGlvbjogdXBncmFkZQ0KVHJhbnNmZXItRW5jb2Rpbmc6IGNodW5rZWQNClNlYy1XZWJzb2NrZXQtQWNjZXB0OiBhRllGTzgwZTZDZjJpallMdmwrbVdObW5YdGc9DQpTZWMtV2Vic29ja2V0LUV4dGVuc2lvbnM6IHBlcm1lc3NhZ2UtZGVmbGF0ZQ0KQ29udGVudC1UeXBlOiBhcHBsaWNhdGlvbi9vY3RldC1zdHJlYW0NCkRhdGU6IFdlZCwgMjAgRGVjIDIwMTcgMTQ6MTc6NTcgR01UDQpTZXJ2ZXI6IFB5dGhvbi8zLjYgYWlvaHR0cC8yLjMuNQ0KRW5kVGltZTogMTU6MTc6NTguMTA0DQpSZWNlaXZlZEJ5dGVzOiAwDQpTZW50Qnl0ZXM6IDANCg0KwSuqViqpLEhVslJQSiwtyYjPz1bSUVDKSIwvSy0qzszPA0kY6Jla6hkp1QIA
The upgraded socket connection is missing
Á
in its buffer.Works if i use npm: http-parser-js.
The text was updated successfully, but these errors were encountered: