Class that contains functionalities related to the HTTP protocol and its most common requests
Specify if the HTTP manager instance will work in asynchronous or synchronous mode. (Synchronous mode is NOT recommended)
Structure containing all the created request queues and their status
Defines if the http comunications made by this class will be synchronous (code execution will be stopped while waiting for the response) or asynchronous (execution flow will continue and response will be processed once received) Note: Synchronous requests are normally NOT, NOT a good idea
Defines a list with internet urls that will be used to test network availability by the isInternetAvailable() method. We mainly use globally available CDN urls, cause these are not blocked by cross-orining policies on the browsers and are widely available and replicated. It may be interesting to add your own server side url at the bengining of this list, so it will be the first one to be tested, and you will also check that your server is correctly responding. Note that when an url request is successful, process ends and internet connection is considered to be working.
Defines how much miliseconds will the http requests wait before failing with a timeout. If set to 0, no value will be specifically defined, so the platform default will be used.
Error message that is used when a timeout happens
Auxiliary method to generate a valid list of HTTPManagerBaseRequest instances from multiple sources
Auxiliary method that is used to begin executing the http requests that are pending on the specified queue. A recursive operation will be used to launch the next http request once the previous has totally finished.
The name for the queue we want to start
void
Get the number of created queues. Some may be running and some may be not
The number of existing queues
Create a new http queue. Requests can then be added to this queue with the queue() method.
The name we want to define for this queue
void
Remove the specified queue from this manager. Make sure the queue is not running when calling this method, or an exception will happen
The name for the queue we want to remove
void
Launch one or more http requests without caring about their execution order.
One or more requests to be inmediately launched (at the same time if possible). Each request can be defined as a string that will be used as a GET request url, or as an HTTPManagerBaseRequest instance in case we want to define parameters and callbacks.
A method to be executed once all the http requests have finished (either succesfully or with errors). The callback will receive two parameters: results (an array with information about each request result in the same order as provided to this method) and anyError (true if any of the requests has failed)
Executed after each one of the urls finishes (either successfully or with an error). A string with the requested url and the total requests to perform will be passed to this method.
void
This method generates a GET url query from a set of key/value pairs
A query string is the part of an url that contains the GET parameters. It is placed after the ? symbol and contains a list of parameters and values that are sent to the url.
An object or a HashMapObject containing key/value pairs that will be used to construct the query string
A valid query string that can be used with any url: http://www.url.com?query_string (Note that ? symbol is not included)
Get the Http headers for a given url. Note that crossdomain security rules may prevent this method from working correctly
The url for which we want to get the http headers.
Executed when headers are read. An array of strings will be passed to this method containing all the read headers with each header line as an array element.
Executed if headers cannot be read. A string containing the error description and the error code will be passed to this method.
void
Tells if there's currently a working internet connection available or not.
Executed if the internet connection is available and working
Executed if the internet connection is NOT available
void
Check if the specified queue is currently executing http requests
The name for the queue we want to check
boolean True if the specified queue is actually running its http requests
Given a url that contains a list of resources (files), this method will perform a request for each one of them and store the whole file contents inside an array. After all the process completes, the array containing all the loaded data will be available.
This method implements a technique that allows us to read a big list of files from an http server without needing to write much code. We simply put the files on the server, create a list with all the file names, and call this method. When the process succeeds, we will have all the files data loaded and ready to be used. We have also a progress callback that will notify us when each one of the files is correctly loaded.
A url that contains the list of resources that will be loaded. It normally contains a list of file names
A url that will be used as the root for all the files of the list when the load is performed. This usually is the path to the folder that contains the files
Executed once all the resources have been loaded. Two parameters will be passed to this method: An array with The list of resources as they are defined on the urlToResourcesList, and an array containing all the data for each one of the loaded resources.
Executed if a failure happens on any of the requests. The url that caused the error, the error description and the error code will be passed to this method.
Executed after each one of the resources is correctly loaded. A string with the correctly requested url will be passed to this method.
void
Sequentially launch one or more http requests to the specified queue, one after the other. Each request will start inmediately after the previous one is finished (either succesfully or with an error). We can have several independent queues that run their requests at the same time.
One or more requests that must be added to the specified queue. Each request can be defined as a string that will be used as a GET request url, or as an HTTPManagerBaseRequest instance in case we want to define parameters and callbacks. Requests will be sequentially executed one after the other in the same order. If the specified queue contains requests that have not finished yet, they will be executed before the ones provided here.
The name for an existing queue (created with this.createQueue()) where the specified requests will be added
void
Test if the specified url exists by trying to connect to it. Note that crossdomain security rules may prevent this method from working correctly if you try to check the existence of an url that does not allow CORS outside your application domain.
An full valid internet address to check
Executed if the url exists
Executed if the url does not exist (or is not accessible).
void
Generated using TypeDoc
Class that contains functionalities related to the HTTP protocol and its most common requests