Packagecom.curlyben.net
Classpublic dynamic class HTTPRequest
InheritanceHTTPRequest Inheritance flash.events.EventDispatcher

A HTTP request handler similair to the builtin flash.net.URLRequest.

HTTPRequest differs in that it allows further flexibillity, at the cost of requiring specific server abillities:

Why the need for RedHerring?

Adobe are actively phasing in an updated policy system that could render many flash.net.Socket HTTP handling classes unusable. Policy file changes in Flash Player 9
HTTPRequest was originally designed to utilise flash.net.Socket, but during development news of the changes to socket policies spawned the implementation of RedHerring.

RedHerring allows non-persistant HTTP requests to be proxied by a server and policied in the same manner as URLRequest.

This allows raw data to be delivered without the need for a socket:843 service, re-opening Flash dynamic data to shared and virtual hosting environments currently locked out by flash.net.Socket

For more information about preparing policies, and specifically HTTP policies safe for hosted environments, see: http://www.adobe.com/devnet/flashplayer/articles/fplayer9_security_03.html#Meta-Policy_Options



Public Properties
 PropertyDefined by
  BaseStream : URLStream
[read-only] Provides access to the internal URLStream used to deliver a request.
HTTPRequest
  Buffer : ByteArray
[read-only] Provides a byte level copy of the input buffer containing any downloaded data.
HTTPRequest
  Host : String
The remote host address.
HTTPRequest
  HTTPVersion : String
The HTTP protocol version to use when making requests.
HTTPRequest
  IsSSL : Boolean
[read-only] Specifies whether the request URL uses a secure connection.
HTTPRequest
  Port : uint
The port to connect to on the remote host.
HTTPRequest
  RawHeader : String
[read-only] The HTTP response header as a multiline string.
HTTPRequest
  RedHerringURL : String
[static] The URL to a "RedHerring" proxy.
HTTPRequest
  Request : URLRequest
[read-only] The request object as type URLRequest.
HTTPRequest
  RequestData : Object
Provides read/write access to request data.
HTTPRequest
  RequestMethodOverride : String
The request objects HTTP method attribute, which may be overridden to bypass URLRequest method limitations.
HTTPRequest
  Resource : String
The address of the requested resource less any domain/subdomain and protocol preamble.
HTTPRequest
  ResponseCode : String
[read-only] The HTTP response word, for example "200" when a response header begins "HTTP/1.1 200 OK"
HTTPRequest
  ResponseData : ByteArray
[read-only] The response data as a ByteArray.
HTTPRequest
  ResponseDescription : String
[read-only] The HTTP response description, for example "OK" when a response header begins "HTTP/1.1 200 OK"
HTTPRequest
  ResponseHeaders : Array
[read-only] An array of type Array<HTTPHeader> containing all recieved response headers.
HTTPRequest
  ResponseWord : String
[read-only] The HTTP response word, for example "HTTP/1.1" when a response header begins "HTTP/1.1 200 OK"
HTTPRequest
Public Methods
 MethodDefined by
  
HTTPRequest(redherring:String = null)
Creates an instance of HTTPRequest, optionally specifying a URL for a RedHerring proxy.
HTTPRequest
  
Close():void
Closes any unfinished streams and dispatchs the Event.CLOSE event.
HTTPRequest
  
GetHeader(name:String):HTTPHeader
Returns a named header if it is available, or a valueless header when no such header exists.
HTTPRequest
  
Load(urlrequest:URLRequest, requestdata:Object = null, forcemethod:String = null):void
Load a URL request optionally providing request data and HTTP method override.
HTTPRequest
Events
 EventSummaryDefined by
   This event is triggered when the remote host accepts a connection.HTTPRequest
   This event is triggered when the request has completed loading all data.HTTPRequest
   This event is triggered multiple times after the header is complete, and before the data is complete.HTTPRequest
   This event is triggered when the header portion of a request has completed loading.HTTPRequest
   This event is triggered when a URL is incorrectly constructed.HTTPRequest
   This event is triggered when a connection is disconnected prematurely.HTTPRequest
