class HttpResponse (View source)

Constants

REDIRECT

REDIRECT_PERM

REDIRECT_FOUND

REDIRECT_POST

REDIRECT_PROXY

REDIRECT_TEMP

Properties

static protected $cache
static protected $gzip
static protected $eTag
static protected $lastModified
static protected $cacheControl
static protected $contentType
static protected $contentDisposition
static protected $bufferSize
static protected $throttleDelay

Methods

static bool
setHeader(string $name, mixed $value = null, bool $replace = null)

(PECL pecl_http >= 0.12.0)
Set header

static mixed
getHeader(string $name = null)

(PECL pecl_http >= 0.12.0)
Get header

static bool
setETag(string $etag)

(PECL pecl_http >= 0.10.0)
Set ETag

static string
getETag()

(PECL pecl_http >= 0.10.0)
Get ETag

static bool
setLastModified(int $timestamp)

(PECL pecl_http >= 0.12.0)
Set last modified

static int
getLastModified()

(PECL pecl_http >= 0.12.0)
Get last modified

static bool
setContentDisposition(string $filename, bool $inline = null)

(PECL pecl_http >= 0.10.0)
Set content disposition

static string
getContentDisposition()

(PECL pecl_http >= 0.10.0)
Get content disposition

static bool
setContentType(string $content_type)

(PECL pecl_http >= 0.10.0)
Set content type

static string
getContentType()

(PECL pecl_http >= 0.10.0)
Get content type

static string|false
guessContentType(string $magic_file, int $magic_mode = null)

(PECL pecl_http >= 0.13.0)
Guess content type

static bool
setCache(bool $cache)

(PECL pecl_http >= 0.10.0)
Set cache

static bool
getCache()

(PECL pecl_http >= 0.10.0)
Get cache

static bool
setCacheControl(string $control, int $max_age = null, bool $must_revalidate = null)

(PECL pecl_http >= 0.10.0)
Set cache control

static string
getCacheControl()

(PECL pecl_http >= 0.10.0)
Get cache control

static bool
setGzip(bool $gzip)

(PECL pecl_http >= 0.10.0)
Set gzip

static bool
getGzip()

(PECL pecl_http >= 0.10.0)
Get gzip

static bool
setThrottleDelay(float $seconds)

(PECL pecl_http >= 0.10.0)
Set throttle delay

static float
getThrottleDelay()

(PECL pecl_http >= 0.10.0)
Get throttle delay

static bool
setBufferSize(int $bytes)

(PECL pecl_http >= 0.10.0)
Set buffer size

static int
getBufferSize()

(PECL pecl_http >= 0.10.0)
Get buffer size

static bool
setData(mixed $data)

(PECL pecl_http >= 0.10.0)
Set data

static string
getData()

(PECL pecl_http >= 0.10.0)
Get data

static bool
setFile(string $file)

(PECL pecl_http >= 0.10.0)
Set file

static string
getFile()

(PECL pecl_http >= 0.10.0)
Get file

static bool
setStream(resource $stream)

(PECL pecl_http >= 0.10.0)
Set stream

static resource
getStream()

(PECL pecl_http >= 0.10.0)
Get Stream

static bool
send(bool $clean_ob = null)

(PECL pecl_http >= 0.10.0)
Send response

static void
capture()

(PECL pecl_http >= 0.10.0)
Capture script output

static void
redirect(null|string $url = null, array|null $params = null, null|bool $session = null, null|int $status = null)

(PECL pecl_http >= 0.10.0)
Redirect

static bool
status(int $status)

(PECL pecl_http >= 0.12.0)
Send HTTP response status

static array
getRequestHeaders()

(PECL pecl_http >= 0.10.0)
Get request headers

static string
getRequestBody()

(PECL pecl_http >= 0.10.0)
Get request body

static resource
getRequestBodyStream()

(PECL pecl_http >= 0.10.0)
Get request body stream

Details

static bool setHeader(string $name, mixed $value = null, bool $replace = null)

(PECL pecl_http >= 0.12.0)
Set header

Parameters

string $name

the name of the header

mixed $value

[optional]

the value of the header; if not set, no header with this name will be sent

bool $replace

[optional]

whether an existing header should be replaced

Return Value

bool

true on success or false on failure.

static mixed getHeader(string $name = null)

(PECL pecl_http >= 0.12.0)
Get header

Parameters

string $name

[optional]

specifies the name of the header to read; if empty or omitted, an associative array with all headers will be returned

Return Value

mixed

either a string containing the value of the header matching name, false on failure, or an associative array with all headers.

static bool setETag(string $etag)

(PECL pecl_http >= 0.10.0)
Set ETag

Parameters

string $etag

unquoted string as parameter containing the ETag

Return Value

bool

true on success or false on failure.

static string getETag()

(PECL pecl_http >= 0.10.0)
Get ETag

Return Value

string

the calculated or previously set ETag as unquoted string.

static bool setLastModified(int $timestamp)

(PECL pecl_http >= 0.12.0)
Set last modified

Parameters

int $timestamp

Unix timestamp representing the last modification time of the sent entity

Return Value

bool

true on success or false on failure.

static int getLastModified()

(PECL pecl_http >= 0.12.0)
Get last modified

Return Value

int

the calculated or previously set Unix timestamp.

