public function clickAuth ($sender, $param)
{
$response=$this->getResponse();
$response->setStatusCode(401);
$response->appendHeader('WWW-Authenticate: Basic realm="Test"');
}
This event handler will sent the 401 status code (Unauthorized) to the browser, with the WWW-Authenticate header field. This
will force the browser to ask for a username and a password.
显示文件
Open project: pradosoft/prado
Class Usage Examples
Method | Description | |
---|---|---|
__destruct ( ) | Destructor. | |
addCookie ( $cookie ) | Sends a cookie. | |
appendHeader ( $value, $replace = true ) | Sends a header. | |
appendLog ( $message, $messageType, $destination = '', $extraHeaders = '' ) | Writes a log message into error log. | |
clear ( ) | Clears any existing buffered content. | |
createHtmlWriter ( $type = null ) | Creates a new instance of HTML writer. | |
createNewHtmlWriter ( $type, $writer ) | Create a new html writer instance. | |
ensureHeadersSent ( ) | Ensures that HTTP response and content-type headers are sent | |
flush ( $continueBuffering = true ) | Flush the response contents and headers. | |
flushContent ( $continueBuffering = true ) | Outputs the buffered content, sends content-type and charset header. | |
getAdapter ( ) : |
||
getBufferOutput ( ) : boolean | ||
getCacheControl ( ) : string | ||
getCacheExpire ( ) : integer | ||
getCharset ( ) : string | boolean | ||
getContentType ( ) : string | ||
getContents ( ) : string | Returns the content in the output buffer. | |
getCookies ( ) : |
||
getHasAdapter ( ) : boolean | ||
getHeaders ( $case = null ) : array | ||
getHtmlWriterType ( ) : string | ||
getStatusCode ( ) : integer | ||
getStatusReason ( ) | ||
httpRedirect ( $url ) | Redirect the browser to another URL and exists the current application. | |
init ( $config ) | Initializes the module. | |
redirect ( $url ) | Redirects the browser to the specified URL. | |
reload ( ) | Reloads the current page. | |
removeCookie ( $cookie ) | Deletes a cookie. | |
setAdapter ( |
||
setBufferOutput ( $value ) | ||
setCacheControl ( $value ) | ||
setCacheExpire ( $value ) | ||
setCharset ( $charset ) | ||
setContentType ( $type ) : string | ||
setHtmlWriterType ( $value ) | ||
setStatusCode ( $status, $reason = null ) | Set the HTTP status code for the response. | |
write ( $str ) | Outputs a string. | |
writeFile ( $fileName, $content = null, $mimeType = null, $headers = null, $forceDownload = true, $clientFileName = null, $fileSize = null ) | Sends a file back to user. |
Method | Description | |
---|---|---|
ensureContentTypeHeaderSent ( ) | Ensures that the HTTP header with the status code and status reason are sent | |
ensureHttpHeaderSent ( ) | Ensures that the HTTP header with the status code and status reason are sent | |
sendContentTypeHeader ( ) | Sends content type header with optional charset. | |
sendHttpHeader ( ) | Send the HTTP header with the status code (defaults to 200) and status reason (defaults to OK) |
public addCookie ( $cookie ) |
public appendLog ( $message, $messageType, $destination = '', $extraHeaders = '' ) |
public createHtmlWriter ( $type = null ) |
public createNewHtmlWriter ( $type, $writer ) |
protected ensureContentTypeHeaderSent ( ) |
public ensureHeadersSent ( ) |
protected ensureHttpHeaderSent ( ) |
public flush ( $continueBuffering = true ) |
public flushContent ( $continueBuffering = true ) |
public getAdapter ( ) : |
||
return | response adapter, null if not exist. |
public getBufferOutput ( ) : boolean | ||
return | boolean | whether to enable output buffer |
public getCacheControl ( ) : string | ||
return | string | cache control method to use for session pages |
public getCacheExpire ( ) : integer | ||
return | integer | time-to-live for cached session pages in minutes, this has no effect for nocache limiter. Defaults to 180. |
public getCharset ( ) : string | boolean | ||
return | string | boolean | output charset. |
public getContentType ( ) : string | ||
return | string | current content type |
public getContents ( ) : string | ||
return | string | output that is in the buffer. |
public getCookies ( ) : |
||
return | list of output cookies |
public getHasAdapter ( ) : boolean | ||
return | boolean | true if adapter exists, false otherwise. |
public getHtmlWriterType ( ) : string | ||
return | string | the type of HTML writer to be used, defaults to THtmlWriter |
public getStatusCode ( ) : integer | ||
return | integer | HTTP status code, defaults to 200 |
public httpRedirect ( $url ) |
public init ( $config ) |
public redirect ( $url ) |
public reload ( ) |
public removeCookie ( $cookie ) |
protected sendContentTypeHeader ( ) |
protected sendHttpHeader ( ) |
public setAdapter ( |
||
$adapter |
public setContentType ( $type ) : string | ||
return | string | content type, default is text/html |
public setStatusCode ( $status, $reason = null ) |
public write ( $str ) |
public writeFile ( $fileName, $content = null, $mimeType = null, $headers = null, $forceDownload = true, $clientFileName = null, $fileSize = null ) |