Exemplo n.º 1
0
 /**
  * Constructor.
  *
  * @param null|int|string $status Optional; the status code,
  *
  * must be a 3-digit integer result code between 100 and 599
  * <!-- -->
  * @param null|string|resource|\Psr\Http\Message\StreamInterface $body Optional;
  *
  * the body of response
  * <!-- -->
  * @param null|array $headers Optional; the HTTP headers
  *
  * <!-- -->
  * @param null|string $protocol Optional; the version of HTTP protocol
  */
 public function __construct($status = null, $body = null, array $headers = null, $protocol = null)
 {
     parent::__construct($body, $headers, $protocol);
     if (null !== $status) {
         $this->setStatus($status);
     }
 }
Exemplo n.º 2
0
 /**
  * Constructor.
  *
  * @param null|string|resource|\Psr\Http\Message\StreamInterface $body Optional;
  *
  * null by default means "php://temp"
  * The body of request:
  * - the string as reference to resource as "scheme://target"
  * - or the resource to wrap
  * - or instance of stream
  * @param null|array                                 $headers  Optional; the request headers
  * @param null|string|\Psr\Http\Message\UriInterface $uri      Optional; the requested URI
  * @param null|string                                $method   Optional; null by default means
  *                                                             "GET". The request method
  * @param null|string                                $protocol Optional; null by default means
  *                                                             "1.1". The HTTP protocol version
  */
 public function __construct($body = null, array $headers = null, $uri = null, $method = null, $protocol = null)
 {
     parent::__construct($body, $headers, $protocol);
     // set uri after headers and preserve host
     if (null === $uri) {
         $uri = '';
     }
     $this->setUri($uri, true);
     if (null !== $method) {
         $this->setMethod($method);
     }
 }
Exemplo n.º 3
0
 public function testWithBodySetBody()
 {
     $message = new Message();
     $body = new Stream();
     $new = $message->withBody($body);
     $this->assertSame($body, $new->getBody());
 }