Class that contains functionalities related to the HTTP protocol and its most common requests
| package | Default |
|---|
__construct(boolean $asynchronous = false)
booleanSpecify if the HTTP manager instance will work in asynchronous or synchronous mode. (Synchronous mode is NOT recommended on client side languages)
__get(string $name): void
stringThe property name
__set(string $name,string $value): void
stringThe property name
stringThe property value
countQueues(): integer
| see | \org\turbocommons\src\main\php\managers\$this->queue() |
|---|---|
integerThe number of existing queues
createQueue(string $name): void
| see | \org\turbocommons\src\main\php\managers\$this->queue() |
|---|
stringThe name we want to define for this queue
deleteGlobalPostParam(string $parameterName)
stringThe name of the POST parameter that will be deleted
deleteQueue(string $name): void
Make sure the queue is not running when calling this method, or an exception will happen
| see | \org\turbocommons\src\main\php\managers\$this->queue() |
|---|
stringThe name for the queue we want to remove
execute(string|array|\org\turbocommons\src\main\php\managers\httpmanager\HTTPManagerBaseRequest $requests,callable $finishedCallback = null,callable $progressCallback = null): void
string|array|\org\turbocommons\src\main\php\managers\httpmanager\HTTPManagerBaseRequestOne 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.
callableA 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)
callableExecuted 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.
generateUrlQueryString(array|\org\turbocommons\src\main\php\model\HashMapObject $keyValuePairs): string
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.
| see | https://en.wikipedia.org/wiki/Query_string\org\turbocommons\src\main\php\model\HashMapObject |
|---|
array|\org\turbocommons\src\main\php\model\HashMapObjectAn associative array or a HashMapObject containing key/value pairs that will be used to construct the query string. Note that when a value is an object or array, it will be encoded as a JSON string on the resulting query
stringA valid query string that can be used with any url: http://www.url.com?query_string (Note that ? symbol is not included)
getGlobalPostParam(string $parameterName): string
stringThe name of the POST parameter that we want to read
stringThe parameter value
getUrlHeaders(string $url,callable $successCallback,callable $errorCallback): void
Note that crossdomain security rules may prevent this method from working correctly
stringThe url for which we want to get the http headers.
callableExecuted 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.
callableExecuted if headers cannot be read. A string containing the error description and the error code will be passed to this method.
isGlobalPostParam(string $parameterName): boolean
stringThe name of the POST parameter that we want to check
booleanTrue if the parameter exists, false otherwise
isInternetAvailable(callable $yesCallback,callable $noCallback): void
callableExecuted if the internet connection is available and working
callableExecuted if the internet connection is NOT available
isQueueRunning(string $name): boolean
| see | \org\turbocommons\src\main\php\managers\$this->queue() |
|---|
stringThe name for the queue we want to check
booleanTrue if the specified queue is actually running its http requests
loadResourcesFromList( $todo)
queue( $todo)
setGlobalPostParam(string $parameterName,string $value)
stringThe name of the POST parameter that will be always sent to all the http requests
stringThe value that the POST parameter will have
urlExists(string $url,callable $yesCallback,callable $noCallback): void
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.
stringA full valid internet address to check
callableExecuted if the url exists
callableExecuted if the url does not exist (or is not accessible).
baseUrl :
This property is useful when all the requests in our application share the same root url, which can be defined here.
asynchronous :
timeout :
If set to 0, no value will be specifically defined, so the platform default will be used.
isOnlyHttps :
internetCheckLocations :
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.