Class HttpResponse (namespace Nette\Web)


HttpResponse class.

Object
   |
   --HttpResponse

Implements interfaces:

Copyright: Copyright (c) 2004, 2010 David Grudl
Located: in /Web/HttpResponse.php (line 25)
Public Method Summary
void
void
addHeader (string $name, string $value)
Adds HTTP header.
static string
date ([string|int|DateTime $time = NULL])
Returns HTTP valid date format.
void
deleteCookie (string $name, [string $path = NULL], [string $domain = NULL], [bool $secure = NULL])
Deletes a cookie.
bool
Enables compression. (warning: may not work)
void
expire ($seconds)
int
getCode ()
Returns HTTP response code.
mixed
getHeader (string $header, [mixed $default = NULL])
Return the value of the HTTP header.
array
Returns a list of headers to sent.
bool
isSent ()
Checks if headers have been sent.
void
redirect (string $url, [int $code = self::S302_FOUND])
Redirects to a new URL. Note: call exit() after it.
HttpResponse
setCode (int $code)
Sets HTTP response code.
HttpResponse
setContentType (string $type, [string $charset = NULL])
Sends a Content-type HTTP header.
HttpResponse
setCookie (string $name, string $value, string|int|DateTime $time, [string $path = NULL], [string $domain = NULL], [bool $secure = NULL])
Sends a cookie.
HttpResponse
setExpiration (string|int|DateTime $time)
Sets the number of seconds before a page cached on a browser expires.
HttpResponse
setHeader (string $name, string $value)
Sends a HTTP header and replaces a previous one.
Methods Inherited From Object
extensionMethod(), getClass(), getReflection(), __call(), __callStatic(), __get(), __isset(), __set(), __unset()
Variable Summary
string $cookieDomain ''

line 31

The domain in which the cookie will be available
string $cookiePath '/'

line 34

The path in which the cookie will be available
string $cookieSecure FALSE

line 37

The path in which the cookie will be available

Method Details

line 290

__destruct

public void __destruct ()

Output
void  

line 119

addHeader

public void addHeader (string $name, string $value)

Adds HTTP header.

Implementation of:

Input
string $name header name
string $value header value
Output
void  
Throws
throws InvalidStateException if HTTP headers have been sent

line 249

date

public static string date ([string|int|DateTime $time = NULL])

Returns HTTP valid date format.

Input
string|int|DateTime $time
Output
string  

line 345

deleteCookie

public void deleteCookie (string $name, [string $path = NULL], [string $domain = NULL], [bool $secure = NULL])

Deletes a cookie.

Implementation of:

Input
string $name name of the cookie.
string $path
string $domain
bool $secure
Output
void  
Throws
throws InvalidStateException if HTTP headers have been sent

line 262

enableCompression

public bool enableCompression ()

Enables compression. (warning: may not work)

Output
bool  

line 189

expire

public void expire ($seconds)

Input
$seconds
Output
void  
Tags
Deprecated

line 82

getCode

public int getCode ()

Returns HTTP response code.

Implementation of:

Output
int  

line 214

getHeader

public mixed getHeader (string $header, [mixed $default = NULL])

Return the value of the HTTP header.

Input
string $header
mixed $default
Output
mixed  

line 232

getHeaders

public array getHeaders ()

Returns a list of headers to sent.

Implementation of:

Output
array  

line 201

isSent

public bool isSent ()

Checks if headers have been sent.

Implementation of:

Output
bool  

line 152

redirect

public void redirect (string $url, [int $code = self::S302_FOUND])

Redirects to a new URL. Note: call exit() after it.

Implementation of:

Input
string $url URL
int $code HTTP code
Output
void  
Throws
throws InvalidStateException if HTTP headers have been sent

line 51

setCode

public HttpResponse setCode (int $code)

Sets HTTP response code.

Implementation of:

Input
int $code
Output
HttpResponse provides a fluent interface
Throws
throws InvalidStateException if HTTP headers have been sent
throws InvalidArgumentException if code is invalid

line 137

setContentType

public HttpResponse setContentType (string $type, [string $charset = NULL])

Sends a Content-type HTTP header.

Implementation of:

Input
string $type mime-type
string $charset charset
Output
HttpResponse provides a fluent interface
Throws
throws InvalidStateException if HTTP headers have been sent

line 316

setCookie

public HttpResponse setCookie (string $name, string $value, string|int|DateTime $time, [string $path = NULL], [string $domain = NULL], [bool $secure = NULL])

Sends a cookie.

Implementation of:

Input
string $name name of the cookie
string $value value
string|int|DateTime $time expiration time, value 0 means "until the browser is closed"
string $path
string $domain
bool $secure
Output
HttpResponse provides a fluent interface
Throws
throws InvalidStateException if HTTP headers have been sent

line 172

setExpiration

public HttpResponse setExpiration (string|int|DateTime $time)

Sets the number of seconds before a page cached on a browser expires.

Implementation of:

Input
string|int|DateTime $time time, value 0 means "until the browser is closed"
Output
HttpResponse provides a fluent interface
Throws
throws InvalidStateException if HTTP headers have been sent

line 96

setHeader

public HttpResponse setHeader (string $name, string $value)

Sends a HTTP header and replaces a previous one.

Implementation of:

Input
string $name header name
string $value header value
Output
HttpResponse provides a fluent interface
Throws
throws InvalidStateException if HTTP headers have been sent