Overview

Packages

  • Requests
    • Authentication
    • Cookies
    • Proxy
    • Session
    • Transport
    • Utilities

Classes

  • Requests_Transport_cURL
  • Requests_Transport_fsockopen

Interfaces

  • Requests_Transport
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated

Warning! You are currently reading the documentation for Requests 1.x.

It is recommended to upgrade to Requests 2.x at your earliest convenience. Upgrading to Requests 2.x is fairly straight-forward.
A full list of the changes can be found in the Changelog.

Visit the documentation for Requests_Transport_cURL in Requests 2.x.

Class Requests_Transport_cURL

cURL HTTP transport

Requests_Transport_cURL implements Requests_Transport
Package: Requests\Transport
Located at Requests/Transport/cURL.php
Methods summary
public
# __construct( )

Constructor

Constructor

public
# __destruct( )

Destructor

Destructor

public string
# request( string $url, array $headers = array(), string|array $data = array(), array $options = array() )

Perform a request

Perform a request

Parameters

$url
URL to request
$headers
Associative array of request headers
$data
Data to send either as the POST body, or as parameters in the URL for a GET/HEAD
$options
Request options, see Requests::response() for documentation

Returns

string
Raw HTTP result

Throws

Requests_Exception
On a cURL error (curlerror)

Implementation of

Requests_Transport::request()
public array
# request_multiple( array $requests, array $options )

Send multiple requests simultaneously

Send multiple requests simultaneously

Parameters

$requests
Request data
$options
Global options

Returns

array
Array of Requests_Response objects (may contain Requests_Exception or string responses as well)

Implementation of

Requests_Transport::request_multiple()
public resource &
# get_subrequest_handle( string $url, array $headers, string|array $data, array $options )

Get the cURL handle for use in a multi-request

Get the cURL handle for use in a multi-request

Parameters

$url
URL to request
$headers
Associative array of request headers
$data
Data to send either as the POST body, or as parameters in the URL for a GET/HEAD
$options
Request options, see Requests::response() for documentation

Returns

resource
Subrequest's cURL handle
protected
# setup_handle( string $url, array $headers, string|array $data, array $options )

Setup the cURL handle for the given data

Setup the cURL handle for the given data

Parameters

$url
URL to request
$headers
Associative array of request headers
$data
Data to send either as the POST body, or as parameters in the URL for a GET/HEAD
$options
Request options, see Requests::response() for documentation
public string|false
# process_response( string $response, array $options )

Process a response

Process a response

Parameters

$response
Response data from the body
$options
Request options

Returns

string|false
HTTP response data including headers. False if non-blocking.

Throws

Requests_Exception
public integer
# stream_headers( resource $handle, string $headers )

Collect the headers as they are received

Collect the headers as they are received

Parameters

$handle
cURL resource
$headers
Header string

Returns

integer
Length of provided header
public integer
# stream_body( resource $handle, string $data )

Collect data as it's received

Collect data as it's received

Parameters

$handle
cURL resource
$data
Body data

Returns

integer
Length of provided data

Since

1.6.1
protected static string
# format_get( string $url, array|object $data )

Format a URL given GET data

Format a URL given GET data

Parameters

$url
$data
Data to build query using, see https://secure.php.net/http_build_query

Returns

string
URL with data
public static boolean
# test( $capabilities = array() )

Whether this transport is valid

Whether this transport is valid

Returns

boolean
True if the transport is valid, false otherwise.

Codecoverageignore

Implementation of

Requests_Transport::test()
protected string
# get_expect_header( string|array $data )

Get the correct "Expect" header for the given request data.

Get the correct "Expect" header for the given request data.

Parameters

$data
Data to send either as the POST body, or as parameters in the URL for a GET/HEAD.

Returns

string
The "Expect" header.
Constants summary
integer CURL_7_10_5
# 0x070A05
integer CURL_7_16_2
# 0x071002
Properties summary
public string $headers

Raw HTTP data

Raw HTTP data

# ''
public string $response_data

Raw body data

Raw body data

# ''
public array $info

Information on the current request

Information on the current request

#
public integer $version

cURL version number

cURL version number

#
protected resource $handle

cURL handle

cURL handle

#
protected Requests_Hooks $hooks

Hook dispatcher instance

Hook dispatcher instance

#
protected boolean $done_headers

Have we finished the headers yet?

Have we finished the headers yet?

# false
protected resource $stream_handle

If streaming to a file, keep the file pointer

If streaming to a file, keep the file pointer

#
protected integer $response_bytes

How many bytes are in the response body?

How many bytes are in the response body?

#
protected integer|boolean $response_byte_limit

What's the maximum number of bytes we should keep?

What's the maximum number of bytes we should keep?

#
Requests 1.8.1 API Documentation API documentation generated by ApiGen