PHPXMLRPC 4.11.0

Response
in package
uses CharsetEncoderAware, DeprecationLogger, PayloadBearer

This class provides the representation of the response of an XML-RPC server.

Server-side, a server method handler will construct a Response and pass it as its return value. An identical Response object will be returned by the result of an invocation of the send() method of the Client class.

Tags
@property

array _cookies deprecated. Access via httpResponse()['cookies'], set via $httpResponse['cookies']

Table of Contents

Properties

$content_type  : string
$errno  : int
$errstr  : string
$hdrs  : array<string|int, mixed>
$payload  : string
$raw_data  : string
$val  : Value|string|mixed
$valtyp  : string
$charsetEncoder  : mixed
$content_type  : string
$errno  : int
$errstr  : string
$httpResponse  : mixed
$payload  : string
$val  : Value|string|mixed
$valtyp  : string

Methods

__construct()  : mixed
__get()  : mixed
__isset()  : mixed
__set()  : mixed
__unset()  : mixed
cookies()  : array<string|int, array<string|int, mixed>>
Returns an array with the cookies received from the server.
faultCode()  : int
Returns the error code of the response.
faultString()  : string
Returns the error code of the response.
getCharsetEncoder()  : mixed
getContentType()  : string
getPayload()  : string
httpResponse()  : array<string|int, mixed>
Returns an array with info about the http response received from the server.
serialize()  : string
Returns xml representation of the response, XML prologue _not_ included. Sets `payload` and `content_type` properties
setCharsetEncoder()  : void
value()  : Value|string|mixed
Returns the value received by the server. If the Response's faultCode is non-zero then the value returned by this method should not be used (it may not even be an object).
valueType()  : string
xml_header()  : string
logDeprecation()  : mixed
logDeprecationUnlessCalledBy()  : void

Properties

$content_type

public string $content_type

deprecated - public access left in purely for BC. Access via getContentType()/setPayload()

$errno

public int $errno

deprecated - public access left in purely for BC. Access via faultCode()/__construct()

$errstr

public string $errstr

deprecated - public access left in purely for BC. Access faultString()/__construct()

$hdrs

public array<string|int, mixed> $hdrs

deprecated. Access via httpResponse()['headers'], set via $httpResponse['headers']

$payload

public string $payload

deprecated - public access left in purely for BC. Access via getPayload()/setPayload()

$raw_data

public string $raw_data

deprecated. Access via httpResponse()['raw_data'], set via $httpResponse['raw_data']

$val

public Value|string|mixed $val

deprecated - public access left in purely for BC. Access via value()/__construct()

$valtyp

public string $valtyp

deprecated - public access left in purely for BC. Access via valueType()/__construct()

$httpResponse

protected mixed $httpResponse = array('headers' => array(), 'cookies' => array(), 'raw_data' => '', 'status_code' => null)

Methods

__construct()

public __construct(Value|string|mixed $val[, int $fCode = 0 ][, string $fString = '' ][, string $valType = '' ][, array<string|int, mixed>|null $httpResponse = null ]) : mixed
Parameters
$val : Value|string|mixed

either a Value object, a php value or the xml serialization of an xml-rpc value (a string). Note that using anything other than a Value object wll have an impact on serialization.

$fCode : int = 0

set it to anything but 0 to create an error response. In that case, $val is discarded

$fString : string = ''

the error string, in case of an error response

$valType : string = ''

The type of $val passed in. Either 'xmlrpcvals', 'phpvals' or 'xml'. Leave empty to let the code guess the correct type by looking at $val - in which case strings are assumed to be serialized xml

$httpResponse : array<string|int, mixed>|null = null

this should be set when the response is being built out of data received from http (i.e. not when programmatically building a Response server-side). Array keys should include, if known: headers, cookies, raw_data, status_code

Tags
todo

add check that $val / $fCode / $fString is of correct type? We could at least log a warning for fishy cases... NB: as of now we do not do it, since it might be either an xml-rpc value or a plain php val, or a complete xml chunk, depending on usage of Client::send() inside which the constructor is called.

__get()

public & __get(mixed $name) : mixed
Parameters
$name : mixed

__isset()

public __isset(mixed $name) : mixed
Parameters
$name : mixed

__set()

public __set(mixed $name, mixed $value) : mixed
Parameters
$name : mixed
$value : mixed

__unset()

public __unset(mixed $name) : mixed
Parameters
$name : mixed

cookies()

Returns an array with the cookies received from the server.

public cookies() : array<string|int, array<string|int, mixed>>

Array has the form: $cookiename => array ('value' => $val, $attr1 => $val1, $attr2 => $val2, ...) with attributes being e.g. 'expires', 'path', domain'. NB: cookies sent as 'expired' by the server (i.e. with an expiry date in the past) are still present in the array. It is up to the user-defined code to decide how to use the received cookies, and whether they have to be sent back with the next request to the server (using $client->setCookie) or not. The values are filled in at constructor time, and might not be set for specific debug values used.

Return values
array<string|int, array<string|int, mixed>>

array of cookies received from the server

faultCode()

Returns the error code of the response.

public faultCode() : int
Return values
int

the error code of this response (0 for not-error responses)

faultString()

Returns the error code of the response.

public faultString() : string
Return values
string

the error string of this response ('' for not-error responses)

getContentType()

public getContentType() : string
Return values
string

getPayload()

public getPayload() : string
Return values
string

httpResponse()

Returns an array with info about the http response received from the server.

public httpResponse() : array<string|int, mixed>

The values are filled in at constructor time, and might not be set for specific debug values used.

Return values
array<string|int, mixed>

array with keys 'headers', 'cookies', 'raw_data' and 'status_code'.

serialize()

Returns xml representation of the response, XML prologue _not_ included. Sets `payload` and `content_type` properties

public serialize([string $charsetEncoding = '' ]) : string
Parameters
$charsetEncoding : string = ''

the charset to be used for serialization. If null, US-ASCII is assumed

Tags
throws
StateErrorException

if the response was built out of a value of an unsupported type

Return values
string

the xml representation of the response

setCharsetEncoder()

public static setCharsetEncoder(mixed $charsetEncoder) : void
Parameters
$charsetEncoder : mixed

value()

Returns the value received by the server. If the Response's faultCode is non-zero then the value returned by this method should not be used (it may not even be an object).

public value() : Value|string|mixed
Return values
Value|string|mixed

the Value object returned by the server. Might be an xml string or plain php value depending on the convention adopted when creating the Response

valueType()

public valueType() : string
Return values
string

xml_header()

public xml_header([string $charsetEncoding = '' ]) : string
Parameters
$charsetEncoding : string = ''
Return values
string

logDeprecation()

protected logDeprecation(mixed $message) : mixed
Parameters
$message : mixed

logDeprecationUnlessCalledBy()

protected logDeprecationUnlessCalledBy(string $expectedCaller) : void
Parameters
$expectedCaller : string

atm only the method name is supported


        
On this page

Search results