|
Previous Class |
Solar_Http_Request_Adapter |
Next Page |
Solar_Http_Request_Adapter
Abstract adapter to support various HTTP request backends.
Note that this class represents a standalone HTTP request, whereas Solar_Request represents the PHP request environment superglobals (including $_SERVER, $_ENV, $_POST, etc).
Here is an example request process:
<?php
$request = Solar::factory('Solar_Http_Request');
// fetch a response object for a GET request
$request->setUri('http://example.com');
$response = $request->fetch();
// fetch a response object for a POST request with some data
$request->setContent = array(...);
$request->setMethod('post');
$response = $request->fetch();
// fetch the response as raw text instead of a response object
$response = $request->fetchRaw();
?>
This is a fluent class; you can chain the set*() and fetch() methods like so:
<?php
// fetch a response object for a POST request with some data
$request = Solar::factory('Solar_Http_Request');
$response = $request->setUri('http://example.com')
->setContent(array(...))
->setMethod('post')
->fetch();
?>
To see the request message that will be sent, use __toString():
<?php
// fetch a response object for a POST request with some data
$request = Solar::factory('Solar_Http_Request');
echo $request->setUri('http://example.com')
->setContent(array(...))
->setMethod('post')
->__toString();
?>
Catalog
This class is part of the Solar_Http package.
Inheritance:
- Solar_Base
- Solar_Http_Request_Adapter
Constants
None.
Public Properties
These are all the public properties in the Solar_Http_Request_Adapter class.
You can also view the list of all public, protected, and private properties.
$content- Content to send along with the request.
Public Methods
These are all the public methods in the Solar_Http_Request_Adapter class.
You can also view the list of all public, protected, and private methods.
__construct()- Constructor.
__destruct()- Default destructor; does nothing other than provide a safe fallback for calls to parent::__destruct().
__toString()- Returns this object as a string; effectively, the request message to be sent.
apiVersion()- Reports the API version for this class.
dump()- Convenience method for getting a dump the whole object, or one of its properties, or an external variable.
fetch()- Fetches from the specified URI and returns a Solar_Http_Response object (or an array of objects if there was more than one response).
fetchRaw()- Fetches from the specified URI and returns the response message as a string.
getContent()- Returns the body content.
getOptions()- Returns all options as an array.
locale()- Looks up class-specific locale strings based on a key.
setBasicAuth()- Sets "Basic" authorization credentials.
setCharset()- Sets the character set for the body content.
setContent()- Sets the body content; technically you can use the public $content property, but this allows method-chaining.
setContentType()- Sets the content-type for the body content.
setCookie()- Sets a cookie value in $this->_cookies to add to the request.
setHeader()- Sets a header value in $this->_headers for sending at fetch() time.
setMaxRedirects()- When making the request, allow no more than this many redirects.
setMethod()- Sets the HTTP method for the request (GET, POST, etc).
setProxy()- Send all requests through this proxy server.
setSslCafile()- Location of Certificate Authority file on local filesystem which should be used with the $_ssl_verify_peer option to authenticate the identity of the remote peer.
setSslCapath()- If $_ssl_cafile is not specified or if the certificate is not found there, this directory path is searched for a suitable certificate.
setSslLocalCert()- Path to local certificate file on filesystem.
setSslPassphrase()- Passphrase with which the $_ssl_local_cert file was encoded.
setSslVerifyPeer()- Require verification of SSL certificate used?
setTimeout()- Sets the request timeout in seconds.
setUri()- Sets the URI for the request.
setUserAgent()- Sets the User-Agent for the request.
setVersion()- Sets the HTTP protocol version for the request (1.0 or 1.1).
Local
- Overview
- Constants
- Properties
- Methods
- __construct()
- __destruct()
- __toString()
- _exception()
- _fetch()
- _parseCookie()
- _prepareRequest()
- apiVersion()
- dump()
- fetch()
- fetchRaw()
- getContent()
- getOptions()
- locale()
- setBasicAuth()
- setCharset()
- setContent()
- setContentType()
- setCookie()
- setHeader()
- setMaxRedirects()
- setMethod()
- setProxy()
- setSslCafile()
- setSslCapath()
- setSslLocalCert()
- setSslPassphrase()
- setSslVerifyPeer()
- setTimeout()
- setUri()
- setUserAgent()
- setVersion()