示例#1
2
文件: CookieJar.php 项目: kingsj/core
 /**
  * {@inheritdoc}
  */
 public function updateFromResponse(Response $response, $uri = null)
 {
     foreach ($response->getHeader('Set-Cookie', false) as $cookie) {
         $this->set(Cookie::fromString(urldecode($cookie), $uri));
     }
 }
示例#2
0
 public function testMagicToStringWithMultipleSetCookieHeader()
 {
     $headers = array('content-type' => 'text/html; charset=utf-8', 'set-cookie' => array('foo=bar', 'bar=foo'));
     $expected = 'content-type: text/html; charset=utf-8' . "\n";
     $expected .= 'set-cookie: foo=bar' . "\n";
     $expected .= 'set-cookie: bar=foo' . "\n\n";
     $expected .= 'foo';
     $response = new Response('foo', 304, $headers);
     $this->assertEquals($expected, $response->__toString(), '->__toString() returns the headers and the content as a string');
 }
示例#3
0
文件: Client.php 项目: aWEBoLabs/taxi
 /**
  * Reads response meta tags to guess content-type charset.
  *
  * @param Response $response
  *
  * @return Response
  */
 protected function filterResponse($response)
 {
     $contentType = $response->getHeader('Content-Type');
     if (!$contentType || false === strpos($contentType, 'charset=')) {
         if (preg_match('/\\<meta[^\\>]+charset *= *["\']?([a-zA-Z\\-0-9]+)/i', $response->getContent(), $matches)) {
             $headers = $response->getHeaders();
             $headers['Content-Type'] = $contentType . ';charset=' . $matches[1];
             $response = new Response($response->getContent(), $response->getStatus(), $headers);
         }
     }
     return parent::filterResponse($response);
 }
示例#4
0
 /**
  * @return $this
  */
 public function assertSuccess()
 {
     $this->assertEquals(200, $this->response->getStatusCode());
     return $this;
 }
 public function getContent()
 {
     $metadata = array('content-type' => $this->getHeader('Content-Type', true, true), 'url' => $this->getUrl());
     return $this->getCharsetFront()->convert(parent::getContent(), $metadata);
 }
示例#6
0
 public function testMagicToString()
 {
     $response = new Response('foo', 304, array('foo' => 'bar'));
     $this->assertEquals("foo: bar\n\nfoo", $response->__toString(), '->__toString() returns the headers and the content as a string');
 }