本文整理汇总了PHP中Response::getContent方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::getContent方法的具体用法?PHP Response::getContent怎么用?PHP Response::getContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Response
的用法示例。
在下文中一共展示了Response::getContent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIfContentIsAppendedCorrectly
/**
* @test
*/
public function testIfContentIsAppendedCorrectly()
{
$response = new Response();
$response->setContent('<html>');
$this->assertEquals('<html>', $response->getContent());
$response->appendContent('</html>');
$this->assertEquals('<html></html>', $response->getContent());
}
示例2: testRebuild
public function testRebuild()
{
$expectedContent = ['foo' => 'bar'];
$expectedHeaders = new \Phalcon\Http\Response\Headers();
$expectedHeaders->set('Status', '200 OK');
$expectedHeaders->set('HTTP/1.1 200 OK', null);
$this->response->rebuild(['foo' => 'bar']);
$this->assertEquals($expectedContent, $this->response->getContent());
$this->assertEquals($expectedHeaders, $this->response->getHeaders());
}
示例3: handle
/**
* @param Response $response
*/
public function handle(Response $response)
{
foreach ($response->getHeaders() as $header) {
header($header);
}
echo $response->getContent();
}
示例4: testSetError
/** @dataProvider provideSetError */
public function testSetError($expected, $statusCode, $error, $error_description = null, $error_uri = null)
{
$response = new Response();
$response->setError($statusCode, $error, $error_description, $error_uri);
$this->assertEquals($expected, $response->getContent());
$this->assertEquals($statusCode, $response->getStatusCode());
}
示例5: createTokenFromResponse
public function createTokenFromResponse(Response $response)
{
$token = json_decode($response->getContent(), true);
if (isset($token['access_token'])) {
return new Token($token['access_token'], $token['response_token']);
}
return false;
}
示例6: buildMessage
public function buildMessage(Response $response)
{
$str = '';
$str .= $response->getStatus();
$str .= "\nURL:\n" . $response->getUrl();
$str .= "\nPARAMS:\n" . var_export($response->getParams(), true);
$str .= "\nRESPONSE HEADER:\n" . var_export($response->getHeaders(), true);
$str .= "\nRESPONSE CONTENT:\n" . substr($response->getContent(), 0, 200);
return $str;
}
示例7: __construct
/**
* @param Response $response
*/
public function __construct(Response $response)
{
$content = json_decode($response->getContent(), TRUE);
if ($content !== NULL && is_array($content)) {
foreach ($content as $sectionIdentifier => $sectionData) {
$section = new ResponseSection($sectionIdentifier, $sectionData);
$this->sections[$sectionIdentifier] = $section;
}
}
}
示例8: createTemplate
/**
*
* @param Response $response
* @return string
*/
private function createTemplate($response)
{
$content = $response->getContent();
if ($content instanceof \Exception) {
$templateContent = $this->createExceptionContent($content);
} else {
$templateContent = $this->createObjectContent($content);
}
$template = '<!DOCTYPE html>
<HTML>
<HEAD>
</HEAD>
<BODY>' . $templateContent . '</BODY>
</HEAD>
';
return $template;
}
示例9: process_with_exception
/**
* Process this Request when an exception occured
*
* @param Request $request
* @param Response $response
* @param Exception $exception
* @return Response
*/
public static function process_with_exception(Request $request, Response $response, Exception $exception)
{
$body = $response->getContent();
if (ob_get_length()) {
ob_end_clean();
}
$template = ActionView::factory('php');
$template->assign('error', $exception);
$template->assign('request', $request);
$template->assign('response', $response);
$template->assign('body', $body);
$text = $template->render_file(MEDICK_PATH . '/libs/action/controller/templates/error.phtml');
$response->setStatus(HTTPResponse::SC_INTERNAL_SERVER_ERROR);
$response->setContent($text);
return $response;
}
示例10: testSetContent
public function testSetContent()
{
$response = new Response('first');
$response->setContent('second');
$this->assertEquals('second', $response->getContent());
}
示例11: filterResponse
/**
* Converts the HttpKernel response to a BrowserKit response.
*
* @param Response $response A Response instance
*
* @return Response A Response instance
*/
protected function filterResponse($response)
{
return new DomResponse($response->getContent(), $response->getStatusCode(), $response->headers->all());
}
示例12: _sendResponse
/**
* Send Response to client
*
* @param $response
* @param String|null $flash
*/
private function _sendResponse($response, $flash = null)
{
try {
if ($response instanceof Response) {
switch (strtolower($response->getType())) {
case 'html':
$view = $this->getMainLayout();
$wrapped = Controller::renderit($view, array('content' => $response->getContent()));
//, 'flush' => $flash));
$response = new Response($wrapped);
break;
case 'ajax':
$response = new Response($response->getContent());
break;
}
$response->send();
} else {
throw new \Exception('Bad response', 500);
}
} catch (\Exception $e) {
new Response($this->renderError($e));
}
}
示例13: parse
/**
* @param Response $response
* @return array
*/
public function parse(Response $response)
{
return $this->convertXmlToArray($response->getContent());
}
示例14: parse
/**
* @inheritdoc
*/
public function parse(Response $response)
{
return json_decode($response->getContent(), true);
}
示例15: testWrite
public function testWrite()
{
$this->object->write('1');
$this->object->write('2');
$this->assertThat($this->object->getContent(), $this->equalTo('12'));
}