  *  A helper class that is used by the streaming channels to open an internal
  *  HTTP connection to the server that is held open to allow the server to
  *  stream data down to the client with no poll overhead.
- */  
+ */
 class StreamingHTTPConnectionHandler extends StreamingConnectionHandler
-{    
+{
     //--------------------------------------------------------------------------
     //
     // Constructor
-    // 
-    //--------------------------------------------------------------------------
-    
+    //
+    //--------------------------------------------------------------------------
+
     /**
      *  Creates an new StreamingHTTPConnectionHandler instance.
      *
-	 *  @param channel The Channel that uses this class.
-	 *  @param log Reference to the logger for the associated Channel.
+     *  @param channel The Channel that uses this class.
+     *  @param log Reference to the logger for the associated Channel.
      */
     public function StreamingHTTPConnectionHandler(channel:Channel, log:ILogger)
     {
-		super(channel, log);
-    }    
-        
+        super(channel, log);
+    }
+
     //--------------------------------------------------------------------------
     //
     // Protected Methods
-    // 
-    //--------------------------------------------------------------------------
-        
-	/**
-	 *  Used by the streamProgressHandler to read an AMFX encoded message. 
-	 */
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  Used by the streamProgressHandler to read an AMFX encoded message.
+     */
     override protected function readMessage():IMessage
     {
-    	var message:IMessage;
-		chunkBuffer.position = dataOffset - 1; 
-		var messageBytes:ByteArray = new ByteArray();
-		messageBytes.objectEncoding = ObjectEncoding.AMF3;
-		try
-    	{		
-			chunkBuffer.readBytes(messageBytes, 0, dataBytesToRead);							
-			var messageString:String = messageBytes.readUTFBytes(dataBytesToRead);
-			var messageObject:Object = AMFXDecoder.decodeValue(XML(messageString), new AMFXContext());
-			message = IMessage(messageObject);		
-    	}
-    	catch(error:Error)
-    	{
-			if (Log.isError())
-	        	_log.error("'{0}' channel encountered an error while reading a message from the streaming connection: {1}", channel.id, error.message);
-    	}
-		return message;                 	    	
-    }    
+        var message:IMessage;
+        chunkBuffer.position = dataOffset - 1;
+        var messageBytes:ByteArray = new ByteArray();
+        messageBytes.objectEncoding = ObjectEncoding.AMF3;
+        try
+        {
+            chunkBuffer.readBytes(messageBytes, 0, dataBytesToRead);
+            var messageString:String = messageBytes.readUTFBytes(dataBytesToRead);
+            var messageObject:Object = AMFXDecoder.decodeValue(XML(messageString), new AMFXContext());
+            message = IMessage(messageObject);
+        }
+        catch(error:Error)
+        {
+            if (Log.isError())
+                _log.error("'{0}' channel encountered an error while reading a message from the streaming connection: {1}", channel.id, error.message);
+        }
+        return message;
+    }
 }


        // Disable polling.
        internalPollingEnabled = false;
    }    
 
    //--------------------------------------------------------------------------
    //
    // Variables
    // 
    //--------------------------------------------------------------------------
  
  	/**
  	 * Helper class used by the channel to establish a streaming HTTP connection
  	 * with the server.
  	 */
	private var streamingConnectionHandler:StreamingConnectionHandler;
	    
    /**
     *  @private
     */
    private var resourceManager:IResourceManager =
									ResourceManager.getInstance();
									       
    //--------------------------------------------------------------------------
    //
    // Properties
    // 
    //--------------------------------------------------------------------------

	//----------------------------------
	//  pollingEnabled
	//----------------------------------

    /**
     *  @private
     */
    override public function set pollingEnabled(value:Boolean):void
    {
		var message:String = resourceManager.getString(
			"messaging", "pollingNotSupportedHTTP");    	
        throw new Error(message);
    }
    
    //----------------------------------
	//  pollingInterval
	//----------------------------------
    
    /**
     *  @private
     */
    override public function set pollingInterval(value:Number):void
    {
		var message:String = resourceManager.getString(
			"messaging", "pollingNotSupportedHTTP");    	
        throw new Error(message);
    }
    
    //--------------------------------------------------------------------------
    //
    // Overridden Public Methods
    // 
    //--------------------------------------------------------------------------
	        
    /**
     *  Polling is not supported by this channel.
     */    
    override public function poll():void
    {
		var message:String = resourceManager.getString(
			"messaging", "pollingNotSupportedHTTP");    	
        throw new Error(message);	    	
    }    
    
    //--------------------------------------------------------------------------
    //
    // Overriden Protected Methods
    // 
    //--------------------------------------------------------------------------

    /**
     *  @private
     *  Closes the streaming connection before redispatching the fault event. 
     * 
     *  @param event The ChannelFaultEvent.
     */
	override protected function connectFailed(event:ChannelFaultEvent):void
	{
		if (streamingConnectionHandler != null)
			streamingConnectionHandler.closeStreamingConnection();

        super.connectFailed(event);			 	    
	}
	
    /**
     *  @private
     *  Closes the streaming connection before disconnecting.
     */
    override protected function internalDisconnect(rejected:Boolean = false):void
    {
		if (streamingConnectionHandler != null)
			streamingConnectionHandler.closeStreamingConnection();
						
		super.internalDisconnect(rejected);
    }
    
    /**
     *  @private
     *  This method will be called if the ping message sent to test connectivity

            internalDisconnect();
        }
    }

    /**
     *  Handles HTTP status events dispatched by the streaming connection.
     *
     *  @param event The HTTPStatusEvent.
     */
    private function streamHttpStatusHandler(event:HTTPStatusEvent):void
    {
        // No-op because most of the times, HTTP status is zero.
        // See ioErrorHandler.
    }

    /**
     *  Handles IO error events dispatched by the streaming connection.
     *
     *  @param event The IOErrorEvent.
     */
    private function streamIoErrorHandler(event:IOErrorEvent):void