static bool setContentDisposition(string $filename, bool $inline = null)

(PECL pecl_http >= 0.10.0)
Set content disposition

Parameters

string $filename

the file name the "Save as..." dialog should display

bool $inline

[optional]

if set to true and the user agent knows how to handle the content type, it will probably not cause the popup window to be shown

Return Value

bool

true on success or false on failure.

static string getContentDisposition()

(PECL pecl_http >= 0.10.0)
Get content disposition

Return Value

string

the current content disposition as string like sent in a header.

static bool setContentType(string $content_type)

(PECL pecl_http >= 0.10.0)
Set content type

Parameters

string $content_type

the content type of the sent entity (primary/secondary)

Return Value

bool

true on success, or false if the content type does not seem to contain a primary and secondary content type part.

static string getContentType()

(PECL pecl_http >= 0.10.0)
Get content type

Return Value

string

the currently set content type as string.

static string|false guessContentType(string $magic_file, int $magic_mode = null)

(PECL pecl_http >= 0.13.0)
Guess content type

Parameters

string $magic_file

specifies the magic.mime database to use

int $magic_mode

[optional]

flags for libmagic

Return Value

string|false

the guessed content type on success or false on failure.

static bool setCache(bool $cache)

(PECL pecl_http >= 0.10.0)
Set cache

Parameters

bool $cache

whether caching should be attempted

Return Value

bool

true on success or false on failure.

static bool getCache()

(PECL pecl_http >= 0.10.0)
Get cache

Return Value

bool

true if caching should be attempted, else false.

static bool setCacheControl(string $control, int $max_age = null, bool $must_revalidate = null)

(PECL pecl_http >= 0.10.0)
Set cache control

Parameters

string $control

the primary cache control setting

int $max_age

[optional]

the max-age in seconds, suggesting how long the cache entry is valid on the client side

bool $must_revalidate

[optional]

whether the cached entity should be revalidated by the client for every request

Return Value

bool

true on success, or false if control does not match one of public, private or no-cache.

static string getCacheControl()

(PECL pecl_http >= 0.10.0)
Get cache control

Return Value

string

the current cache control setting as a string like sent in a header.

static bool setGzip(bool $gzip)

(PECL pecl_http >= 0.10.0)
Set gzip

Parameters

bool $gzip

whether GZip compression should be enabled

Return Value

bool

true on success or false on failure.

static bool getGzip()

(PECL pecl_http >= 0.10.0)
Get gzip

Return Value

bool

true if GZip compression is enabled, else false.

static bool setThrottleDelay(float $seconds)

(PECL pecl_http >= 0.10.0)
Set throttle delay

Parameters

float $seconds

seconds to sleep after each chunk sent

Return Value

bool

true on success or false on failure.

static float getThrottleDelay()

(PECL pecl_http >= 0.10.0)
Get throttle delay

Return Value

float

a float representing the throttle delay in seconds.

static bool setBufferSize(int $bytes)

(PECL pecl_http >= 0.10.0)
Set buffer size

Parameters

int $bytes

the chunk size in bytes

Return Value

bool

true on success or false on failure.

static int getBufferSize()

(PECL pecl_http >= 0.10.0)
Get buffer size

Return Value

int

an int representing the current buffer size in bytes.

static bool setData(mixed $data)

(PECL pecl_http >= 0.10.0)
Set data

Parameters

mixed $data

data to send

Return Value

bool

true on success or false on failure.

static string getData()

(PECL pecl_http >= 0.10.0)
Get data

Return Value

string

a string containing the previously set data to send.

static bool setFile(string $file)

(PECL pecl_http >= 0.10.0)
Set file

Parameters

string $file

the path to the file to send

Return Value

bool

true on success or false on failure.

static string getFile()

(PECL pecl_http >= 0.10.0)
Get file

Return Value

string

the previously set path to the file to send as string.

static bool setStream(resource $stream)

(PECL pecl_http >= 0.10.0)
Set stream

Parameters

resource $stream

already opened stream from which the data to send will be read

Return Value

bool

true on success or false on failure.

static resource getStream()

(PECL pecl_http >= 0.10.0)
Get Stream

Return Value

resource

the previously set resource.

static bool send(bool $clean_ob = null)

(PECL pecl_http >= 0.10.0)
Send response

Parameters

bool $clean_ob

[optional]

whether to destroy all previously started output handlers and their buffers

Return Value

bool

true on success or false on failure.

static void capture()

(PECL pecl_http >= 0.10.0)
Capture script output

Return Value

void

static void redirect(null|string $url = null, array|null $params = null, null|bool $session = null, null|int $status = null)

(PECL pecl_http >= 0.10.0)
Redirect

Parameters

null|string $url [optional]
array|null $params [optional]
null|bool $session [optional]
null|int $status [optional]

Return Value

void

static bool status(int $status)

(PECL pecl_http >= 0.12.0)
Send HTTP response status

Parameters

int $status

Return Value

bool

static array getRequestHeaders()

(PECL pecl_http >= 0.10.0)
Get request headers

Return Value

array

static string getRequestBody()

(PECL pecl_http >= 0.10.0)
Get request body

Return Value

string

static resource getRequestBodyStream()

(PECL pecl_http >= 0.10.0)
Get request body stream

Return Value

resource