[Refactor] Fixing stuff for Chris
Fixing sub protocol agreement between server and client
This commit is contained in:
parent
8a2b9153ab
commit
c6a801f1ef
@ -23,7 +23,6 @@ class Hixie76 implements VersionInterface {
|
||||
/**
|
||||
* @param string
|
||||
* @return string
|
||||
* @todo Unhack this mess...or wait for Hixie to die (HURRY UP APPLE)
|
||||
*/
|
||||
public function handshake(RequestInterface $request) {
|
||||
$body = $this->sign($request->getHeader('Sec-WebSocket-Key1'), $request->getHeader('Sec-WebSocket-Key2'), $request->getBody());
|
||||
@ -34,12 +33,8 @@ class Hixie76 implements VersionInterface {
|
||||
, 'Sec-WebSocket-Origin' => $request->getHeader('Origin')
|
||||
, 'Sec-WebSocket-Location' => 'ws://' . $request->getHeader('Host') . $request->getPath()
|
||||
);
|
||||
if ($request->getHeader('Sec-WebSocket-Protocol')) {
|
||||
$headers['Sec-WebSocket-Protocol'] = $request->getHeader('Sec-WebSocket-Protocol');
|
||||
}
|
||||
|
||||
$response = new \Guzzle\Http\Message\Response('101', $headers, $body);
|
||||
return $response;
|
||||
return new \Guzzle\Http\Message\Response('101', $headers, $body);
|
||||
}
|
||||
|
||||
public function newMessage() {
|
||||
|
@ -79,6 +79,25 @@ class WebSocketComponent implements MessageComponentInterface {
|
||||
$response = $from->WebSocket->version->handshake($from->WebSocket->headers);
|
||||
$from->WebSocket->handshake = true;
|
||||
|
||||
|
||||
|
||||
// This block is to be moved/changed later
|
||||
|
||||
$agreed_protocols = array();
|
||||
|
||||
$requested_protocols = $from->WebSocket->headers->getTokenizedHeader('Sec-WebSocket-Protocol', ',');
|
||||
|
||||
foreach ($this->accepted_subprotocols as $sub_protocol) {
|
||||
if (false !== $requested_protocols->hasValue($sub_protocol)) {
|
||||
$agreed_protocols[] = $sub_protocol;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($agreed_protocols) > 0) {
|
||||
|
||||
// $response['Sec-WebSocket-Protocol'] = implode(',', $agreed_protocols);
|
||||
$response->setHeader('Sec-WebSocket-Protocol', implode(',', $agreed_protocols));
|
||||
}
|
||||
$header = (string)$response;
|
||||
|
||||
$comp = $this->_factory->newComposite();
|
||||
|
Loading…
Reference in New Issue
Block a user