============= HTTP Requests ============= The [`Solar_Http_Request`](/class/Solar_Http_Request_Adapter) class represents a standalone HTTP request (i.e., it's not an HTTP client, just a request). It uses adapters, so you can (in the future) change between a cURL, pecl_http, or sockets adapter -- but for now, the only adapter is the [streams-based](http://php.net/stream) one. It's a [fluent class](http://paul-m-jones.com/blog/?p=188), which makes the code a little prettier at times. Here's a basic GET request that sends "?foo=bar" as the query string, and fetches a [[Solar_Http_Response::Overview | Solar_Http_Response]] object. {{code: php $request = Solar::factory('Solar_Http_Request'); $request->setUri('http://example.com/index.php') ->setContent(array('foo' => 'bar')); $response = $request->fetch(); }} (You could also set the query string in the URI if you wanted, but using setContent() does all the esaping for you.) Here's the same thing as a POST: {{code: php $request = Solar::factory('Solar_Http_Request'); $request->setUri('http://example.com/index.php') ->setContent(array('foo' => 'bar')) ->setMethod('post'); $response = $request->fetch(); }} And here's a request with a lot of customization: {{code: php $request = Solar::factory('Solar_Http_Request'); $request->setUri('http://example.com/index.php') ->setMethod('post') ->setHeader('X-Zim', 'Kneel before Zim!') ->setUserAgent('Irken Robot Gir') ->setBasicAuth('username', 'password') ->setContent(array('foo' => 'bar')); $response = $request->fetch(); }} Right now, `Solar_Http_Request` doesn't handle file uploads or the `multipart/form-data` content type, but that functionality is planned for a future release. However, it does provide SSL support through PHP streams. You can make a secure request like this (note the use of `https` instead of `http`): {{code: php $request = Solar::factory('Solar_Http_Request'); $request->setUri('https://example.com/index.php') ->setContent(array('foo' => 'bar')); $response = $request->fetch(); }} If you need to, you can set various TLS and SSL parameters using these methods: * [[Solar_Http_Request_Adapter::setSslCafile()]] * [[Solar_Http_Request_Adapter::setSslCapath()]] * [[Solar_Http_Request_Adapter::setSslLocalCert()]] * [[Solar_Http_Request_Adapter::setSslPassphrase()]] * [[Solar_Http_Request_Adapter::setSslVerifyPeer()]]