public function testResponseContainsPoweredByHeader() { $io = new ServerStub(); $server = new Server($io); $server->on('request', function ($request, $response) { $response->writeHead(); $response->end(); }); $conn = new ConnectionStub(); $io->emit('connection', array($conn)); $data = $this->createGetRequest(); $conn->emit('data', array($data)); $this->assertContains("\r\nX-Powered-By: React/alpha\r\n", $conn->getData()); }
public function testServerRespondsToExpectContinue() { $io = new ServerStub(); $server = new Server($io); $conn = new ConnectionStub(); $io->emit('connection', array($conn)); $requestReceived = false; $postBody = '{"React":true}'; $httpRequestText = $this->createPostRequestWithExpect($postBody); $conn->emit('data', array($httpRequestText)); $server->on('request', function ($request, $_) use(&$requestReceived, $postBody) { $requestReceived = true; $this->assertEquals($postBody, $request->getBody()); }); // If server received Expect: 100-continue - the client won't send the body right away $this->assertEquals(false, $requestReceived); $this->assertEquals("HTTP/1.1 100 Continue\r\n\r\n", $conn->getData()); $conn->emit('data', array($postBody)); $this->assertEquals(true, $requestReceived); }