WordPress Version: 3.7
/**
* Retrieve the raw response from the HTTP request.
*
* The array structure is a little complex.
*
* <code>
* $res = array( 'headers' => array(), 'response' => array('code' => int, 'message' => string) );
* </code>
*
* 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.
*
* <code>
* $user_agent = $res['headers']['user-agent'];
* </code>
*
* 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.
*
* List of default arguments:
* 'method' => 'GET'
* - Default 'GET' for wp_remote_get()
* - Default 'POST' for wp_remote_post()
* - Default 'HEAD' for wp_remote_head()
* 'timeout' => 5
* 'redirection' => 5
* 'httpversion' => '1.0'
* 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
* 'blocking' => true
* 'headers' => array()
* 'cookies' => array()
* 'body' => null
* 'compress' => false,
* 'decompress' => true,
* 'sslverify' => true,
* 'stream' => false,
* 'filename' => null
*
* @since 2.7.0
*
* @param string $url Site URL to retrieve.
* @param array $args Optional. Override the defaults.
* @return WP_Error|array The response or WP_Error on failure.
*/
function wp_remote_request($url, $args = array())
{
$objFetchSite = _wp_http_get_object();
return $objFetchSite->request($url, $args);
}