EasyRdf API Documentation
Class

EasyRdf_Http_Client

class EasyRdf_Http_Client

This class is an implemetation of an HTTP client in PHP.

It supports basic HTTP 1.0 and 1.1 requests. For a more complete implementation try ZendHttpClient.

Methods

__construct(string $uri = null, array $config = null)

Constructor method.

EasyRdf_Http_Client setUri(string $uri)

Set the URI for the next request

string getUri($asString = true)

Get the URI for the next request

EasyRdf_Http_Client setConfig(array $config = array())

Set configuration parameters for this HTTP client

EasyRdf_Http_Client setHeaders(string $name, string $value = null)

Set a request header

EasyRdf_Http_Client setMethod(string $method)

Set the next request's method

string getMethod()

Get the method for the next request

string|array|null getHeader(string $key)

Get the value of a specific header

EasyRdf_Http_Client setParameterGet(string $name, string $value = null)

Set a GET parameter for the request.

string getParameterGet(string $name)

Get a GET parameter for the request.

array getParametersGet()

Get all the GET parameters

int getRedirectionsCount()

Get the number of redirections done on the last request

Zend_Http_Client setRawData(string|resource $data)

Set the raw (already encoded) POST data.

string getRawData()

Get the raw (already encoded) POST data.

EasyRdf_Http_Client resetParameters(bool $clearAll = false)

Clear all GET and POST parameters

EasyRdf_Http_Response request($method = null)

Send the HTTP request and return an HTTP response object

Details

at line 111
public __construct(string $uri = null, array $config = null)

Constructor method.

Will create a new HTTP client. Accepts the target URL and optionally configuration array.

Parameters

string $uri
array $config Configuration key-value pairs.

at line 127
public EasyRdf_Http_Client setUri(string $uri)

Set the URI for the next request

Parameters

string $uri

Return Value

EasyRdf_Http_Client

at line 149
public string getUri($asString = true)

Get the URI for the next request

Parameters

$asString

Return Value

string

at line 161
public EasyRdf_Http_Client setConfig(array $config = array())

Set configuration parameters for this HTTP client

Parameters

array $config

Return Value

EasyRdf_Http_Client

Exceptions

InvalidArgumentException

at line 183
public EasyRdf_Http_Client setHeaders(string $name, string $value = null)

Set a request header

Parameters

string $name Header name (e.g. 'Accept')
string $value Header value or null

Return Value

EasyRdf_Http_Client

at line 207
public EasyRdf_Http_Client setMethod(string $method)

Set the next request's method

Validated the passed method and sets it.

Parameters

string $method

Return Value

EasyRdf_Http_Client

Exceptions

InvalidArgumentException

at line 223
public string getMethod()

Get the method for the next request

Return Value

string

at line 237
public string|array|null getHeader(string $key)

Get the value of a specific header

Note that if the header has more than one value, an array will be returned.

Parameters

string $key

Return Value

string|array|null The header value or null if it is not set

at line 254
public EasyRdf_Http_Client setParameterGet(string $name, string $value = null)

Set a GET parameter for the request.

Parameters

string $name
string $value

Return Value

EasyRdf_Http_Client

at line 273
public string getParameterGet(string $name)

Get a GET parameter for the request.

Parameters

string $name

Return Value

string value

at line 287
public array getParametersGet()

Get all the GET parameters

Return Value

array

at line 297
public int getRedirectionsCount()

Get the number of redirections done on the last request

Return Value

int

at line 315
public Zend_Http_Client setRawData(string|resource $data)

Set the raw (already encoded) POST data.

This function is here for two reasons: 1. For advanced user who would like to set their own data, already encoded 2. For backwards compatibilty: If someone uses the old post($data) method. this method will be used to set the encoded data.

$data can also be stream (such as file) from which the data will be read.

Parameters

string|resource $data

Return Value

Zend_Http_Client

at line 326
public string getRawData()

Get the raw (already encoded) POST data.

Return Value

string

at line 343
public EasyRdf_Http_Client resetParameters(bool $clearAll = false)

Clear all GET and POST parameters

Should be used to reset the request parameters if the client is used for several concurrent requests.

clearAll parameter controls if we clean just parameters or also headers

Parameters

bool $clearAll Should all data be cleared?

Return Value

EasyRdf_Http_Client

at line 371
public EasyRdf_Http_Response request($method = null)

Send the HTTP request and return an HTTP response object

Parameters

$method

Return Value

EasyRdf_Http_Response

Exceptions

EasyRdf_Exception