PHP Class Ergo\Http\Client

Show file Open project: 99designs/ergo

Public Properties

Property Type Description
$requestCount
$requestTime

Public Methods

Method Description
__construct ( string $url )
addFilter ( $filter ) Adds an HTTP header to all requests
addHeader ( $header ) Adds an HTTP header to all requests
delete ( $path ) : Response Sends a DELETE request
get ( $path ) : Response Sends a GET request
getBaseUrl ( ) : Url Return the base url this Client was instanciated with
post ( $path, $body, $contentType = null ) : Response Sends a POST request
put ( $path, $body, $contentType = null ) : Response Sends a PUT request
setConnectTimeoutMs ( $milliseconds ) Sets the connection timeout in milliseconds
setHttpAuth ( $user, $pass ) Sets HTTP authentication credentials
setHttpProxy ( $url ) Sets an HTTP proxy to use
setIPFamily ( $family ) Sets the IP Family to use when making requests.
setTimeout ( $seconds ) Sets the total timeout in seconds
transport ( $transport = null )

Private Methods

Method Description
_buildRequest ( $method, $path, $body = null, $contentType = null ) Builds an Request object
_dispatchRequest ( $request ) Dispatches a request via CURL
_redirect ( $location ) Redirect to a new url

Method Details

__construct() public method

public __construct ( string $url )
$url string

addFilter() public method

Adds an HTTP header to all requests
public addFilter ( $filter )

addHeader() public method

Adds an HTTP header to all requests
public addHeader ( $header )

delete() public method

Sends a DELETE request
public delete ( $path ) : Response
return Response

get() public method

Sends a GET request
public get ( $path ) : Response
return Response

getBaseUrl() public method

Return the base url this Client was instanciated with
public getBaseUrl ( ) : Url
return Url

post() public method

Sends a POST request
public post ( $path, $body, $contentType = null ) : Response
return Response

put() public method

Sends a PUT request
public put ( $path, $body, $contentType = null ) : Response
return Response

setConnectTimeoutMs() public method

Sets the connection timeout in milliseconds
public setConnectTimeoutMs ( $milliseconds )

setHttpAuth() public method

Sets HTTP authentication credentials
public setHttpAuth ( $user, $pass )

setHttpProxy() public method

Sets an HTTP proxy to use
public setHttpProxy ( $url )

setIPFamily() public method

Defaults to negotiating with the other end
public setIPFamily ( $family )

setTimeout() public method

Sets the total timeout in seconds
public setTimeout ( $seconds )

transport() public static method

public static transport ( $transport = null )

Property Details

$requestCount public static property

public static $requestCount

$requestTime public static property

public static $requestTime