HttpBase

haxe.http.HttpBase (Class) → sys.Http

This class can be used to handle Http requests consistently across platforms. There are two intended usages:

  • call haxe.Http.requestUrl(url) and receive the result as a String (only available on sys targets)
  • create a new haxe.Http(url), register your callbacks for onData, onError and onStatus, then call request().

Instance Members

url: String

The url of this request. It is used only by the request() method and can be changed in order to send the same request to different target Urls.


responseBytes: Null<haxe.io.Bytes>

onData(data: String): Void

This method is called upon a successful request, with data containing the result String.

The intended usage is to bind it to a custom function: httpInstance.onData = function(data) { // handle result }

Name Type
data String

onError(msg: String): Void

This method is called upon a request error, with msg containing the error description.

The intended usage is to bind it to a custom function: httpInstance.onError = function(msg) { // handle error }

Name Type
msg String

onStatus(status: Int): Void

This method is called upon a Http status change, with status being the new status.

The intended usage is to bind it to a custom function: httpInstance.onStatus = function(status) { // handle status }

Name Type
status Int

new(url: String): Void

Creates a new Http instance with url as parameter.

This does not do a request until request() is called.

If url is null, the field url must be set to a value before making the call to request(), or the result is unspecified.

(Php) Https (SSL) connections are allowed only if the OpenSSL extension is enabled.

Name Type
url String

Private Members

responseAsString: Null<String>

postData: Null<String>

postBytes: Null<haxe.io.Bytes>



emptyOnData(): Void