# Class HttpSoft\Message\Request

Class, that implements Psr\Http\Message\RequestInterface.

If you need an HTTP request component for a Server-Side Application, use HttpSoft\Message\ServerRequest.

Source code on GitHub.

use HttpSoft\Message\Request;
use HttpSoft\Message\Uri;

$request = new Request();
$request->getMethod(); // 'GET'
$request->getProtocolVersion(); // '1.1'
$request->getBody()->getContents(); // ''
(string) $request->getUri(); // ''
$request->getHeader('host'); // []
$request->getHeaders(); // []

$request = new Request('POST', 'http://example.com', ['Content-Type' => 'text/html'], 'data://,Content', '1.0');
$request->getMethod(); // 'POST'
$request->getProtocolVersion(); // '1.0'
$request->getBody()->getContents(); // 'Content'
(string) $request->getUri(); // 'http://example.com'
$request->getHeader('host'); // ['example.com']
$request->getHeaders(); // ['Host' => ['example.com'], 'Content-Type' => ['text/html']]

$newRequest = $request->withUri(new Uri('http://example.org'));
(string) $newRequest->getUri(); // 'http://example.org'
$newRequest->getHeader('host'); // ['example.org']
$newRequest->getHeaders(); // ['Host' => ['example.org'], 'Content-Type' => ['text/html']]

# Public methods

See the original detailed description of the methods in the Psr\Http\Message\RequestInterface.

/**
 * @param string $method
 * @param UriInterface|string $uri
 * @param array $headers
 * @param StreamInterface|string|resource $body
 * @param string $protocol
 */
public function __construct(
    string $method = 'GET',
    $uri = '',
    array $headers = [],
    $body = 'php://temp',
    string $protocol = '1.1'
);

All other methods with descriptions are in the used traits (HttpSoft\Message\RequestTrait and HttpSoft\Message\MessageTrait).