Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/updraftp.../vendor/guzzleht.../psr7/src
File: Request.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace GuzzleHttp\Psr7;
[2] Fix | Delete
[3] Fix | Delete
use InvalidArgumentException;
[4] Fix | Delete
use Psr\Http\Message\RequestInterface;
[5] Fix | Delete
use Psr\Http\Message\StreamInterface;
[6] Fix | Delete
use Psr\Http\Message\UriInterface;
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* PSR-7 request implementation.
[10] Fix | Delete
*/
[11] Fix | Delete
class Request implements RequestInterface
[12] Fix | Delete
{
[13] Fix | Delete
use MessageTrait;
[14] Fix | Delete
[15] Fix | Delete
/** @var string */
[16] Fix | Delete
private $method;
[17] Fix | Delete
[18] Fix | Delete
/** @var string|null */
[19] Fix | Delete
private $requestTarget;
[20] Fix | Delete
[21] Fix | Delete
/** @var UriInterface */
[22] Fix | Delete
private $uri;
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* @param string $method HTTP method
[26] Fix | Delete
* @param string|UriInterface $uri URI
[27] Fix | Delete
* @param array $headers Request headers
[28] Fix | Delete
* @param string|resource|StreamInterface|null $body Request body
[29] Fix | Delete
* @param string $version Protocol version
[30] Fix | Delete
*/
[31] Fix | Delete
public function __construct(
[32] Fix | Delete
$method,
[33] Fix | Delete
$uri,
[34] Fix | Delete
array $headers = [],
[35] Fix | Delete
$body = null,
[36] Fix | Delete
$version = '1.1'
[37] Fix | Delete
) {
[38] Fix | Delete
$this->assertMethod($method);
[39] Fix | Delete
if (!($uri instanceof UriInterface)) {
[40] Fix | Delete
$uri = new Uri($uri);
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
$this->method = strtoupper($method);
[44] Fix | Delete
$this->uri = $uri;
[45] Fix | Delete
$this->setHeaders($headers);
[46] Fix | Delete
$this->protocol = $version;
[47] Fix | Delete
[48] Fix | Delete
if (!isset($this->headerNames['host'])) {
[49] Fix | Delete
$this->updateHostFromUri();
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
if ($body !== '' && $body !== null) {
[53] Fix | Delete
$this->stream = Utils::streamFor($body);
[54] Fix | Delete
}
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
public function getRequestTarget()
[58] Fix | Delete
{
[59] Fix | Delete
if ($this->requestTarget !== null) {
[60] Fix | Delete
return $this->requestTarget;
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
$target = $this->uri->getPath();
[64] Fix | Delete
if ($target == '') {
[65] Fix | Delete
$target = '/';
[66] Fix | Delete
}
[67] Fix | Delete
if ($this->uri->getQuery() != '') {
[68] Fix | Delete
$target .= '?' . $this->uri->getQuery();
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
return $target;
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
public function withRequestTarget($requestTarget)
[75] Fix | Delete
{
[76] Fix | Delete
if (preg_match('#\s#', $requestTarget)) {
[77] Fix | Delete
throw new InvalidArgumentException(
[78] Fix | Delete
'Invalid request target provided; cannot contain whitespace'
[79] Fix | Delete
);
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
$new = clone $this;
[83] Fix | Delete
$new->requestTarget = $requestTarget;
[84] Fix | Delete
return $new;
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
public function getMethod()
[88] Fix | Delete
{
[89] Fix | Delete
return $this->method;
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
public function withMethod($method)
[93] Fix | Delete
{
[94] Fix | Delete
$this->assertMethod($method);
[95] Fix | Delete
$new = clone $this;
[96] Fix | Delete
$new->method = strtoupper($method);
[97] Fix | Delete
return $new;
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
public function getUri()
[101] Fix | Delete
{
[102] Fix | Delete
return $this->uri;
[103] Fix | Delete
}
[104] Fix | Delete
[105] Fix | Delete
public function withUri(UriInterface $uri, $preserveHost = false)
[106] Fix | Delete
{
[107] Fix | Delete
if ($uri === $this->uri) {
[108] Fix | Delete
return $this;
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
$new = clone $this;
[112] Fix | Delete
$new->uri = $uri;
[113] Fix | Delete
[114] Fix | Delete
if (!$preserveHost || !isset($this->headerNames['host'])) {
[115] Fix | Delete
$new->updateHostFromUri();
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
return $new;
[119] Fix | Delete
}
[120] Fix | Delete
[121] Fix | Delete
private function updateHostFromUri()
[122] Fix | Delete
{
[123] Fix | Delete
$host = $this->uri->getHost();
[124] Fix | Delete
[125] Fix | Delete
if ($host == '') {
[126] Fix | Delete
return;
[127] Fix | Delete
}
[128] Fix | Delete
[129] Fix | Delete
if (($port = $this->uri->getPort()) !== null) {
[130] Fix | Delete
$host .= ':' . $port;
[131] Fix | Delete
}
[132] Fix | Delete
[133] Fix | Delete
if (isset($this->headerNames['host'])) {
[134] Fix | Delete
$header = $this->headerNames['host'];
[135] Fix | Delete
} else {
[136] Fix | Delete
$header = 'Host';
[137] Fix | Delete
$this->headerNames['host'] = 'Host';
[138] Fix | Delete
}
[139] Fix | Delete
// Ensure Host is the first header.
[140] Fix | Delete
// See: http://tools.ietf.org/html/rfc7230#section-5.4
[141] Fix | Delete
$this->headers = [$header => [$host]] + $this->headers;
[142] Fix | Delete
}
[143] Fix | Delete
[144] Fix | Delete
private function assertMethod($method)
[145] Fix | Delete
{
[146] Fix | Delete
if (!is_string($method) || $method === '') {
[147] Fix | Delete
throw new \InvalidArgumentException('Method must be a non-empty string.');
[148] Fix | Delete
}
[149] Fix | Delete
}
[150] Fix | Delete
}
[151] Fix | Delete
[152] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function