HttpRequest

com.akifox.asynchttp.HttpRequest (Class)

##HttpRequest

This class represents an Http Request

@author Simone Cingano (yupswing) Akifox Studio

@repo akifox-asynchttp repository

@licence MIT Licence

Instance Members

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


fingerprint: String

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


headers: HttpHeaders

The request headers


timeout: Int

The request timeout in seconds (default:10)

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


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


http11: Bool

Http Protocol Version flag

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


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


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


content: Dynamic

The HTTP Content

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


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)


contentIsBinary: Bool

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

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


toString(): String
Returns
String

clone(): HttpRequest

Deep copy of the HttpRequest

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

Returns
HttpRequest

finalise(): Void

Make this instance immutable

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


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)


callback(): 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


callbackError(): 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


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)

Name Type
`` Int
`` Int

new(?options: Null<HttpRequestOptions> = null): Void

Class instance

Name Type Default Description
options Null<HttpRequestOptions> null HttpRequestOptions object or null (NOTE: every parameter could be changed also after the class instance)

Private Members

DEFAULT_CONTENT_TYPE: String