Overview

Namespaces

  • None
  • OpenCloud
    • Autoscale
      • Resource
    • CloudMonitoring
      • Exception
      • Resource
    • Common
      • Exceptions
      • Log
      • Request
        • Response
    • Compute
    • Database
    • DNS
    • LoadBalancer
      • Resources
    • ObjectStore
      • Resource
    • Orchestration
    • Volume
  • PHP

Classes

  • Curl

Interfaces

  • HttpRequestInterface
  • Overview
  • Namespace
  • Class
  • Tree
  • Download

Class Curl

The CurlRequest class is a simple wrapper to CURL functions. Not only does this permit stubbing of the interface as described under the HttpRequest interface, it could potentially allow us to replace the interface methods with other function calls in the future.

OpenCloud\Common\Base
Extended by OpenCloud\Common\Request\Curl implements OpenCloud\Common\Request\HttpRequestInterface
Namespace: OpenCloud\Common\Request
Author: Glen Campbell <glen.campbell@rackspace.com>
Api
Located at OpenCloud/Common/Request/Curl.php
Methods summary
public
# __construct( string $url, string $method = 'GET', array $options = array() )

Initializes the CURL handle and HTTP method

Initializes the CURL handle and HTTP method

The constructor also sets a number of default values for options.

Parameters

$url
string
$url the URL to connect to
$method
string
$method the HTTP method (default "GET")
$options
array
$options optional hashed array of options => value pairs
public
# setOption( const $name, mixed $value )

Sets a CURL option

Sets a CURL option

Parameters

$name
const
$name - a CURL named constant; e.g. CURLOPT_TIMEOUT
$value
mixed
$value - the value for the option
public
# setConnectTimeout( integer $value )

Explicit method for setting the connect timeout

Explicit method for setting the connect timeout

The connect timeout is the time it takes for the initial connection request to be established. It is different than the HTTP timeout, which is the time for the entire request to be serviced.

Parameters

$value
integer
$value The connection timeout in seconds. Use 0 to wait indefinitely (NOT recommended)
public
# setHttpTimeout( integer $value )

Explicit method for setting the HTTP timeout

Explicit method for setting the HTTP timeout

The HTTP timeout is the time it takes for the HTTP request to be serviced. This value is usually larger than the connect timeout value.

Parameters

$value
integer
$value - the number of seconds to wait before timing out the HTTP request.
public
# setRetries( mixed $value )

Sets the number of retries

Sets the number of retries

If you set this to a non-zero value, then it will repeat the request up to that number.

public
# setheaders( array $array )

Simplified method for setting lots of headers at once

Simplified method for setting lots of headers at once

This method takes an associative array of header/value pairs and calls the setheader() method on each of them.

Parameters

$array
array
$arr an associative array of headers

Implementation of

OpenCloud\Common\Request\HttpRequestInterface::setheaders()
public
# setHeader( string $name, mixed $value )

Sets a single header

Sets a single header

For example, to set the content type to JSON: $request->SetHeader('Content-Type','application/json');

Parameters

$name
string
$name The name of the header
$value
mixed
$value The value of the header
public OpenCloud\HttpResponse
# execute( )

Executes the current request

Executes the current request

This method actually performs the request using the values set previously. It throws a OpenCloud\HttpError exception on any CURL error.

Returns

OpenCloud\HttpResponse

Throws

OpenCloud\HttpError

CodeCoverageIgnore

public
# info( )

returns an array of information about the request

returns an array of information about the request

public
# errno( )

returns the most recent CURL error number

returns the most recent CURL error number

public
# error( )

returns the most recent CURL error string

returns the most recent CURL error string

public
# close( )

Closes the HTTP request

Closes the HTTP request

Implementation of

OpenCloud\Common\Request\HttpRequestInterface::close()
public
# returnHeaders( )

Returns the headers as an array

Returns the headers as an array

public
# _get_header_cb( mixed $ch, string $header )

This is a callback method used to handle the returned HTTP headers

This is a callback method used to handle the returned HTTP headers

Parameters

$ch
mixed
$ch a CURL handle
$header
string
$header the header string in its entirety
Methods inherited from OpenCloud\Common\Base
__set(), checkJsonError(), getHttpRequestObject(), getLogger(), makeQueryString(), populate(), setLogger(), setProperty(), url()
Methods inherited from OpenCloud\Common\Request\HttpRequestInterface
Execute(), SetHeader(), SetOption()
PHP OpenCloud API API documentation generated by ApiGen 2.8.0