File "Response.php"

Full path: /home/kosmetik/public_html/wp-includes/Requests/Response.php
File size: 1.07 B
MIME-type: text/x-php
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

<?php

class Requests_Response
{
    public function __construct()
    {
        $this->headers = new Requests_Response_Headers();
        $this->cookies = new Requests_Cookie_Jar();
    }
    public $body = '';
    public $raw = '';
    public $headers = array();
    public $status_code = false;
    public $protocol_version = false;
    public $success = false;
    public $redirects = 0;
    public $url = '';
    public $history = array();
    public $cookies = array();
    public function is_redirect()
    {
        $code = $this->status_code;
        return in_array($code, array(300, 301, 302, 303, 307)) || $code > 307 && $code < 400;
    }
    public function throw_for_status($allow_redirects = true)
    {
        if ($this->is_redirect()) {
            if (!$allow_redirects) {
                throw new Requests_Exception('Redirection not allowed', 'response.no_redirects', $this);
            }
        } elseif (!$this->success) {
            $exception = Requests_Exception_HTTP::get_class($this->status_code);
            throw new $exception(null, $this);
        }
    }
}