ar\http

ar\http\cookie Support for reading and writing cookies.
ar\http\headers Support for sending all kinds of headers.

methods

(void) configure Configures global settings for ar\http.
(object) client Returns a HTTP client object.
(mixed) getvar Returns the value of the requested variable.
(bool) header Sends an HTTP header. Shortcut for ar\http\headers::header()
(string) request Sends a HTTP request to a webserver and returns the result.

configure

(void) ar('http')->configure( $option, $value )

(string) $option Currently only 'tainting' is a valid option.
(mixed) $value The value for the given option.

Sets a single global setting for the ar\http module. Currently you can only change whether automatic tainting is enabled or disabled. Call configure like this to disable tainting:

<pinp>
ar('http')->configure('tainting', false);
</pinp>

Setting it to true enables tainting again. Read more about tainting at ar::taint().

client

(object) ar('http')->client( $options = array() )

(array) $options A list of options for the HTTP client. See the HTTP context options for a full list.

Returns a HTTP client object that implements the following methods:

(string) get Shortcut to send, using method GET.
(string) delete Shortcut to send, using method DELETE.
(object) headers Adds the given headers to the request and returns the client object.
(string) post Shortcut to send, using method POST.
(string) put Shortcut to send, using method PUT.
(string) send Sends a request to a webserver and returns the result.

(string) $httpClient->get( $url, $request = null, $options = array() )

(string) $httpClient->delete( $url, $request = null, $options = array() )

(string) $httpClient->post( $url, $request = null, $options = array() )

(string) $httpClient->put( $url, $request = null, $options = array() ) 

Shortcuts to the send method, with the request type set to the method name.

(string) $httpClient->send( $type, $url, $request = null, $options = array() )

(string) $type Request type, either 'DELETE', 'GET', 'POST' or 'PUT'.
(string) $url The url to request.
(mixed) $request Either a string or an array of name => value pairs.
(array) $options The context options for the HTTP connection. See the HTTP context options for a full list.

Sends a request to a webserver and returns the result. Any response headers can be read through the responseHeaders property. e.g.:

<pinp>
$client = ar('http')->client();
$result = $client->get('http://www.ariadne-cms.org/');
$headers = $client->responseHeaders;
</pinp>

(object) $httpClient->headers( $headers )

Allows you to add one or more headers to a request, e.g.:

<pinp>
$client = ar('http')->client();
$result = $client->headers( array(
'Cache-control' => 'no-cache',
'Pragma' => 'no-cache'
) )->get( $url );
</pinp>

getvar

(mixed) ar('http')->getvar( $name = null, $method = null )

(string) $name The name of the variable to get.
(string) $method Where to get the variable from. Can be either 'GET', 'POST', 'COOKIE', 'SERVER' or 'REQUEST'.

Returns the variable with the given name, requested using the given method. If no method is supplied the variable will be first sought in the POST request and if not found there in the GET request.

If a name is set, but no method, only the POST and GET variables will be searched, in that order.

If no name is supplied, the entire array of variables send using the given method is returned. If no method is set, the REQUEST array with all GET, POST and COOKIE variables is returned. e.g.:

<pinp>
$AllGetVars = ar('http')->getvar(null, 'GET');
</pinp>

The same can also be done using:

<pinp>
$AllGetVars = ar('http')->GET;
</pinp>

request

(string) ar('http')->request( $type = null, $url = null, $request = null, $options = array() )

(string) $type Request type, either 'DELETE', 'GET', 'POST' or 'PUT'.
(string) $url The url to request.
(mixed) $request Either a string or an array of name => value pairs.
(array) $options The context options for the HTTP connection. See the HTTP context options for a full list.

Sends a request to a webserver and returns the result.