예제 #1
0
 /**
  * Response constructor.
  *
  * Example: $response = new Response(new Stream('php://temp', 'wb+'));
  *
  * @param StreamInterface $stream       StreamInterface instance.
  * @param string $statusCode            Response status code.
  * @param string $reasonPhrase          Response reason phrase.
  */
 public function __construct(StreamInterface $stream, $statusCode = '', $reasonPhrase = '')
 {
     parent::__construct();
     // Row stream for response body.
     $this->stream = $stream;
     // Set status code.
     $this->statusCode = $statusCode === '' ? 200 : $this->checkStatusCode($statusCode);
     // Set reason phrase.
     $this->reasonPhrase = $reasonPhrase === '' ? 'OK' : $this->checkReasonPhrase($reasonPhrase);
 }
예제 #2
0
 /**
  * Response constructor.
  *
  * @param Stream $stream        Stream instance.
  * @param string $statusCode    Response status code.
  * @param string $reasonPhrase  Response reason phrase.
  */
 public function __construct(Stream $stream, $statusCode = '', $reasonPhrase = '')
 {
     // Message construct
     parent::__construct();
     // Row stream for response body.
     $this->stream = $stream->createStream('php://temp', 'wb+');
     // Set status code.
     $this->statusCode = $statusCode === '' ? 200 : $this->checkStatusCode($statusCode);
     // Set reason phrase.
     $this->reasonPhrase = $reasonPhrase === '' ? 'OK' : $this->checkReasonPhrase($reasonPhrase);
 }