Wildfire/Channel/HttpHeaders.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Wildfire
- Subpackage
- Channel
- Version
- $Id: HttpHeaders.php 24593 2012-01-05 20:35:02Z matthew $
\Zend_Wildfire_Channel_HttpHeaders
Implements communication via HTTP request and response headers for Wildfire Protocols.
- Implements
- \Zend_Wildfire_Channel_Interface
- Parent(s)
- \Zend_Controller_Plugin_Abstract
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Properties


integer $_controllerPluginStackIndex = 999
The index of the plugin in the controller dispatch loop plugin stack
999
Details- Type
- integer


string $_headerPrefix = 'X-WF-'
The string to be used to prefix the headers.
'X-WF-'
Details- Type
- string


\Zend_Wildfire_Channel_HttpHeaders $_instance = null
Singleton instance
null
Details


array $_protocols = null
The protocol instances for this channel
null
Details- Type
- array


\Zend_Controller_Request_Abstract $_request =
- Type
- \Zend_Controller_Request_Abstract
- Inherited_from
- \Zend_Controller_Plugin_Abstract::$$_request


\Zend_Controller_Response_Abstract $_response =
- Type
- \Zend_Controller_Response_Abstract
- Inherited_from
- \Zend_Controller_Plugin_Abstract::$$_response
Methods


_initProtocol(string $uri) : object
Initialize a new protocol
Name | Type | Description |
---|---|---|
$uri | string | The URI for the protocol to be initialized |
Type | Description |
---|---|
object | Returns the new initialized protocol instance |
Exception | Description |
---|---|
\Zend_Wildfire_Exception |


dispatchLoopShutdown() : void
Flush messages to headers as late as possible but before headers have been sent.


dispatchLoopStartup(\Zend_Controller_Request_Abstract $request) : void
Called before Zend_Controller_Front enters its dispatch loop.
Inherited from: \Zend_Controller_Plugin_Abstract::dispatchLoopStartup()Name | Type | Description |
---|---|---|
$request | \Zend_Controller_Request_Abstract |


flush() : boolean
Flush all data from all protocols and send all data to response headers.
Type | Description |
---|---|
boolean | Returns TRUE if data was flushed |


getInstance(bool $skipCreate = false) : \Zend_Wildfire_Channel_HttpHeaders
Get or create singleton instance
Name | Type | Description |
---|---|---|
$skipCreate | bool | True if an instance should not be created |
Type | Description |
---|---|
\Zend_Wildfire_Channel_HttpHeaders |


getProtocol(string $uri) : object
Get the instance of a give protocol for this channel
Name | Type | Description |
---|---|---|
$uri | string | The URI for the protocol |
Type | Description |
---|---|
object | Returns the protocol instance for the diven URI |


getRequest() : \Zend_Controller_Request_Abstract
Get the request object
Type | Description |
---|---|
\Zend_Controller_Request_Abstract |
Exception | Description |
---|---|
\Zend_Wildfire_Exception |


getResponse() : \Zend_Controller_Response_Abstract
Get the response object
Type | Description |
---|---|
\Zend_Controller_Response_Abstract |
Exception | Description |
---|---|
\Zend_Wildfire_Exception |


init(string $class = null) : \Zend_Wildfire_Channel_HttpHeaders
Initialize singleton instance.
Name | Type | Description |
---|---|---|
$class | string | OPTIONAL Subclass of Zend_Wildfire_Channel_HttpHeaders |
Type | Description |
---|---|
\Zend_Wildfire_Channel_HttpHeaders | Returns the singleton Zend_Wildfire_Channel_HttpHeaders instance |
Exception | Description |
---|---|
\Zend_Wildfire_Exception |


isReady(boolean $forceCheckRequest = false) : boolean
Determine if channel is ready.
The channel is ready as long as the request and response objects are initialized, can send headers and the FirePHP header exists in the User-Agent.
If the header does not exist in the User-Agent, no appropriate client is making this request and the messages should not be sent.
A timing issue arises when messages are logged before the request/response objects are initialized. In this case we do not yet know if the client will be able to accept the messages. If we consequently indicate that the channel is not ready, these messages will be dropped which is in most cases not the intended behaviour. The intent is to send them at the end of the request when the request/response objects will be available for sure.
If the request/response objects are not yet initialized we assume if messages are logged, the client will be able to receive them. As soon as the request/response objects are availoable and a message is logged this assumption is challenged. If the client cannot accept the messages any further messages are dropped and messages sent prior are kept but discarded when the channel is finally flushed at the end of the request.
When the channel is flushed the $forceCheckRequest option is used to force a check of the request/response objects. This is the last verification to ensure messages are only sent when the client can accept them.
Name | Type | Description |
---|---|---|
$forceCheckRequest | boolean | OPTIONAL Set to TRUE if the request must be checked |
Type | Description |
---|---|
boolean | Returns TRUE if channel is ready. |


postDispatch(\Zend_Controller_Request_Abstract $request) : void
Called after an action is dispatched by Zend_Controller_Dispatcher.
Inherited from: \Zend_Controller_Plugin_Abstract::postDispatch()This callback allows for proxy or filter behavior. By altering the request and resetting its dispatched flag (via setDispatched(false)), a new action may be specified for dispatching.
Name | Type | Description |
---|---|---|
$request | \Zend_Controller_Request_Abstract |


preDispatch(\Zend_Controller_Request_Abstract $request) : void
Called before an action is dispatched by Zend_Controller_Dispatcher.
Inherited from: \Zend_Controller_Plugin_Abstract::preDispatch()This callback allows for proxy or filter behavior. By altering the request and resetting its dispatched flag (via setDispatched(false)), the current action may be skipped.
Name | Type | Description |
---|---|---|
$request | \Zend_Controller_Request_Abstract |


routeShutdown(\Zend_Controller_Request_Abstract $request) : void
Called after Zend_Controller_Router exits.
Inherited from: \Zend_Controller_Plugin_Abstract::routeShutdown()Called after Zend_Controller_Front exits from the router.
Name | Type | Description |
---|---|---|
$request | \Zend_Controller_Request_Abstract |


routeStartup(\Zend_Controller_Request_Abstract $request) : void
Called before Zend_Controller_Front begins evaluating the request against its routes.
Inherited from: \Zend_Controller_Plugin_Abstract::routeStartup()Name | Type | Description |
---|---|---|
$request | \Zend_Controller_Request_Abstract |


setControllerPluginStackIndex(integer $index) : integer
Set the index of the plugin in the controller dispatch loop plugin stack
Name | Type | Description |
---|---|---|
$index | integer | The index of the plugin in the stack |
Type | Description |
---|---|
integer | The previous index. |


setRequest(\Zend_Controller_Request_Abstract $request) : \Zend_Controller_Plugin_Abstract
Name | Type | Description |
---|---|---|
$request | \Zend_Controller_Request_Abstract |
Type | Description |
---|---|
\Zend_Controller_Plugin_Abstract |


setResponse(\Zend_Controller_Response_Abstract $response) : \Zend_Controller_Plugin_Abstract
Name | Type | Description |
---|---|---|
$response | \Zend_Controller_Response_Abstract |
Type | Description |
---|---|
\Zend_Controller_Plugin_Abstract |