Skip to content

Commit 7dcd5e0

Browse files
hlovdalsitegui
authored andcommitted
Fix parse error, accept header values separated without space (#46)
The following example failed: $ socat - TCP:localhost:1234,crnl GET / HTTP/1.1 Connection: Upgrade,Keep-Alive Upgrade: websocket Sec-WebSocket-Key: hq0S1hpdldRhTHVwXBDPvg== Sec-WebSocket-Version: 13 Host: localhost:1234 HTTP/1.1 400 Bad Request $ but would have worked as expected with Connection: Upgrade, Keep-Alive
1 parent 28835a2 commit 7dcd5e0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Connection.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ Connection.prototype.checkHandshake = function (lines) {
387387
return false
388388
}
389389
if (this.headers.upgrade.toLowerCase() !== 'websocket' ||
390-
this.headers.connection.toLowerCase().split(', ').indexOf('upgrade') === -1) {
390+
this.headers.connection.toLowerCase().split(/\s*,\s*/).indexOf('upgrade') === -1) {
391391
this.emit('error', new Error('Invalid handshake: invalid Upgrade or Connection header'))
392392
return false
393393
}
@@ -450,7 +450,7 @@ Connection.prototype.answerHandshake = function (lines) {
450450
return false
451451
}
452452
if (this.headers.upgrade.toLowerCase() !== 'websocket' ||
453-
this.headers.connection.toLowerCase().split(', ').indexOf('upgrade') === -1) {
453+
this.headers.connection.toLowerCase().split(/\s*,\s*/).indexOf('upgrade') === -1) {
454454
return false
455455
}
456456
if (this.headers['sec-websocket-version'] !== '13') {

0 commit comments

Comments
 (0)