HeaderHelper
- Type
- Class
- Namespace
- Craft
- Inherits
- Craft\HeaderHelper
- Since
- 1.3
Class HeaderHelper
See also http://craftcms.com
View source (opens new window)
# Public Methods
Method | Description |
---|---|
getHeader() | Returns the value of a given header, if it has been set. |
getMimeType() | Returns the MIME type that is going to be included in the response via the Content-Type header, whether that has been set explicitly in the PHP code or if it's going to be based on the default_mimetype setting in php.ini. |
isHeaderSet() | Checks whether a header is currently set or not. |
removeHeader() | Removes a header by key. |
setContentTypeByExtension() | Sets the Content-Type header based on a file extension. |
setDownload() | Forces a file download. Be sure to give the right extension. |
setExpires() | Tells the browser not to request this content again the next $sec seconds but use the browser cached content. |
setHeader() | Called to output a header. |
setLength() | Tells the browser the length of the following content. This mostly makes sense when using the download function so the browser can calculate how many bytes are left during the process. |
setNoCache() | Tells the browser not to cache the following content |
setPrivate() | Tells the browser that the following content is private |
setPublic() | Tells the browser that the following content is public |
# getHeader()
Returns the value of a given header, if it has been set.
View source (opens new window)
Arguments
$name
(string (opens new window)) – The name of the header.
Returns
string (opens new window), null (opens new window) – The value of the header, or null
if it hasn’t been set.
Signature
public static string, null getHeader ( $name )
# getMimeType()
Returns the MIME type that is going to be included in the response via the Content-Type header, whether that has been set explicitly in the PHP code or if it's going to be based on the default_mimetype setting in php.ini.
View source (opens new window)
Returns
Signature
public static string getMimeType ( )
# isHeaderSet()
Checks whether a header is currently set or not.
View source (opens new window)
Arguments
$name
(string (opens new window))
Returns
Signature
public static boolean isHeaderSet ( $name )
# removeHeader()
Signature
public static null removeHeader ( $key )
# setContentTypeByExtension()
Sets the Content-Type header based on a file extension.
View source (opens new window)
Arguments
$extension
(string (opens new window))
Returns
boolean (opens new window) – Whether setting the header was successful.
Signature
public static boolean setContentTypeByExtension ( $extension )
# setDownload()
Forces a file download. Be sure to give the right extension.
View source (opens new window)
Arguments
$fileName
(string (opens new window)) – The name of the file when it's downloaded$fileSize
(integer (opens new window)) – The size in bytes.
Returns
Signature
public static null setDownload ( $fileName, $fileSize = null )
# setExpires()
Tells the browser not to request this content again the next $sec seconds but use the browser cached content.
View source (opens new window)
Arguments
$seconds
(integer (opens new window)) – Time in seconds to hold in browser cache
Returns
Signature
public static null setExpires ( $seconds = 300 )
# setHeader()
Called to output a header.
View source (opens new window)
Arguments
$header
(array (opens new window)) – Use key => value
Returns
Signature
public static null setHeader ( $header )
# setLength()
Tells the browser the length of the following content. This mostly makes sense when using the download function so the browser can calculate how many bytes are left during the process.
View source (opens new window)
Arguments
$sizeInBytes
(integer (opens new window)) – The content size in bytes
Returns
Signature
public static null setLength ( $sizeInBytes )
# setNoCache()
Signature
public static null setNoCache ( )
# setPrivate()
Signature
public static null setPrivate ( )
# setPublic()
Signature
public static null setPublic ( )