Ejemplo n.º 1
0
 /**
  * @return string
  */
 public function toString()
 {
     $str = $this->renderRequestLine() . "\r\n";
     if ($this->headers) {
         $str .= $this->headers->toString();
     }
     $str .= "\r\n";
     $str .= $this->getContent();
     return $str;
 }
Ejemplo n.º 2
0
 public function testHeadersCanBeCastToString()
 {
     $headers = new Headers();
     $headers->addHeaders(array('Foo' => 'bar', 'Baz' => 'baz'));
     $this->assertEquals('Foo: bar' . "\r\n" . 'Baz: baz' . "\r\n", $headers->toString());
 }
Ejemplo n.º 3
0
 public function testCastingToStringReturnsAllMultiHeaderValues()
 {
     $headers = new Headers();
     $cookie1 = new Header\SetCookie('foo', 'bar');
     $cookie2 = new Header\SetCookie('bar', 'baz');
     $headers->addHeader($cookie1);
     $headers->addHeader($cookie2);
     $string = $headers->toString();
     $expected = array('Set-Cookie: ' . $cookie1->getFieldValue(), 'Set-Cookie: ' . $cookie2->getFieldValue());
     $expected = implode("\r\n", $expected) . "\r\n";
     $this->assertEquals($expected, $string);
 }