Send a HTTP request to a URI.


(array) apply_filters( 'http_request_timeout', (int) $int ); 

The body and headers are part of the arguments. The body argument is for the body and will accept either a string or an array. The headers, argument should be an array, but a string is acceptable. If the body argument is an array, then it will automatically be escaped using http_build_query().

The only URI that are supported in the HTTP Transport implementation are the HTTP and HTTPS protocols. HTTP and HTTPS are assumed so the server might not know how to handle the send headers. Other protocols are unsupported and most likely will fail.

The defaults are method, timeout, redirection, httpversion, blocking and 'user-agent'.

Accepted method values are GET, POST, and HEAD, some transports technically allow others, but should not be assumed. The timeout is used to sent how long the connection should stay open before failing when no response. redirection is used to track how many redirects were taken and used to sent the amount for other transports, but not all transports accept setting that value.

The httpversion option is used to sent the HTTP version and accepted values are 1.0, and '1.1' and should be a string. Version 1.1 is not supported, because of chunk response. The 'user-agent' option is the user-agent and is used to replace the default user-agent, which is 'WordPress/WP_Version', where WP_Version is the value from $wp_version.

blocking is the default, which is used to tell the transport, whether it should halt PHP while it performs the request or continue regardless. Actually, that isn't entirely correct. Blocking mode really just means whether the fread should just pull what it can whenever it gets bytes or if it should wait until it has enough in the buffer to read or finishes reading the entire content. It doesn't actually always mean that PHP will continue going after making the request.

Returns (array)

containing 'headers', 'body', 'response', 'cookies'

Parameters (1)

0. $int (int) => 5
The int.


To run the hook, copy the example below.
  1. $int = apply_filters( 'http_request_timeout', $int ); 
  3. if ( !empty( $int ) ) { 
  5. // everything has led up to this point... 
The following example is for adding a hook callback.
  1. // define the http_request_timeout callback 
  2. function filter_http_request_timeout( $int ) { 
  3. // make filter magic happen here... 
  4. return $int
  5. }; 
  7. // add the filter 
  8. add_filter( 'http_request_timeout', 'filter_http_request_timeout', 10, 1 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'http_request_timeout', 'filter_http_request_timeout', 10, 1 ); 

Defined (1)

The filter is defined in the following location(s).

  1. 'timeout' => apply_filters( 'http_request_timeout', 5),