/** * @test */ public function it_gets_json_without_message_parameter() { $response = new \Response\Response(); $shouldOutPut = json_encode(array('status' => 'success')); $data = $response->writeJson('success'); $this->assertEquals($shouldOutPut, $data); }
/** * * @throws Response\Exception * @return Response\Response */ public function getResponse() { if ($this->_response === null) { $this->_connection->getResponse($this->_streamId); } if ($this->_response instanceof Response\Error) { throw $this->_response->getException(); } return $this->_response; }
/** * 设置立即重定向地址 * * @param string $url 重定向的地址 * @param bool $exitNow 立即退出,默认为否 */ public function redirect($url, $exitNow = false) { $this->response->redirect($url, $exitNow); }
public function sendResponse(Response\Response $response) { $buffer = $this->eventHTTPRequest->getOutputBuffer(); $buffer->add($response->getContent()); if ($contentType = $response->headers->get('Content-Type')) { $this->eventHTTPRequest->addHeader('Content-Type', $contentType, \EventHttpRequest::OUTPUT_HEADER); } $this->eventHTTPRequest->sendReply($response->getStatusCode(), $response->getStatusCode()); $this->eventHTTPRequest->free(); }