Internally, this implementation builds on top of an existing outgoing * request message and only adds support for streaming. This base class is * considered an implementation detail that may change in the future. * * @see RequestInterface */ final class Request extends BaseRequest implements RequestInterface { /** * @param string $method HTTP method for the request. * @param string|UriInterface $url URL for the request. * @param array $headers Headers for the message. * @param string|ReadableStreamInterface|StreamInterface $body Message body. * @param string $version HTTP protocol version. * @throws \InvalidArgumentException for an invalid URL or body */ public function __construct( $method, $url, array $headers = array(), $body = '', $version = '1.1' ) { if (\is_string($body)) { $body = new BufferedBody($body); } elseif ($body instanceof ReadableStreamInterface && !$body instanceof StreamInterface) { $body = new ReadableBodyStream($body); } elseif (!$body instanceof StreamInterface) { throw new \InvalidArgumentException('Invalid request body given'); } parent::__construct($method, $url, $headers, $body, $version); } }