HttpSourceConnection

Extends \Object

Default HttpSource connection class

package

HttpSource

subpackage

Model.Datasource

Methods

Constructor

__construct(array $config = array(), \HttpSocket $Transport = null) 

Arguments

$config

array

$Transport

\HttpSocket

Checks if we can retry request

_canRetryRequest(\HttpSocketResponse $Response, integer $currentAttempt) : boolean

Arguments

$Response

\HttpSocketResponse

$currentAttempt

integer

Response

boolean

Decodes the response based on the content type

_decode() : array
throws

If content type decoder not found or response is not an object

Response

array

Decoded response

Extract remote error from response

_extractRemoteError() : string

Response

string

Initialize default decoders

_initDefaultDecoders() 

Save dump into log

_logDump(\HttpSocketResponse|boolean $Response) : boolean

Arguments

$Response

\HttpSocketResponse|boolean

Response

boolean

Make attempts to request

_request(array $request, integer $currentAttempt = 1) : boolean

Arguments

$request

array

$currentAttempt

integer

Response

boolean

Delay before newt request

_requestDelay(\HttpSocketResponse $Response, integer $currentAttempt) 

Arguments

$Response

\HttpSocketResponse

$currentAttempt

integer

Supplements a request array with oauth credentials

addOauth(array $request) : array
throws

Arguments

$request

array

Response

array

$request

Supplements a request array with oauth credentials

addOauthV2(array $request) : array

Arguments

$request

array

Response

array

$request

Disconnect

disconnect() 

Returns affected rows

getAffected() : integer|string

Response

integer|string

Gets credentials data

getCredentials() : array

Response

array

Get decoder by given $contentType.

getDecoder(string $contentType) : callable

If decoder not found writes log and throw exception.

throws

Arguments

$contentType

string

Response

callable

Get decoders

getDecoders() : array

Response

array

Returns last error

getError() : string

Response

string

Returns number of rows in result

getNumRows(mixed $result) : integer|string

Arguments

$result

mixed

Response

integer|string

Returns lst request query

getQuery() : string

Response

string

Returns last Response

getResponse() : \HttpSocketResponse

Response

\HttpSocketResponse

Returns last request took time

getTook() : integer|string

Response

integer|string

Return current transport

getTransport() : \HttpSocket

Response

\HttpSocket

Quote data

quote(mixed $data, integer $type = \PDO::PARAM_STR) : mixed

Arguments

$data

mixed

$type

integer

Response

mixed

Issue the specified request and decode it on success

request(array $request = array()) : mixed
throws

Arguments

$request

array

Response

mixed

false on error, decoded response array on success

Reset state variables

reset() 

Sets credentials data

setCredentials(array $credentials = array()) 

Arguments

$credentials

array

Add decoder for given $contentType

setDecoder(string|array $contentType, callable $callback, boolean $replace = false) 

Arguments

$contentType

string|array

Content type

$callback

callable

Function used for decoding

$replace

boolean

Replace decoder if already set or not. Default false

Properties

Request error

_error : string
var

Type(s)

string

Request time

_took : integer|string
var

Type(s)

integer|string

Affected rows

_affected : integer|string
var

Type(s)

integer|string

Response object

_Response : \HttpSocketResponse
var

Type(s)

\HttpSocketResponse

Object for requests

_Transport : \HttpSocket
var

Type(s)

\HttpSocket

Connection config

_config : array
var

Type(s)

array

Credentials for request, for ex: login, password, token, etc

_credentials : array
var

Type(s)

array

Contains all possible decoders

_decoders : array
var

Type(s)

array

Last decoded response

_lastResponse : array
var

Type(s)

array