Public Constants
 ConstantDefined by
  ER_MALFORMEDURL : String = "MalformedUrlError"
[static] Defines the value of the type property of an MalformedUrlError event object.
HTTPRequest
  EV_CONNECTED : String = "connected"
[static] Defines the value of the type property of an connected event object.
HTTPRequest
  EV_DATACOMPLETE : String = "dataComplete"
[static] Defines the value of the type property of an dataComplete event object.
HTTPRequest
  EV_DATAPROGRESS : String = "dataProgress"
[static] Defines the value of the type property of an dataProgress event object.
HTTPRequest
  EV_HEADERCOMPLETE : String = "headerComplete"
[static] Defines the value of the type property of an headerComplete event object.
HTTPRequest
  EV_PREMATUREDISCONNECT : String = "prematureDisconnect"
[static] Defines the value of the type property of an prematureDisconnect event object.
HTTPRequest
  HTTP_VER_1_0 : String = "1.0"
[static] A string constant used to set "1.0" as the HTTPVersion.
HTTPRequest
  HTTP_VER_1_1 : String = "1.1"
[static] A string constant used to set "1.1" as the HTTPVersion.
HTTPRequest
Property detail
BaseStreamproperty
BaseStream:URLStream  [read-only]

Provides access to the internal URLStream used to deliver a request.

Implementation
    public function get BaseStream():URLStream
Bufferproperty 
Buffer:ByteArray  [read-only]

Provides a byte level copy of the input buffer containing any downloaded data.
Note:
Until the header is complete, data in the Buffer may not accurately represent any part of the data upon completion.
Buffer is made available to assist network debugging, and it is advised developers use ResponseData to access raw response data.

Implementation
    public function get Buffer():ByteArray

See also

Hostproperty 
Host:String  [read-write]

The remote host address.

Implementation
    public function get Host():String
    public function set Host(value:String):void
HTTPVersionproperty 
HTTPVersion:String  [read-write]

The HTTP protocol version to use when making requests.

Implementation
    public function get HTTPVersion():String
    public function set HTTPVersion(value:String):void

See also

IsSSLproperty 
IsSSL:Boolean  [read-only]

Specifies whether the request URL uses a secure connection.
Secure connections are not currently implemented.

Implementation
    public function get IsSSL():Boolean
Portproperty 
Port:uint  [read-write]

The port to connect to on the remote host.

Implementation
    public function get Port():uint
    public function set Port(value:uint):void
RawHeaderproperty 
RawHeader:String  [read-only]

The HTTP response header as a multiline string.

Implementation
    public function get RawHeader():String
RedHerringURLproperty 
RedHerringURL:String  [read-write]

The URL to a "RedHerring" proxy. A default URL will be formed from the application host URL and "redherring.php" if no value is specified.

At the time of writing there are version available for:


Get the source from http://code.google.com/p/redherring/

Implementation
    public static function get RedHerringURL():String
    public function set RedHerringURL(value:String):void
Requestproperty 
Request:URLRequest  [read-only]

The request object as type URLRequest.

Implementation
    public function get Request():URLRequest
RequestDataproperty 
RequestData:Object  [read-write]

Provides read/write access to request data.
Also referred to as POST data.

Implementation
    public function get RequestData():Object
    public function set RequestData(value:Object):void
RequestMethodOverrideproperty 
RequestMethodOverride:String  [read-write]

The request objects HTTP method attribute, which may be overridden to bypass URLRequest method limitations.

Implementation
    public function get RequestMethodOverride():String
    public function set RequestMethodOverride(value:String):void
Resourceproperty 
Resource:String  [read-write]

The address of the requested resource less any domain/subdomain and protocol preamble.

Implementation
    public function get Resource():String
    public function set Resource(value:String):void
ResponseCodeproperty 
ResponseCode:String  [read-only]

The HTTP response word, for example "200" when a response header begins "HTTP/1.1 200 OK"

Implementation
    public function get ResponseCode():String
ResponseDataproperty 
ResponseData:ByteArray  [read-only]

The response data as a ByteArray.
ResponseData will return a ByteArray of zero length if the header has not yet completed.

