/** * Many RESTful frameworks omit the text status from the header. That * provides a response like "HTTP/1.1 200". Prevent an Undefined offset * by checking to see how many parts of the status line are provided * before trying to assign them. * * @covers Guzzle\Http\Message\Request::receiveResponseHeader */ public function testReceivingShortStatusLineResponse() { $request = new Request('GET', $this->getServer()->getUrl()); $request->receiveResponseHeader('HTTP/1.1 200'); $this->assertSame(200, $request->getResponse()->getStatusCode()); $this->assertSame('OK', $request->getResponse()->getReasonPhrase()); }
/** * Users sometimes want to use a custom stream when receiving a response body. * Because of the various potential for retrying failed requests, the stream * specified by the user should only be written to in the event that a * successful response was received. Otherwise, a new temp stream is created * to store the body of the failed request. * * @covers Guzzle\Http\Message\Request::receiveResponseHeader */ public function testReceivingUnsuccessfulResponseUsesOtherResponseBody() { $request = new Request('GET', $this->getServer()->getUrl()); $body = EntityBody::factory(); $request->setResponseBody($body); $request->receiveResponseHeader('HTTP/1.1 503 Service Unavailable'); $this->assertNotSame($body, $request->getResponse()->getBody()); }