wppaste
WordPress

WP_Http_Curl

Since
2.7.0
Source
wp-includes/class-wp-http-curl.php:21
Core class used to integrate Curl as an HTTP transport.

Description

HTTP request method uses Curl extension to retrieve the url.

Requires the Curl extension to be installed.

Compatibility

Deprecated in WordPress 6.4.0. Use WP_Http

WordPress
since 2.7.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Hooks and filters fired · 4

Every hook that fires from inside WP_Http_Curl, in the order it appears in the class, grouped by the method that fires it.

Properties · 5

$headersstringprivate
Temporary header storage for during requests.
$bodystringprivate
Temporary body storage for during requests.
$max_body_lengthint|falseprivate
The maximum amount of data to receive from the remote server.
$stream_handleresource|falseprivate
The file resource used for streaming to file.
$bytes_written_totalintprivate
The total bytes written in the current request.

Methods · 4

  • request()Send a HTTP request to a URI using cURL extension.
  • stream_headers()Grabs the headers of the cURL request.
  • stream_body()Grabs the body of the cURL request.
  • test()Determines whether this class can be used for retrieving a URL.

Source code

#[AllowDynamicProperties]class WP_Http_Curl { 	/**	 * Temporary header storage for during requests.	 *	 * @since 3.2.0	 * @var string	 */	private $headers = ''; 	/**	 * Temporary body storage for during requests.	 *	 * @since 3.6.0	 * @var string	 */	private $body = ''; 	/**	 * The maximum amount of data to receive from the remote server.	 *	 * @since 3.6.0	 * @var int|false	 */	private $max_body_length = false; 	/**	 * The file resource used for streaming to file.	 *	 * @since 3.6.0	 * @var resource|false	 */	private $stream_handle = false; 	/**	 * The total bytes written in the current request.	 *	 * @since 4.1.0	 * @var int	 */	private $bytes_written_total = 0; 	/**	 * Send a HTTP request to a URI using cURL extension.	 *	 * @since 2.7.0	 *	 * @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'. A WP_Error instance upon error	 */	public function request( $url, $args = array() ) {		$defaults = array(			'method'      => 'GET',			'timeout'     => 5,			'redirection' => 5,			'httpversion' => '1.0',			'blocking'    => true,			'headers'     => array(),			'body'        => null,			'cookies'     => array(),			'decompress'  => false,			'stream'      => false,			'filename'    => null,		); 		$parsed_args = wp_parse_args( $args, $defaults ); 		if ( isset( $parsed_args['headers']['User-Agent'] ) ) {			$parsed_args['user-agent'] = $parsed_args['headers']['User-Agent'];			unset( $parsed_args['headers']['User-Agent'] );		} elseif ( isset( $parsed_args['headers']['user-agent'] ) ) {			$parsed_args['user-agent'] = $parsed_args['headers']['user-agent'];			unset( $parsed_args['headers']['user-agent'] );		} 		// Construct Cookie: header if any cookies are set.		WP_Http::buildCookieHeader( $parsed_args );

Changelog

Introduced in 2.7.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

6.4.0
Deprecated. Use WP_Httpfrom the docblock
2.7.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 tag, from src/wp-includes/class-wp-http-curl.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.