コード例 #1
0
 /**
  * Constructs an instance of this class.
  *
  * @param string           $method   method of the request
  * @param UriInterface     $uri      request URI
  * @param StreamInterface  $body     body of the request
  * @param HeaderCollection $headers  headers of the request
  * @param string           $protocol HTTP protocol version of the request
  */
 public function __construct(string $method, UriInterface $uri, StreamInterface $body, HeaderCollection $headers = null, string $protocol = '')
 {
     $this->method = new Method($method);
     $this->uri = $uri;
     $headers = $headers !== null ? $headers : new HeaderCollection();
     if (!$headers->has('Host') && $this->uri->getHost() != '') {
         $headers->set('Host', $this->buildHost($this->uri));
     }
     parent::__construct($body, $headers, $protocol);
 }
コード例 #2
0
 /**
  * Constructs an instance of this class.
  *
  * @param StreamInterface       $body    body of the response
  * @param int                   $status  HTTP status code of the response
  * @param HeaderCollection|null $headers headers of the response
  */
 public function __construct(StreamInterface $body, int $status = 200, HeaderCollection $headers = null)
 {
     parent::__construct($body, $headers);
     $this->status = new Status($status);
 }