File "Session.php"
Full path: /home/kosmetik/public_html/wp-includes/Requests/Session.php
File
size: 3.57 B
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Editor Back
<?php
class Requests_Session
{
public $url = null;
public $headers = array();
public $data = array();
public $options = array();
public function __construct($url = null, $headers = array(), $data = array(), $options = array())
{
$this->url = $url;
$this->headers = $headers;
$this->data = $data;
$this->options = $options;
if (empty($this->options['cookies'])) {
$this->options['cookies'] = new Requests_Cookie_Jar();
}
}
public function __get($key)
{
if (isset($this->options[$key])) {
return $this->options[$key];
}
return null;
}
public function __set($key, $value)
{
$this->options[$key] = $value;
}
public function __isset($key)
{
return isset($this->options[$key]);
}
public function __unset($key)
{
if (isset($this->options[$key])) {
unset($this->options[$key]);
}
}
public function get($url, $headers = array(), $options = array())
{
return $this->request($url, $headers, null, Requests::GET, $options);
}
public function head($url, $headers = array(), $options = array())
{
return $this->request($url, $headers, null, Requests::HEAD, $options);
}
public function delete($url, $headers = array(), $options = array())
{
return $this->request($url, $headers, null, Requests::DELETE, $options);
}
public function post($url, $headers = array(), $data = array(), $options = array())
{
return $this->request($url, $headers, $data, Requests::POST, $options);
}
public function put($url, $headers = array(), $data = array(), $options = array())
{
return $this->request($url, $headers, $data, Requests::PUT, $options);
}
public function patch($url, $headers, $data = array(), $options = array())
{
return $this->request($url, $headers, $data, Requests::PATCH, $options);
}
public function request($url, $headers = array(), $data = array(), $type = Requests::GET, $options = array())
{
$request = $this->merge_request(compact('url', 'headers', 'data', 'options'));
return Requests::request($request['url'], $request['headers'], $request['data'], $type, $request['options']);
}
public function request_multiple($requests, $options = array())
{
foreach ($requests as $key => $request) {
$requests[$key] = $this->merge_request($request, false);
}
$options = array_merge($this->options, $options);
unset($options['type']);
return Requests::request_multiple($requests, $options);
}
protected function merge_request($request, $merge_options = true)
{
if ($this->url !== null) {
$request['url'] = Requests_IRI::absolutize($this->url, $request['url']);
$request['url'] = $request['url']->uri;
}
if (empty($request['headers'])) {
$request['headers'] = array();
}
$request['headers'] = array_merge($this->headers, $request['headers']);
if (empty($request['data'])) {
if (is_array($this->data)) {
$request['data'] = $this->data;
}
} elseif (is_array($request['data']) && is_array($this->data)) {
$request['data'] = array_merge($this->data, $request['data']);
}
if ($merge_options !== false) {
$request['options'] = array_merge($this->options, $request['options']);
unset($request['options']['type']);
}
return $request;
}
}