EasyRdf API Documentation
Class

EasyRdf_Http_Response

class EasyRdf_Http_Response

Class that represents an HTTP 1.0 / 1.1 response message.

Methods

object __construct(int $status, array $headers, string $body = null, string $version = '1.1', string $message = null)

Constructor.

boolean isSuccessful()

Check whether the response in successful

boolean isError()

Check whether the response is an error

boolean isRedirect()

Check whether the response is a redirection

int getStatus()

Get the HTTP response status code

string getMessage()

Return a message describing the HTTP response code (Eg.

string getBody()

Get the response body as string

string getRawBody()

Get the raw response body (as transfered "on wire") as string

string getVersion()

Get the HTTP version of the response

array getHeaders()

Get the response headers

string|array|null getHeader(string$header $header)

Get a specific header as string, or null if it is not set

string getHeadersAsString(boolean $statusLine = true, string $br = ' ')

Get all headers as string

static EasyRdf_Http_Response fromString(string $responseStr)

Create an EasyRdfHttpResponse object from a HTTP response string

static string decodeChunkedBody(string $body)

Decode a "chunked" transfer-encoded body and return the decoded text

string asString(string $br = ' ')

Get the entire response as string

string __toString()

Implements magic __toString()

Details

at line 91
public object __construct(int $status, array $headers, string $body = null, string $version = '1.1', string $message = null)

Constructor.

Parameters

int $status HTTP Status code
array $headers The HTTP response headers
string $body The content of the response
string $version The HTTP Version (1.0 or 1.1)
string $message The HTTP response Message

Return Value

object EasyRdfHttpResponse

at line 114
public boolean isSuccessful()

Check whether the response in successful

Return Value

boolean

at line 124
public boolean isError()

Check whether the response is an error

Return Value

boolean

at line 134
public boolean isRedirect()

Check whether the response is a redirection

Return Value

boolean

at line 144
public int getStatus()

Get the HTTP response status code

Return Value

int

at line 155
public string getMessage()

Return a message describing the HTTP response code (Eg.

"OK", "Not Found", "Moved Permanently")

Return Value

string

at line 165
public string getBody()

Get the response body as string

Return Value

string

at line 190
public string getRawBody()

Get the raw response body (as transfered "on wire") as string

If the body is encoded (with Transfer-Encoding, not content-encoding - IE "chunked" body), gzip compressed, etc. it will not be decoded.

Return Value

string

at line 200
public string getVersion()

Get the HTTP version of the response

Return Value

string

at line 210
public array getHeaders()

Get the response headers

Return Value

array

at line 221
public string|array|null getHeader(string$header $header)

Get a specific header as string, or null if it is not set

Parameters

string$header $header

Return Value

string|array|null

at line 238
public string getHeadersAsString(boolean $statusLine = true, string $br = ' ')

Get all headers as string

Parameters

boolean $statusLine Whether to return the first status line (ie "HTTP 200 OK")
string $br Line breaks (eg. "\n", "\r\n", "
")

Return Value

string

at line 266
static public EasyRdf_Http_Response fromString(string $responseStr)

Create an EasyRdfHttpResponse object from a HTTP response string

Parameters

string $responseStr

Return Value

EasyRdf_Http_Response

at line 319
static public string decodeChunkedBody(string $body)

Decode a "chunked" transfer-encoded body and return the decoded text

Parameters

string $body

Return Value

string

at line 346
public string asString(string $br = ' ')

Get the entire response as string

Parameters

string $br Line breaks (eg. "\n", "\r\n", "
")

Return Value

string

at line 356
public string __toString()

Implements magic __toString()

Return Value

string