Edit File by line
/home/barbar84/public_h.../wp-inclu.../Requests
File: Response.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* HTTP response class
[2] Fix | Delete
*
[3] Fix | Delete
* Contains a response from Requests::request()
[4] Fix | Delete
* @package Requests
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* HTTP response class
[9] Fix | Delete
*
[10] Fix | Delete
* Contains a response from Requests::request()
[11] Fix | Delete
* @package Requests
[12] Fix | Delete
*/
[13] Fix | Delete
class Requests_Response {
[14] Fix | Delete
/**
[15] Fix | Delete
* Constructor
[16] Fix | Delete
*/
[17] Fix | Delete
public function __construct() {
[18] Fix | Delete
$this->headers = new Requests_Response_Headers();
[19] Fix | Delete
$this->cookies = new Requests_Cookie_Jar();
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* Response body
[24] Fix | Delete
*
[25] Fix | Delete
* @var string
[26] Fix | Delete
*/
[27] Fix | Delete
public $body = '';
[28] Fix | Delete
[29] Fix | Delete
/**
[30] Fix | Delete
* Raw HTTP data from the transport
[31] Fix | Delete
*
[32] Fix | Delete
* @var string
[33] Fix | Delete
*/
[34] Fix | Delete
public $raw = '';
[35] Fix | Delete
[36] Fix | Delete
/**
[37] Fix | Delete
* Headers, as an associative array
[38] Fix | Delete
*
[39] Fix | Delete
* @var Requests_Response_Headers Array-like object representing headers
[40] Fix | Delete
*/
[41] Fix | Delete
public $headers = array();
[42] Fix | Delete
[43] Fix | Delete
/**
[44] Fix | Delete
* Status code, false if non-blocking
[45] Fix | Delete
*
[46] Fix | Delete
* @var integer|boolean
[47] Fix | Delete
*/
[48] Fix | Delete
public $status_code = false;
[49] Fix | Delete
[50] Fix | Delete
/**
[51] Fix | Delete
* Protocol version, false if non-blocking
[52] Fix | Delete
* @var float|boolean
[53] Fix | Delete
*/
[54] Fix | Delete
public $protocol_version = false;
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* Whether the request succeeded or not
[58] Fix | Delete
*
[59] Fix | Delete
* @var boolean
[60] Fix | Delete
*/
[61] Fix | Delete
public $success = false;
[62] Fix | Delete
[63] Fix | Delete
/**
[64] Fix | Delete
* Number of redirects the request used
[65] Fix | Delete
*
[66] Fix | Delete
* @var integer
[67] Fix | Delete
*/
[68] Fix | Delete
public $redirects = 0;
[69] Fix | Delete
[70] Fix | Delete
/**
[71] Fix | Delete
* URL requested
[72] Fix | Delete
*
[73] Fix | Delete
* @var string
[74] Fix | Delete
*/
[75] Fix | Delete
public $url = '';
[76] Fix | Delete
[77] Fix | Delete
/**
[78] Fix | Delete
* Previous requests (from redirects)
[79] Fix | Delete
*
[80] Fix | Delete
* @var array Array of Requests_Response objects
[81] Fix | Delete
*/
[82] Fix | Delete
public $history = array();
[83] Fix | Delete
[84] Fix | Delete
/**
[85] Fix | Delete
* Cookies from the request
[86] Fix | Delete
*
[87] Fix | Delete
* @var Requests_Cookie_Jar Array-like object representing a cookie jar
[88] Fix | Delete
*/
[89] Fix | Delete
public $cookies = array();
[90] Fix | Delete
[91] Fix | Delete
/**
[92] Fix | Delete
* Is the response a redirect?
[93] Fix | Delete
*
[94] Fix | Delete
* @return boolean True if redirect (3xx status), false if not.
[95] Fix | Delete
*/
[96] Fix | Delete
public function is_redirect() {
[97] Fix | Delete
$code = $this->status_code;
[98] Fix | Delete
return in_array($code, array(300, 301, 302, 303, 307)) || $code > 307 && $code < 400;
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
/**
[102] Fix | Delete
* Throws an exception if the request was not successful
[103] Fix | Delete
*
[104] Fix | Delete
* @throws Requests_Exception If `$allow_redirects` is false, and code is 3xx (`response.no_redirects`)
[105] Fix | Delete
* @throws Requests_Exception_HTTP On non-successful status code. Exception class corresponds to code (e.g. {@see Requests_Exception_HTTP_404})
[106] Fix | Delete
* @param boolean $allow_redirects Set to false to throw on a 3xx as well
[107] Fix | Delete
*/
[108] Fix | Delete
public function throw_for_status($allow_redirects = true) {
[109] Fix | Delete
if ($this->is_redirect()) {
[110] Fix | Delete
if (!$allow_redirects) {
[111] Fix | Delete
throw new Requests_Exception('Redirection not allowed', 'response.no_redirects', $this);
[112] Fix | Delete
}
[113] Fix | Delete
}
[114] Fix | Delete
elseif (!$this->success) {
[115] Fix | Delete
$exception = Requests_Exception_HTTP::get_class($this->status_code);
[116] Fix | Delete
throw new $exception(null, $this);
[117] Fix | Delete
}
[118] Fix | Delete
}
[119] Fix | Delete
}
[120] Fix | Delete
[121] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function