__toString() 공개 메소드

The string representation of the Response is the same as the one that will be sent to the client only if the prepare() method has been called before.
또한 보기: prepare()
public __toString ( ) : string
리턴 string The Response as an HTTP string
예제 #1
0
 public function __toString()
 {
     $this->headers->set('Content-Length', strlen($this->getContent()));
     return parent::__toString();
 }
예제 #2
0
 public function testDefaultContentType()
 {
     $headerMock = $this->getMock('Symfony\\Component\\HttpFoundation\\ResponseHeaderBag', array('set'));
     $headerMock->expects($this->at(0))->method('set')->with('Content-Type', 'text/html; charset=UTF-8');
     $headerMock->expects($this->at(1))->method('set')->with('Content-Type', 'text/html; charset=Foo');
     $response = new Response();
     $response->headers = $headerMock;
     // verify first set()
     $response->__toString();
     $response->headers->remove('Content-Type');
     $response->setCharset('Foo');
     // verify second set()
     $response->__toString();
 }
예제 #3
0
 public function testContentTypeCharset()
 {
     $response = new Response();
     $response->headers->set('Content-Type', 'text/css');
     // force fixContentType() to be called
     $response->__toString();
     $this->assertEquals('text/css; charset=UTF-8', $response->headers->get('Content-Type'));
 }