Press on the image to return to the main documentation page.
HTTP
The HTTP library allows you to communicate with web services and to download resources from the web. As network communication can be slow and fragile this library handles the requests and responses in the background and raises events when a task is ready.
HttpClient allows you to make Http requests. Instead of using HttpClient directly it is recommended to use HttpUtil2 modules which are much simpler to use.
Permissions:
android.permission.INTERNET
Events:
ResponseSuccess (Response As HttpResponse, TaskId As Int) ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
Executes the HttpRequest asynchronously. ResponseSuccess or ResponseError events will be fired later. Note that in many cases the Response object passed in ResponseError event will be Null. If there is a request with the same TaskId already running then this method will return False and the new request will not be submitted.
Same behavior as Execute. The UserName and Password will be used for Basic or Digest authentication. Digest authentication is supported for GET requests and repeatable POST requests (requests with payloads based on an array of bytes).
Initialize (EventNameAsString)
Initializes this object. IMPORTANT: this object should be declared in Sub Process_Globals. EventName - The prefix that will be used for ResponseSuccess and ResponseError events.
InitializeAcceptAll (EventNameAsString)
Similar to Initialize, with one important difference. All SSL certificates will be automatically accepted. This method should only be used when trying to connect to a server located in a secured network.
IsInitializedAsBoolean
SetHttpParameter (NameAsString, ValueAsObject)
Sets the value of the parameter with the given name.
Initializes the request and sets it to be a Http Post method. The specified InputStream will be read and added to the request.
InitializePost2 (URLAsString, Data() AsByte)
Initializes the request and sets it to be a Http Post method. The specified Data array will be added to the request. Unlike InitializePost this method will enable the request to retry and send the data several times in case of IO errors.
An object that holds the response returned from the server. The object is passed in the ResponseSuccess event. You can choose to read the response synchronously or asynchronously. It is important to release this object when it is not used anymore by calling Release.
Asynchronously reads the response and writes it to the given OutputStream. If there is a request with the same TaskId already running then this method will return False, and the response object will be released. The StreamFinish event will be raised after the response has been fully read. EventName - The sub that will handle the StreamFinish event. Output - The stream from the server will be written to this stream. CloseOutput - Whether to close the specified output stream when done. TaskId - The task id given to this task. Example: SubHttp_ResponseSuccess (ResponseAsHttpResponse, TaskIdAsInt) Response.GetAsynchronously("ImageResponse", _ File.OpenOutput(File.DirInternalCache, "image.jpg", False), True, TaskId) EndSub
Returns a Map object with the response headers. Each elements is made of a key which is the header name and a value which is a list containing the values (one or more). Example: Dimlist1AsList list1 = response.GetHeaders.Get("Set-Cookie") Fori = 0Tolist1.Size - 1 Log(list1.Get(i)) Next
GetInputStreamAsInputStreamWrapper
This method is deprecated and will not work properly on Android 4+ device. Use GetAsynchronously instead.
GetString (DefaultCharsetAsString) AsString
This method is deprecated and will not work properly on Android 4+ device. Use GetAsynchronously instead.