class com.akifox.asynchttp.HttpRequest

Available on all platforms

HttpRequest

This class represents an Http Request

@author Simone Cingano (yupswing) Akifox Studio

@repo akifox-asynchttp repository

@licence MIT Licence

Instance Fields

var async:Bool

Asynchronous (default is true)

NOTE: When async==true the application execution will be hold until the request is completed

NOTE: Always true in FLASH due to platform limitations

var content:Dynamic

The HTTP Content

NOTE: You could provide a Bytes or a String according to the Content-type (Binary or Text)

var contentIsBinary:Bool

Content binary flag (tells if the content binary or text)

NOTE: This is set automatically when a content-type is set

var contentType:String

The HTTP Content-Type (default: application/x-www-form-urlencoded)

Content-Type list: (http://www.iana.org/assignments/media-types/media-types.xhtml)

var finalised:Bool

Tell if the instance is immutable

NOTE: The only way to change an immutable instance is copying it (instance.clone()) and change the copy

var fingerprint:String

The fingerprint is a unique 8 char key which identify this request instance

var headers:HttpHeaders

The request headers

var http11:Bool

Http Protocol Version flag

Tells if enable HTTP/1.1 (true ) or HTTP/1.0 (false)

var method:String

The HTTP Method

Accepted values are HttpMethod.GET, .POST, .PUT, .DELETE

NOTE: On JAVASCRIPT only GET and POST are functional due to platform limitations

var timeout:Int

The request timeout in seconds (default:10)

If the request receive no answer for more than the timeout it aborts

var url:URL

The URL to be retrived

Accept a string (format: protocol://host:port/resource?querystring) or a URL instance

NOTE: It supports HTTP+HTTPS protocol (HTTPS on CPP+NEKO platform only with the HXSSL library)

NOTE: On FLASH and JAVASCRIPT relative URLs are allowed

function new(?options:HttpRequestOptions = null):Void

Class instance

options

HttpRequestOptions object or null (NOTE: every parameter could be changed also after the class instance)

function callback(:HttpResponse):Void

The callback function to be called when the response returns

NOTE: This will be called always if no callbackError is set

Otherwise it will be called only if the response is valid

function callbackError(:HttpResponse):Void

The callback error (optional) function to be called when the response returns an error

NOTE: This will be called only if set and in error case

function callbackProgress(:Int, :Int):Void

The callbackProgress (optional) function to be called when get any data on an HTTP Transfer It gets called for sure at the beginning and end of any transfer and (if the HTTP transfer mode supports it) also in between the transfer.

The function has to accept two parameters:

  • loaded:Int the received bytes

  • total:Int the total bytes (-1 if unknown)

function clone():HttpRequest

Deep copy of the HttpRequest

NOTE: The copy will be always mutable despite of the master status

returns

A new HttpRequest

function finalise():Void

Make this instance immutable

NOTE: This method is called automatically once this HttpRequest instance is sent

function send():Void

Send the request and call the callback when it is done

NOTE: When async==true the application execution will be hold until the request is completed

NOTE: When a HttpRequest is sent the instance is made immutable (you have to clone it to send again the same request)

function toString():String

returns

Debug representation of the HttpRequest instance