{"action":"created","issue":{"url":"https://api.github.com/repos/icicleio/Http/issues/1","labels_url":"https://api.github.com/repos/icicleio/Http/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/icicleio/Http/issues/1/comments","events_url":"https://api.github.com/repos/icicleio/Http/issues/1/events","html_url":"https://github.com/icicleio/Http/issues/1","id":83937732,"number":1,"title":"How to process with \"Connection: upgrade\" requests","user":{"login":"mtymek","id":777893,"avatar_url":"https://avatars.githubusercontent.com/u/777893?v=3","gravatar_id":"","url":"https://api.github.com/users/mtymek","html_url":"https://github.com/mtymek","followers_url":"https://api.github.com/users/mtymek/followers","following_url":"https://api.github.com/users/mtymek/following{/other_user}","gists_url":"https://api.github.com/users/mtymek/gists{/gist_id}","starred_url":"https://api.github.com/users/mtymek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtymek/subscriptions","organizations_url":"https://api.github.com/users/mtymek/orgs","repos_url":"https://api.github.com/users/mtymek/repos","events_url":"https://api.github.com/users/mtymek/events{/privacy}","received_events_url":"https://api.github.com/users/mtymek/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-06-02T09:32:22Z","updated_at":"2015-06-07T19:07:24Z","closed_at":"2015-06-07T19:07:24Z","body":"Hi Aaron,\r\n\r\nI'm playing around with building simple WebSocket implementation over icicle libs - for fun and learning purposes. \r\nI was able to easily hack something around base `icicle` library, but interacting with `icicle/http` is a different story. I can complete the handshake and send headers back, but after that I'm not able to read input anymore. Here's what I'm trying to do:\r\n\r\n```php\r\nclass WebSocketMiddleware\r\n{\r\n    public function __invoke(RequestInterface $request, ClientInterface $client)\r\n    {\r\n        echo \"Handshake\\n\";\r\n        $response = new Response(\"101\");\r\n        $response = $response->withHeader('Upgrade', 'websocket')\r\n            ->withHeader('Connection', 'Upgrade')\r\n            ->withHeader(\r\n                \"Sec-WebSocket-Accept\",\r\n                base64_encode(\r\n                    sha1(\r\n                        $request->getHeaderLine('Sec-WebSocket-Key') . \"258EAFA5-E914-47DA-95CA-C5AB0DC85B11\",\r\n                        true\r\n                    )\r\n                )\r\n            );\r\n\r\n        yield $response;\r\n\r\n        echo \"Read loop\\n\";\r\n        $stream = $request->getBody();\r\n        while ($stream->isReadable()) {\r\n            // this does nothing\r\n            $x = (yield $stream->read(1));\r\n            echo $x, \"\\n\";\r\n        }\r\n    }\r\n}\r\n```\r\n\r\n```php\r\n$server = new Server(new WebSocketMiddleware());\r\n$server->listen(8080);\r\nLoop\\run();\r\n```\r\n\r\nAfter sending response headers, I want to echo everything I receive from user, but nothing happens.\r\nCan you point me in right direction?"},"comment":{"url":"https://api.github.com/repos/icicleio/Http/issues/comments/109789160","html_url":"https://github.com/icicleio/Http/issues/1#issuecomment-109789160","issue_url":"https://api.github.com/repos/icicleio/Http/issues/1","id":109789160,"user":{"login":"mtymek","id":777893,"avatar_url":"https://avatars.githubusercontent.com/u/777893?v=3","gravatar_id":"","url":"https://api.github.com/users/mtymek","html_url":"https://github.com/mtymek","followers_url":"https://api.github.com/users/mtymek/followers","following_url":"https://api.github.com/users/mtymek/following{/other_user}","gists_url":"https://api.github.com/users/mtymek/gists{/gist_id}","starred_url":"https://api.github.com/users/mtymek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtymek/subscriptions","organizations_url":"https://api.github.com/users/mtymek/orgs","repos_url":"https://api.github.com/users/mtymek/repos","events_url":"https://api.github.com/users/mtymek/events{/privacy}","received_events_url":"https://api.github.com/users/mtymek/received_events","type":"User","site_admin":false},"created_at":"2015-06-07T19:07:24Z","updated_at":"2015-06-07T19:07:24Z","body":"Thanks, it's exactly what I was looking for! Looking forward to see your WS code."}}