Skip to content

Instantly share code, notes, and snippets.

@WyriHaximus
Created November 15, 2015 20:44
Show Gist options
  • Select an option

  • Save WyriHaximus/966dc78c1d0771ea105b to your computer and use it in GitHub Desktop.

Select an option

Save WyriHaximus/966dc78c1d0771ea105b to your computer and use it in GitHub Desktop.
<?php
class Response implements ReadableStreamInterface
{
public function __construct(DuplexStreamInterface $stream, $protocol, $version, $code, $reasonPhrase, $headers)
{
$this->stream = $stream;
$this->protocol = $protocol;
$this->version = $version;
$this->code = $code;
$this->reasonPhrase = $reasonPhrase;
$this->headers = $headers;
if (isset($this->headers['Content-Encoding']) && $this->headers['Content-Encoding'] == 'gzip') {
$this->stream = $this->stream->pipe(ZlibFilterStream::createGzipDecompressor());
}
$this->stream->on('data', array($this, 'handleData'));
$this->stream->on('error', array($this, 'handleError'));
$this->stream->on('end', array($this, 'handleEnd'));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment