[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/ -> class-http.php (summary)

HTTP API: WP_Http class

File Size: 1072 lines (39 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 1 file
 wp-includes/class-requests.php

Defines 1 class

WP_Http:: (18 methods):
  request()
  normalize_cookies()
  browser_redirect_compatibility()
  validate_redirects()
  _get_first_available_transport()
  _dispatch_request()
  post()
  get()
  head()
  processResponse()
  processHeaders()
  buildCookieHeader()
  chunkTransferDecode()
  block_request()
  parse_url()
  make_absolute_url()
  handle_redirects()
  is_ip_address()


Class: WP_Http  - X-Ref

Core class used for managing HTTP transports and making HTTP requests.

This class is used to consistently make outgoing HTTP requests easy for developers
while still being compatible with the many PHP configurations under which
WordPress runs.

Debugging includes several actions, which pass different variables for debugging the HTTP API.

request( $url, $args = array()   X-Ref
Send an HTTP request to a URI.

Please note: The only URI that are supported in the HTTP Transport implementation
are the HTTP and HTTPS protocols.

return: array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'.
since: 2.7.0
param: string       $url  The request URL.
param: string|array $args {

normalize_cookies( $cookies )   X-Ref
Normalizes cookies for using in Requests.

return: Requests_Cookie_Jar Cookie holder object.
since: 4.6.0
param: array $cookies Array of cookies to send with the request.

browser_redirect_compatibility( $location, $headers, $data, &$options, $original )   X-Ref
Match redirect behaviour to browser handling.

Changes 302 redirects from POST to GET to match browser handling. Per
RFC 7231, user agents can deviate from the strict reading of the
specification for compatibility purposes.

since: 4.6.0
param: string            $location URL to redirect to.
param: array             $headers  Headers for the redirect.
param: string|array      $data     Body to send with the request.
param: array             $options  Redirect request options.
param: Requests_Response $original Response object.

validate_redirects( $location )   X-Ref
Validate redirected URLs.

since: 4.7.5
param: string $location URL to redirect to.

_get_first_available_transport( $args, $url = null )   X-Ref
Tests which transports are capable of supporting the request.

return: string|false Class name for the first transport that claims to support the request. False if no transport claims to support the request.
since: 3.2.0
param: array $args Request arguments
param: string $url URL to Request

_dispatch_request( $url, $args )   X-Ref
Dispatches a HTTP request to a supporting transport.

Tests each transport in order to find a transport which matches the request arguments.
Also caches the transport instance to be used later.

The order for requests is cURL, and then PHP Streams.

return: array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error
since: 3.2.0
param: string $url URL to Request
param: array $args Request arguments

post( $url, $args = array()   X-Ref
Uses the POST HTTP method.

Used for sending data that is expected to be in the body.

return: array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error
since: 2.7.0
param: string       $url  The request URL.
param: string|array $args Optional. Override the defaults.

get( $url, $args = array()   X-Ref
Uses the GET HTTP method.

Used for sending data that is expected to be in the body.

return: array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error
since: 2.7.0
param: string $url The request URL.
param: string|array $args Optional. Override the defaults.

head( $url, $args = array()   X-Ref
Uses the HEAD HTTP method.

Used for sending data that is expected to be in the body.

return: array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error
since: 2.7.0
param: string $url The request URL.
param: string|array $args Optional. Override the defaults.

processResponse( $strResponse )   X-Ref
Parses the responses and splits the parts into headers and body.

return: array Array with 'headers' and 'body' keys.
since: 2.7.0
param: string $strResponse The full response string

processHeaders( $headers, $url = '' )   X-Ref
Transform header string into an array.

If an array is given then it is assumed to be raw header data with numeric keys with the
headers as the values. No headers must be passed that were already processed.

return: array Processed string headers. If duplicate headers are encountered,
since: 2.7.0
param: string|array $headers
param: string $url The URL that was requested

buildCookieHeader( &$r )   X-Ref
Takes the arguments for a ::request() and checks for the cookie array.

If it's found, then it upgrades any basic name => value pairs to WP_Http_Cookie instances,
which are each parsed into strings and added to the Cookie: header (within the arguments array).
Edits the array by reference.

since: 2.8.0
param: array $r Full array of args passed into ::request()

chunkTransferDecode( $body )   X-Ref
Decodes chunk transfer-encoding, based off the HTTP 1.1 specification.

Based off the HTTP http_encoding_dechunk function.

return: string Chunked decoded body on success or raw body on failure.
since: 2.7.0
param: string $body Body content

block_request( $uri )   X-Ref
Block requests through the proxy.

Those who are behind a proxy and want to prevent access to certain hosts may do so. This will
prevent plugins from working and core functionality, if you don't include api.wordpress.org.

You block external URL requests by defining WP_HTTP_BLOCK_EXTERNAL as true in your wp-config.php
file and this will only allow localhost and your site to make requests. The constant
WP_ACCESSIBLE_HOSTS will allow additional hosts to go through for requests. The format of the
WP_ACCESSIBLE_HOSTS constant is a comma separated list of hostnames to allow, wildcard domains
are supported, eg *.wordpress.org will allow for all subdomains of wordpress.org to be contacted.

return: bool True to block, false to allow.
since: 2.8.0
param: string $uri URI of url.

parse_url( $url )   X-Ref
Used as a wrapper for PHP's parse_url() function that handles edgecases in < PHP 5.4.7.

return: bool|array False on failure; Array of URL components on success;
param: string $url The URL to parse.

make_absolute_url( $maybe_relative_path, $url )   X-Ref
Converts a relative URL to an absolute URL relative to a given URL.

If an Absolute URL is provided, no processing of that URL is done.

return: string An Absolute URL, in a failure condition where the URL cannot be parsed, the relative URL will be returned.
since: 3.4.0
param: string $maybe_relative_path The URL which might be relative
param: string $url                 The URL which $maybe_relative_path is relative to

handle_redirects( $url, $args, $response )   X-Ref
Handles HTTP Redirects and follows them if appropriate.

return: false|object False if no redirect is present, a WP_HTTP or WP_Error result otherwise.
since: 3.7.0
param: string $url The URL which was requested.
param: array $args The Arguments which were used to make the request.
param: array $response The Response of the HTTP request.

is_ip_address( $maybe_ip )   X-Ref
Determines if a specified string represents an IP address or not.

This function also detects the type of the IP address, returning either
'4' or '6' to represent a IPv4 and IPv6 address respectively.
This does not verify if the IP is a valid IP, only that it appears to be
an IP address.

return: integer|bool Upon success, '4' or '6' to represent a IPv4 or IPv6 address, false upon failure
since: 3.7.0
param: string $maybe_ip A suspected IP address



Generated: Sun Sep 15 01:00:03 2019 Cross-referenced by PHPXref 0.7.1