Implementation
    public function get ResponseData():ByteArray
ResponseDescriptionproperty 
ResponseDescription:String  [read-only]

The HTTP response description, for example "OK" when a response header begins "HTTP/1.1 200 OK"

Implementation
    public function get ResponseDescription():String
ResponseHeadersproperty 
ResponseHeaders:Array  [read-only]

An array of type Array<HTTPHeader> containing all recieved response headers.

Implementation
    public function get ResponseHeaders():Array

See also

ResponseWordproperty 
ResponseWord:String  [read-only]

The HTTP response word, for example "HTTP/1.1" when a response header begins "HTTP/1.1 200 OK"

Implementation
    public function get ResponseWord():String
Constructor detail
HTTPRequest()constructor
public function HTTPRequest(redherring:String = null)

Creates an instance of HTTPRequest, optionally specifying a URL for a RedHerring proxy.

Parameters
redherring:String (default = null) — Specifies a URL for a RedHerring proxy.
The URL provided will be copied into the static RedHerringURL, and therefore affect any future and present instances of HTTPRequest, and in course classes that implement HTTPRequest.
If no URL is provided at any time, a default value "redherring.php" is used.
Method detail
Close()method
public function Close():void

Closes any unfinished streams and dispatchs the Event.CLOSE event.

GetHeader()method 
public function GetHeader(name:String):HTTPHeader

Returns a named header if it is available, or a valueless header when no such header exists.

Parameters
name:String — The name of the HTTP response header to return.

Returns
HTTPHeader — A HTTPHeader object specific to the passed name parameter.
Load()method 
public function Load(urlrequest:URLRequest, requestdata:Object = null, forcemethod:String = null):void

Load a URL request optionally providing request data and HTTP method override.

Parameters
urlrequest:URLRequest — The URLRequest object.
 
requestdata:Object (default = null) — The URL request data, this is often the POST data.
 
forcemethod:String (default = null) — The HTTP method to force, when URLRequest doesn't allow the required method.
Event detail
connectedevent 
Event object type: com.curlyben.events.HTTPEvent

This event is triggered when the remote host accepts a connection.

dataCompleteevent  
Event object type: com.curlyben.events.HTTPEvent

This event is triggered when the request has completed loading all data.

dataProgressevent  
Event object type: com.curlyben.events.HTTPEvent

This event is triggered multiple times after the header is complete, and before the data is complete.

headerCompleteevent  
Event object type: com.curlyben.events.HTTPEvent

This event is triggered when the header portion of a request has completed loading.

MalformedUrlErrorevent  
Event object type: com.curlyben.events.HTTPEvent

This event is triggered when a URL is incorrectly constructed.

prematureDisconnectevent  
Event object type: com.curlyben.events.HTTPEvent

This event is triggered when a connection is disconnected prematurely.

Constant detail
ER_MALFORMEDURLconstant
public static const ER_MALFORMEDURL:String = "MalformedUrlError"

Defines the value of the type property of an MalformedUrlError event object.

EV_CONNECTEDconstant 
public static const EV_CONNECTED:String = "connected"

Defines the value of the type property of an connected event object.

EV_DATACOMPLETEconstant 
public static const EV_DATACOMPLETE:String = "dataComplete"

Defines the value of the type property of an dataComplete event object.

EV_DATAPROGRESSconstant 
public static const EV_DATAPROGRESS:String = "dataProgress"

Defines the value of the type property of an dataProgress event object.

EV_HEADERCOMPLETEconstant 
public static const EV_HEADERCOMPLETE:String = "headerComplete"

Defines the value of the type property of an headerComplete event object.

EV_PREMATUREDISCONNECTconstant 
public static const EV_PREMATUREDISCONNECT:String = "prematureDisconnect"

Defines the value of the type property of an prematureDisconnect event object.

HTTP_VER_1_0constant 
public static const HTTP_VER_1_0:String = "1.0"

A string constant used to set "1.0" as the HTTPVersion.

See also

HTTP_VER_1_1constant 
public static const HTTP_VER_1_1:String = "1.1"

A string constant used to set "1.1" as the HTTPVersion.

See also