예제 #1
0
 public function testWithHeader()
 {
     $message = new Message();
     $message->withHeader('name', 'jan')->withAddedHeader('name', 'janhuang');
     $this->assertEquals(['jan', 'janhuang'], $message->getHeader('name'));
     $this->assertEquals('jan,janhuang', $message->getHeaderLine('name'));
 }
예제 #2
0
파일: Response.php 프로젝트: JanHuang/http
 /**
  * Response constructor.
  *
  * @param string $content
  * @param int $statusCode
  * @param array $headers
  */
 public function __construct($content = '', $statusCode = Response::HTTP_OK, array $headers = [])
 {
     $this->withBody(new Stream('php://memory', 'wb+'));
     $this->withStatus($statusCode);
     $this->withContent($content);
     parent::__construct(array_merge(static::HEADERS, $headers));
 }
예제 #3
0
파일: Request.php 프로젝트: JanHuang/http
 /**
  * Request constructor.
  *
  * @param $uri
  * @param array $headers
  * @param string $body
  */
 public function __construct($uri, array $headers = [], $body = 'php://memory')
 {
     $this->withUri(new Uri($uri));
     $this->withBody(new Stream($body));
     parent::__construct(array_merge(['USER_AGENT' => static::USER_AGENT], $headers));
 }