Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/updraftp.../vendor/guzzleht.../psr7/src
File: Response.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace GuzzleHttp\Psr7;
[2] Fix | Delete
[3] Fix | Delete
use Psr\Http\Message\ResponseInterface;
[4] Fix | Delete
use Psr\Http\Message\StreamInterface;
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* PSR-7 response implementation.
[8] Fix | Delete
*/
[9] Fix | Delete
class Response implements ResponseInterface
[10] Fix | Delete
{
[11] Fix | Delete
use MessageTrait;
[12] Fix | Delete
[13] Fix | Delete
/** @var array Map of standard HTTP status code/reason phrases */
[14] Fix | Delete
private static $phrases = [
[15] Fix | Delete
100 => 'Continue',
[16] Fix | Delete
101 => 'Switching Protocols',
[17] Fix | Delete
102 => 'Processing',
[18] Fix | Delete
200 => 'OK',
[19] Fix | Delete
201 => 'Created',
[20] Fix | Delete
202 => 'Accepted',
[21] Fix | Delete
203 => 'Non-Authoritative Information',
[22] Fix | Delete
204 => 'No Content',
[23] Fix | Delete
205 => 'Reset Content',
[24] Fix | Delete
206 => 'Partial Content',
[25] Fix | Delete
207 => 'Multi-status',
[26] Fix | Delete
208 => 'Already Reported',
[27] Fix | Delete
300 => 'Multiple Choices',
[28] Fix | Delete
301 => 'Moved Permanently',
[29] Fix | Delete
302 => 'Found',
[30] Fix | Delete
303 => 'See Other',
[31] Fix | Delete
304 => 'Not Modified',
[32] Fix | Delete
305 => 'Use Proxy',
[33] Fix | Delete
306 => 'Switch Proxy',
[34] Fix | Delete
307 => 'Temporary Redirect',
[35] Fix | Delete
400 => 'Bad Request',
[36] Fix | Delete
401 => 'Unauthorized',
[37] Fix | Delete
402 => 'Payment Required',
[38] Fix | Delete
403 => 'Forbidden',
[39] Fix | Delete
404 => 'Not Found',
[40] Fix | Delete
405 => 'Method Not Allowed',
[41] Fix | Delete
406 => 'Not Acceptable',
[42] Fix | Delete
407 => 'Proxy Authentication Required',
[43] Fix | Delete
408 => 'Request Time-out',
[44] Fix | Delete
409 => 'Conflict',
[45] Fix | Delete
410 => 'Gone',
[46] Fix | Delete
411 => 'Length Required',
[47] Fix | Delete
412 => 'Precondition Failed',
[48] Fix | Delete
413 => 'Request Entity Too Large',
[49] Fix | Delete
414 => 'Request-URI Too Large',
[50] Fix | Delete
415 => 'Unsupported Media Type',
[51] Fix | Delete
416 => 'Requested range not satisfiable',
[52] Fix | Delete
417 => 'Expectation Failed',
[53] Fix | Delete
418 => 'I\'m a teapot',
[54] Fix | Delete
422 => 'Unprocessable Entity',
[55] Fix | Delete
423 => 'Locked',
[56] Fix | Delete
424 => 'Failed Dependency',
[57] Fix | Delete
425 => 'Unordered Collection',
[58] Fix | Delete
426 => 'Upgrade Required',
[59] Fix | Delete
428 => 'Precondition Required',
[60] Fix | Delete
429 => 'Too Many Requests',
[61] Fix | Delete
431 => 'Request Header Fields Too Large',
[62] Fix | Delete
451 => 'Unavailable For Legal Reasons',
[63] Fix | Delete
500 => 'Internal Server Error',
[64] Fix | Delete
501 => 'Not Implemented',
[65] Fix | Delete
502 => 'Bad Gateway',
[66] Fix | Delete
503 => 'Service Unavailable',
[67] Fix | Delete
504 => 'Gateway Time-out',
[68] Fix | Delete
505 => 'HTTP Version not supported',
[69] Fix | Delete
506 => 'Variant Also Negotiates',
[70] Fix | Delete
507 => 'Insufficient Storage',
[71] Fix | Delete
508 => 'Loop Detected',
[72] Fix | Delete
511 => 'Network Authentication Required',
[73] Fix | Delete
];
[74] Fix | Delete
[75] Fix | Delete
/** @var string */
[76] Fix | Delete
private $reasonPhrase = '';
[77] Fix | Delete
[78] Fix | Delete
/** @var int */
[79] Fix | Delete
private $statusCode = 200;
[80] Fix | Delete
[81] Fix | Delete
/**
[82] Fix | Delete
* @param int $status Status code
[83] Fix | Delete
* @param array $headers Response headers
[84] Fix | Delete
* @param string|resource|StreamInterface|null $body Response body
[85] Fix | Delete
* @param string $version Protocol version
[86] Fix | Delete
* @param string|null $reason Reason phrase (when empty a default will be used based on the status code)
[87] Fix | Delete
*/
[88] Fix | Delete
public function __construct(
[89] Fix | Delete
$status = 200,
[90] Fix | Delete
array $headers = [],
[91] Fix | Delete
$body = null,
[92] Fix | Delete
$version = '1.1',
[93] Fix | Delete
$reason = null
[94] Fix | Delete
) {
[95] Fix | Delete
$this->assertStatusCodeIsInteger($status);
[96] Fix | Delete
$status = (int) $status;
[97] Fix | Delete
$this->assertStatusCodeRange($status);
[98] Fix | Delete
[99] Fix | Delete
$this->statusCode = $status;
[100] Fix | Delete
[101] Fix | Delete
if ($body !== '' && $body !== null) {
[102] Fix | Delete
$this->stream = Utils::streamFor($body);
[103] Fix | Delete
}
[104] Fix | Delete
[105] Fix | Delete
$this->setHeaders($headers);
[106] Fix | Delete
if ($reason == '' && isset(self::$phrases[$this->statusCode])) {
[107] Fix | Delete
$this->reasonPhrase = self::$phrases[$this->statusCode];
[108] Fix | Delete
} else {
[109] Fix | Delete
$this->reasonPhrase = (string) $reason;
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
$this->protocol = $version;
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
public function getStatusCode()
[116] Fix | Delete
{
[117] Fix | Delete
return $this->statusCode;
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
public function getReasonPhrase()
[121] Fix | Delete
{
[122] Fix | Delete
return $this->reasonPhrase;
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
public function withStatus($code, $reasonPhrase = '')
[126] Fix | Delete
{
[127] Fix | Delete
$this->assertStatusCodeIsInteger($code);
[128] Fix | Delete
$code = (int) $code;
[129] Fix | Delete
$this->assertStatusCodeRange($code);
[130] Fix | Delete
[131] Fix | Delete
$new = clone $this;
[132] Fix | Delete
$new->statusCode = $code;
[133] Fix | Delete
if ($reasonPhrase == '' && isset(self::$phrases[$new->statusCode])) {
[134] Fix | Delete
$reasonPhrase = self::$phrases[$new->statusCode];
[135] Fix | Delete
}
[136] Fix | Delete
$new->reasonPhrase = (string) $reasonPhrase;
[137] Fix | Delete
return $new;
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
private function assertStatusCodeIsInteger($statusCode)
[141] Fix | Delete
{
[142] Fix | Delete
if (filter_var($statusCode, FILTER_VALIDATE_INT) === false) {
[143] Fix | Delete
throw new \InvalidArgumentException('Status code must be an integer value.');
[144] Fix | Delete
}
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
private function assertStatusCodeRange($statusCode)
[148] Fix | Delete
{
[149] Fix | Delete
if ($statusCode < 100 || $statusCode >= 600) {
[150] Fix | Delete
throw new \InvalidArgumentException('Status code must be an integer value between 1xx and 5xx.');
[151] Fix | Delete
}
[152] Fix | Delete
}
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function