[ Index ]

WordPress 5.4.1

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    




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

HTTP API: WP_Http class

File Size: 1088 lines (39 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 1 file

Defines 1 class

WP_Http:: (18 methods):

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.

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

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

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

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.

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.

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.

param: array $args Request arguments.
param: string $url URL to Request.
return: string|false Class name for the first transport that claims to support the 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.

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

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

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

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

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

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

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

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

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

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

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

param: string $strResponse The full response string.
return: array {

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.

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

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.

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.

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

block_request( $uri )   X-Ref
Determines whether an HTTP API request to the given URL should be blocked.

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.

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

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

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

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.

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

handle_redirects( $url, $args, $response )   X-Ref
Handles an HTTP redirect and follows it if appropriate.

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.
return: array|false|WP_Error An HTTP API response array if the redirect is successfully followed,

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.

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

Generated: Tue May 19 15:51:04 2020 Cross-referenced by PHPXref 0.7.1