Property | Type | Description | |
---|---|---|---|
$cacert_location | The location of the cacert.pem file to use. | ||
$connect_timeout | integer | 连接超时时间,默认是10秒 | |
$curl_handle | The handle for the cURL object. | ||
$curlopts | Custom CURLOPT settings. | ||
$debug_mode | The state of debug mode. | ||
$method | The method by which the request is being made. | ||
$password | The password to use for the request. | ||
$proxy | Stores the proxy settings to use for the request. | ||
$read_file | File to read from while streaming up. | ||
$read_stream | The resource to read from while streaming up. | ||
$read_stream_read | The length already read from the stream. | ||
$read_stream_size | The size of the stream to read from. | ||
$registered_streaming_read_callback | The user-defined callback function to call when a stream is read from. | ||
$registered_streaming_write_callback | The user-defined callback function to call when a stream is written to. | ||
$request_body | The body being sent in the request. | ||
$request_class | The default class to use for HTTP Requests (defaults to |
||
$request_headers | The headers being sent in the request. | ||
$request_url | The URL being requested. | ||
$response | The response returned by the request. | ||
$response_body | The body returned by the request. | ||
$response_class | The default class to use for HTTP Responses (defaults to |
||
$response_code | The HTTP status code returned by the request. | ||
$response_headers | The headers returned by the request. | ||
$response_info | Additional response data. | ||
$seek_position | Stores the intended starting seek position. | ||
$ssl_verification | The state of SSL certificate verification. | ||
$timeout | integer | 请求超时时间, 默认是5184000秒,6天 | |
$useragent | Default useragent string to use. | ||
$username | The username to use for the request. | ||
$write_file | File to write to while streaming down. | ||
$write_stream | The resource to write to while streaming down. |
Method | Description | |
---|---|---|
__construct ( string $url = null, string $proxy = null, array $helpers = null ) | Constructs a new instance of this class. | |
__destruct ( ) | Destructs the instance. Closes opened file handles. | |
add_header ( string $key, mixed $value ) | Adds a custom HTTP header to the cURL request. | |
get_response_body ( ) : string | Get the HTTP response body from the request. | |
get_response_code ( ) : string | Get the HTTP response code from the request. | |
get_response_header ( string $header = null ) : string | array | Get the HTTP response headers from the request. | |
prep_request ( ) : resource |
Prepares and adds the details of the cURL request. This can be passed along to a |
|
process_response ( resource $curl_handle = null, string $response = null ) : OSS\Http\ResponseCore | Take the post-processed cURL data and break it down into useful header/body/info chunks. Uses the data stored in the curl_handle and response properties unless replacement data is passed in via parameters. | |
register_streaming_read_callback ( string | array | function $callback ) |
Register a callback function to execute whenever a data stream is read from using
|
|
register_streaming_write_callback ( string | array | function $callback ) |
Register a callback function to execute whenever a data stream is written to using
|
|
remove_header ( string $key ) | Removes an HTTP header from the cURL request. | |
send_multi_request ( array $handles, array $opt = null ) : array |
Sends the request using |
|
send_request ( boolean $parse = false ) : string | Sends the request, calling necessary utility functions to update built-in properties. | |
set_body ( string $body ) | Set the body to send in the request. | |
set_credentials ( string $user, string $pass ) | Sets the credentials to use for authentication. | |
set_curlopts ( array $curlopts ) | Set additional CURLOPT settings. These will merge with the default settings, and override if there is a duplicate. | |
set_method ( string $method ) | Set the method type for the request. | |
set_proxy ( string $proxy ) | Set the proxy to use for making requests. | |
set_read_file ( string $location ) | Sets the file to read from while streaming up. | |
set_read_stream ( resource $resource, integer $size = null ) |
Sets the resource to read from while streaming up. Reads the stream from its current position until
EOF or $size bytes have been read. If $size is not given it will be determined by |
|
set_read_stream_size ( integer $size ) | Sets the length in bytes to read from the stream while streaming up. | |
set_request_url ( string $url ) | Set the URL to make the request to. | |
set_seek_position ( integer $position ) | Set the intended starting seek position. | |
set_useragent ( string $ua ) | Sets a custom useragent string for the class. | |
set_write_file ( string $location ) | Sets the file to write to while streaming down. | |
set_write_stream ( resource $resource ) | Sets the resource to write to while streaming down. | |
streaming_read_callback ( resource $curl_handle, resource $file_handle, integer $length ) : binary | A callback function that is invoked by cURL for streaming up. | |
streaming_write_callback ( resource $curl_handle, binary $data ) : integer | A callback function that is invoked by cURL for streaming down. |
public __construct ( string $url = null, string $proxy = null, array $helpers = null ) | ||
$url | string | (Optional) The URL to request or service endpoint to query. |
$proxy | string | (Optional) The faux-url to use for proxy settings. Takes the following format: `proxy://user:pass@hostname:port` |
$helpers | array | (Optional) An associative array of classnames to use for request, and response functionality. Gets passed in automatically by the calling class. |
public __destruct ( ) |
public add_header ( string $key, mixed $value ) | ||
$key | string | (Required) The custom HTTP header to set. |
$value | mixed | (Required) The value to assign to the custom HTTP header. |
public get_response_body ( ) : string | ||
return | string | The response body. |
public get_response_code ( ) : string | ||
return | string | The HTTP response code. |
public prep_request ( ) : resource | ||
return | resource | The handle for the cURL object. |
public process_response ( resource $curl_handle = null, string $response = null ) : OSS\Http\ResponseCore | ||
$curl_handle | resource | (Optional) The reference to the already executed cURL request. |
$response | string | (Optional) The actual response content itself that needs to be parsed. |
return | OSS\Http\ResponseCore | A |
$curl_handle
- resource
- Required - The cURL handle resource that represents the in-progress transfer.$file_handle
- resource
- Required - The file handle resource that represents the file on the local file system.$length
- integer
- Required - The length in kilobytes of the data chunk that was transferred.public register_streaming_read_callback ( string | array | function $callback ) | ||
$callback | string | array | function | (Required) The callback function is called by
|
$curl_handle
- resource
- Required - The cURL handle resource that represents the in-progress transfer.$length
- integer
- Required - The length in kilobytes of the data chunk that was transferred.public register_streaming_write_callback ( string | array | function $callback ) | ||
$callback | string | array | function | (Required) The callback function is called by
|
public remove_header ( string $key ) | ||
$key | string | (Required) The custom HTTP header to set. |
public send_multi_request ( array $handles, array $opt = null ) : array | ||
$handles | array | (Required) An indexed array of cURL handles to process simultaneously. |
$opt | array | (Optional) An associative array of parameters that can have the following keys:
|
return | array | Post-processed cURL responses. |
public send_request ( boolean $parse = false ) : string | ||
$parse | boolean | (Optional) Whether to parse the response with ResponseCore or not. |
return | string | The resulting unparsed data from the request. |
public set_credentials ( string $user, string $pass ) | ||
$user | string | (Required) The username to authenticate with. |
$pass | string | (Required) The password to authenticate with. |
public set_curlopts ( array $curlopts ) | ||
$curlopts | array | (Optional) A set of key-value pairs that set `CURLOPT` options. These will merge with the existing CURLOPTs, and ones passed here will override the defaults. Keys should be the `CURLOPT_*` constants, not strings. |
public set_method ( string $method ) | ||
$method | string | (Required) One of the following constants: |
public set_read_file ( string $location ) | ||
$location | string | (Required) The readable location to read from. |
public set_read_stream ( resource $resource, integer $size = null ) | ||
$resource | resource | (Required) The readable resource to read from. |
$size | integer | (Optional) The size of the stream to read. |
public set_read_stream_size ( integer $size ) | ||
$size | integer | (Required) The length in bytes to read from the stream. |
public set_request_url ( string $url ) | ||
$url | string | (Required) The URL to make the request to. |
public set_seek_position ( integer $position ) | ||
$position | integer | (Required) The byte-position of the stream to begin reading from. |
public set_useragent ( string $ua ) | ||
$ua | string | (Required) The useragent string to use. |
public set_write_file ( string $location ) | ||
$location | string | (Required) The writeable location to write to. |
public set_write_stream ( resource $resource ) | ||
$resource | resource | (Required) The writeable resource to write to. |
public streaming_read_callback ( resource $curl_handle, resource $file_handle, integer $length ) : binary | ||
$curl_handle | resource | (Required) The cURL handle for the request. |
$file_handle | resource | (Required) The open file handle resource. |
$length | integer | (Required) The maximum number of bytes to read. |
return | binary | Binary data from a stream. |
public streaming_write_callback ( resource $curl_handle, binary $data ) : integer | ||
$curl_handle | resource | (Required) The cURL handle for the request. |
$data | binary | (Required) The data to write. |
return | integer | The number of bytes written. |
public $cacert_location |
public $registered_streaming_read_callback |
public $registered_streaming_write_callback |
public $request_class |
public $response_class |
public $ssl_verification |