wp_remote_retrieve_response_code

Definition:
function wp_remote_retrieve_response_code(&$response) {}

Retrieve only the response code from the raw response.
Will return an empty array if incorrect parameter value is given.

Parameters

  • array $response: HTTP response.
  • &$response

Return values

returns:the response code. Empty string on incorrect parameter given.

Source code

function wp_remote_retrieve_response_code(&$response) {

	if ( is_wp_error($response) || ! isset($response['response']) || ! is_array($response['response']))

		return '';



	return $response['response']['code'];

}

4049

wp_remote_retrieve_headers

Definition:
function wp_remote_retrieve_headers(&$response) {}

Retrieve only the headers from the raw response.

Parameters

  • array $response: HTTP response.
  • &$response

Return values

returns:The headers of the response. Empty array if incorrect parameter given.

Source code

function wp_remote_retrieve_headers(&$response) {

	if ( is_wp_error($response) || ! isset($response['headers']) || ! is_array($response['headers']))

		return array();



	return $response['headers'];

}

4047

wp_remote_retrieve_header

Definition:
function wp_remote_retrieve_header(&$response, $header) {}

Retrieve a single header by name from the raw response.

Parameters

  • array $response
  • string $header: Header name to retrieve value from.
  • &$response

Return values

returns:The header value. Empty string on if incorrect parameter given, or if the header doesn’t exist.

Source code

function wp_remote_retrieve_header(&$response, $header) {

	if ( is_wp_error($response) || ! isset($response['headers']) || ! is_array($response['headers']))

		return '';



	if ( array_key_exists($header, $response['headers']) )

		return $response['headers'][$header];



	return '';

}

4045

wp_remote_retrieve_body

Definition:
function wp_remote_retrieve_body(&$response) {}

Retrieve only the body from the raw response.

Parameters

  • array $response: HTTP response.
  • &$response

Return values

returns:The body of the response. Empty string if no body or incorrect parameter given.

Source code

function wp_remote_retrieve_body(&$response) {

	if ( is_wp_error($response) || ! isset($response['body']) )

		return '';



	return $response['body'];

}

4043

wp_remote_request

Definition:
function wp_remote_request($url, $args = array() {}

Retrieve the raw response from the HTTP request.
The array structure is a little complex.

Parameters

  • string $url: Site URL to retrieve.
  • array $args: Optional. Override the defaults.

Return values

returns:The response or WP_Error on failure.

Source code

function wp_remote_request($url, $args = array()) {

	$objFetchSite = _wp_http_get_object();

	return $objFetchSite->request($url, $args);

}

4041