@@ -109,13 +109,13 @@ private function handshake(string $data): bool
109
109
foreach ($ lines as $ line ) {
110
110
$ line = chop ($ line );
111
111
if (preg_match ('/\A(\S+): (.*)\z/ ' , $ line , $ matches )) {
112
- $ headers [$ matches [1 ]] = $ matches [2 ];
112
+ $ headers [ strtolower ( $ matches [1 ] ) ] = $ matches [2 ];
113
113
}
114
114
}
115
115
116
116
// check for supported websocket version:
117
- if (!isset ($ headers ['Sec-WebSocket-Version ' ]) || $ headers ['Sec-WebSocket-Version ' ] < 6 ) {
118
- $ this ->log ('Unsupported websocket version. ' );
117
+ if (!isset ($ headers ['sec-websocket-version ' ]) || $ headers ['sec-websocket-version ' ] < 6 ) {
118
+ $ this ->log ('Unsupported websocket version. ' );
119
119
$ this ->sendHttpResponse (501 );
120
120
stream_socket_shutdown ($ this ->socket , STREAM_SHUT_RDWR );
121
121
$ this ->server ->removeClientOnError ($ this );
@@ -124,8 +124,8 @@ private function handshake(string $data): bool
124
124
125
125
// check origin:
126
126
if ($ this ->server ->getCheckOrigin () === true ) {
127
- $ origin = (isset ($ headers ['Sec-WebSocket-Origin ' ])) ? $ headers ['Sec-WebSocket-Origin ' ] : '' ;
128
- $ origin = (isset ($ headers ['Origin ' ])) ? $ headers ['Origin ' ] : $ origin ;
127
+ $ origin = (isset ($ headers ['sec-websocket-origin ' ])) ? $ headers ['sec-websocket-origin ' ] : '' ;
128
+ $ origin = (isset ($ headers ['origin ' ])) ? $ headers ['origin ' ] : $ origin ;
129
129
if (empty ($ origin )) {
130
130
$ this ->log ('No origin provided. ' );
131
131
$ this ->sendHttpResponse (401 );
@@ -144,13 +144,13 @@ private function handshake(string $data): bool
144
144
}
145
145
146
146
// do handyshake: (hybi-10)
147
- $ secKey = $ headers ['Sec-WebSocket-Key ' ];
147
+ $ secKey = $ headers ['sec-websocket-key ' ];
148
148
$ secAccept = base64_encode (pack ('H* ' , sha1 ($ secKey . '258EAFA5-E914-47DA-95CA-C5AB0DC85B11 ' )));
149
149
$ response = "HTTP/1.1 101 Switching Protocols \r\n" ;
150
150
$ response .= "Upgrade: websocket \r\n" ;
151
151
$ response .= "Connection: Upgrade \r\n" ;
152
152
$ response .= "Sec-WebSocket-Accept: " . $ secAccept . "\r\n" ;
153
- if (isset ($ headers ['Sec-WebSocket-Protocol ' ]) && !empty ($ headers ['Sec-WebSocket-Protocol ' ])) {
153
+ if (isset ($ headers ['sec-websocket-protocol ' ]) && !empty ($ headers ['sec-websocket-protocol ' ])) {
154
154
$ response .= "Sec-WebSocket-Protocol: " . substr ($ path , 1 ) . "\r\n" ;
155
155
}
156
156
$ response .= "\r\n" ;
0 commit comments