[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

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

Core HTTP Request API Standardizes the HTTP requests for WordPress. Handles cookies, gzip encoding and decoding, chunk decoding, if HTTP 1.1 and various other difficult HTTP protocol implementations.

File Size: 769 lines (22 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 28 functions

  _wp_http_get_object()
  wp_safe_remote_request()
  wp_safe_remote_get()
  wp_safe_remote_post()
  wp_safe_remote_head()
  wp_remote_request()
  wp_remote_get()
  wp_remote_post()
  wp_remote_head()
  wp_remote_retrieve_headers()
  wp_remote_retrieve_header()
  wp_remote_retrieve_response_code()
  wp_remote_retrieve_response_message()
  wp_remote_retrieve_body()
  wp_remote_retrieve_cookies()
  wp_remote_retrieve_cookie()
  wp_remote_retrieve_cookie_value()
  wp_http_supports()
  get_http_origin()
  get_allowed_http_origins()
  is_allowed_http_origin()
  send_origin_headers()
  wp_http_validate_url()
  allowed_http_request_hosts()
  ms_allowed_http_request_hosts()
  wp_parse_url()
  _get_component_from_parsed_url_array()
  _wp_translate_php_url_constant_to_key()

Functions
Functions that are not part of a class:

_wp_http_get_object()   X-Ref
Returns the initialized WP_Http Object

return: WP_Http HTTP Transport object.

wp_safe_remote_request( $url, $args = array()   X-Ref
Retrieve the raw response from a safe HTTP request.

This function is ideal when the HTTP request is being made to an arbitrary
URL. The URL is validated to avoid redirection and request forgery attacks.

param: string $url  Site URL to retrieve.
param: array  $args Optional. Request arguments. Default empty array.
return: WP_Error|array The response or WP_Error on failure.

wp_safe_remote_get( $url, $args = array()   X-Ref
Retrieve the raw response from a safe HTTP request using the GET method.

This function is ideal when the HTTP request is being made to an arbitrary
URL. The URL is validated to avoid redirection and request forgery attacks.

param: string $url  Site URL to retrieve.
param: array  $args Optional. Request arguments. Default empty array.
return: WP_Error|array The response or WP_Error on failure.

wp_safe_remote_post( $url, $args = array()   X-Ref
Retrieve the raw response from a safe HTTP request using the POST method.

This function is ideal when the HTTP request is being made to an arbitrary
URL. The URL is validated to avoid redirection and request forgery attacks.

param: string $url  Site URL to retrieve.
param: array  $args Optional. Request arguments. Default empty array.
return: WP_Error|array The response or WP_Error on failure.

wp_safe_remote_head( $url, $args = array()   X-Ref
Retrieve the raw response from a safe HTTP request using the HEAD method.

This function is ideal when the HTTP request is being made to an arbitrary
URL. The URL is validated to avoid redirection and request forgery attacks.

param: string $url Site URL to retrieve.
param: array $args Optional. Request arguments. Default empty array.
return: WP_Error|array The response or WP_Error on failure.

wp_remote_request( $url, $args = array()   X-Ref
Retrieve the raw response from the HTTP request.

The array structure is a little complex:

$res = array(
'headers'  => array(),
'response' => array(
'code'    => int,
'message' => string
)
);

All of the headers in $res['headers'] are with the name as the key and the
value as the value. So to get the User-Agent, you would do the following.

$user_agent = $res['headers']['user-agent'];

The body is the raw response content and can be retrieved from $res['body'].

This function is called first to make the request and there are other API
functions to abstract out the above convoluted setup.

Request method defaults for helper functions:
- Default 'GET'  for wp_remote_get()
- Default 'POST' for wp_remote_post()
- Default 'HEAD' for wp_remote_head()

param: string $url  Site URL to retrieve.
param: array  $args Optional. Request arguments. Default empty array.
return: WP_Error|array The response or WP_Error on failure.

wp_remote_get( $url, $args = array()   X-Ref
Retrieve the raw response from the HTTP request using the GET method.

param: string $url  Site URL to retrieve.
param: array  $args Optional. Request arguments. Default empty array.
return: WP_Error|array The response or WP_Error on failure.

wp_remote_post( $url, $args = array()   X-Ref
Retrieve the raw response from the HTTP request using the POST method.

param: string $url  Site URL to retrieve.
param: array  $args Optional. Request arguments. Default empty array.
return: WP_Error|array The response or WP_Error on failure.

wp_remote_head( $url, $args = array()   X-Ref
Retrieve the raw response from the HTTP request using the HEAD method.

param: string $url  Site URL to retrieve.
param: array  $args Optional. Request arguments. Default empty array.
return: WP_Error|array The response or WP_Error on failure.

wp_remote_retrieve_headers( $response )   X-Ref
Retrieve only the headers from the raw response.

param: array $response HTTP response.
return: array|\Requests_Utility_CaseInsensitiveDictionary The headers of the response. Empty array if incorrect parameter given.

wp_remote_retrieve_header( $response, $header )   X-Ref
Retrieve a single header by name from the raw response.

param: array  $response
param: string $header Header name to retrieve value from.
return: string The header value. Empty string on if incorrect parameter given, or if the header doesn't exist.

wp_remote_retrieve_response_code( $response )   X-Ref
Retrieve only the response code from the raw response.

Will return an empty array if incorrect parameter value is given.

param: array $response HTTP response.
return: int|string The response code as an integer. Empty string on incorrect parameter given.

wp_remote_retrieve_response_message( $response )   X-Ref
Retrieve only the response message from the raw response.

Will return an empty array if incorrect parameter value is given.

param: array $response HTTP response.
return: string The response message. Empty string on incorrect parameter given.

wp_remote_retrieve_body( $response )   X-Ref
Retrieve only the body from the raw response.

param: array $response HTTP response.
return: string The body of the response. Empty string if no body or incorrect parameter given.

wp_remote_retrieve_cookies( $response )   X-Ref
Retrieve only the cookies from the raw response.

param: array $response HTTP response.
return: array An array of `WP_Http_Cookie` objects from the response. Empty array if there are none, or the response is a WP_Error.

wp_remote_retrieve_cookie( $response, $name )   X-Ref
Retrieve a single cookie by name from the raw response.

param: array  $response HTTP response.
param: string $name     The name of the cookie to retrieve.
return: WP_Http_Cookie|string The `WP_Http_Cookie` object. Empty string if the cookie isn't present in the response.

wp_remote_retrieve_cookie_value( $response, $name )   X-Ref
Retrieve a single cookie's value by name from the raw response.

param: array  $response HTTP response.
param: string $name     The name of the cookie to retrieve.
return: string The value of the cookie. Empty string if the cookie isn't present in the response.

wp_http_supports( $capabilities = array()   X-Ref
Determines if there is an HTTP Transport that can process this request.

param: array  $capabilities Array of capabilities to test or a wp_remote_request() $args array.
param: string $url          Optional. If given, will check if the URL requires SSL and adds
return: bool

get_http_origin()   X-Ref
Get the HTTP Origin of the current request.

return: string URL of the origin. Empty string if no origin.

get_allowed_http_origins()   X-Ref
Retrieve list of allowed HTTP origins.

return: array Array of origin URLs.

is_allowed_http_origin( $origin = null )   X-Ref
Determines if the HTTP origin is an authorized one.

param: null|string $origin Origin URL. If not provided, the value of get_http_origin() is used.
return: string Origin URL if allowed, empty string if not.

send_origin_headers()   X-Ref
Send Access-Control-Allow-Origin and related headers if the current request
is from an allowed origin.

If the request is an OPTIONS request, the script exits with either access
control headers sent, or a 403 response if the origin is not allowed. For
other request methods, you will receive a return value.

return: string|false Returns the origin URL if headers are sent. Returns false

wp_http_validate_url( $url )   X-Ref
Validate a URL for safe use in the HTTP API.

param: string $url
return: false|string URL or false on failure.

allowed_http_request_hosts( $is_external, $host )   X-Ref
Whitelists allowed redirect hosts for safe HTTP requests as well.

Attached to the {@see 'http_request_host_is_external'} filter.

param: bool   $is_external
param: string $host
return: bool

ms_allowed_http_request_hosts( $is_external, $host )   X-Ref
Whitelists any domain in a multisite installation for safe HTTP requests.

Attached to the {@see 'http_request_host_is_external'} filter.

param: bool   $is_external
param: string $host
return: bool

wp_parse_url( $url, $component = -1 )   X-Ref
A wrapper for PHP's parse_url() function that handles consistency in the return
values across PHP versions.

PHP 5.4.7 expanded parse_url()'s ability to handle non-absolute url's, including
schemeless and relative url's with :// in the path. This function works around
those limitations providing a standard output on PHP 5.2~5.4+.

Secondly, across various PHP versions, schemeless URLs starting containing a ":"
in the query are being handled inconsistently. This function works around those
differences as well.

Error suppression is used as prior to PHP 5.3.3, an E_WARNING would be generated
when URL parsing failed.

param: string $url       The URL to parse.
param: int    $component The specific component to retrieve. Use one of the PHP
return: mixed False on parse failure; Array of URL components on success;

_get_component_from_parsed_url_array( $url_parts, $component = -1 )   X-Ref
Retrieve a specific component from a parsed URL array.

param: array|false $url_parts The parsed URL. Can be false if the URL failed to parse.
param: int    $component The specific component to retrieve. Use one of the PHP
return: mixed False on parse failure; Array of URL components on success;

_wp_translate_php_url_constant_to_key( $constant )   X-Ref
Translate a PHP_URL_* constant to the named array keys PHP uses.

param: int $constant PHP_URL_* constant.
return: string|bool The named key or false.



Generated: Tue Sep 25 08:20:01 2018 Cross-referenced by PHPXref 0.7