Module: http

Members

(static) config

Properties:
Name Type Description
config
Properties
Name Type Attributes Default Description
base String The base URL of the API
timeout Number <optional>
30000 Global timeout for the reques. after this value (express in milliseconds) the requests throw an error.
headers Object <optional>
{} Global headers for all requests.
useCache Object <optional>
true Global cache flag.
offlineCache Object <optional>
false Global offline cache.
log Boolean <optional>
false Log the requests.
bodyEncodingInJSON Boolean <optional>
false Force to encoding in JSON of body data is the input is a JS object.
sslPinning Boolean <optional>
false If this value is an array, it must contain the domains on which to apply SSL pinning. If this value is true, SSL pinning is applied on base HTTP domain. Certificates must be located in /app/assets/certs and named as the the domain name without extension. (example: "/app/assets/certs/youtube.com")
Source:

(inner) __uniqueId

Source:

Methods

(static) addFilter(name, func)

Parameters:
Name Type Description
name String The name of the middleware
func function The function
Source:

(static) addHeader(key, value, domainopt)

Add a global header for all requests
Parameters:
Name Type Attributes Default Description
key String The header key
value String The header value
domain String <optional>
null Optional domain
Source:

(static) addToQueue(request)

Add a request to queue
Parameters:
Name Type Description
request HTTP.Request
Source:

(static) download(url, filename, success, error, ondatastream) → {HTTP.Request}

Parameters:
Name Type Description
url String The url
filename Object File name or `Ti.File`
success function Success callback
error function Error callback
ondatastream function Progress callback
Source:
Returns:
Type
HTTP.Request

(static) event()

Attach events to current module
Source:

(static) exportCookiesToSystem(domain)

Export the HTTP cookies to the system to make them available to `WebViews`
Parameters:
Name Type Description
domain String The domain. Default is `HTTP.config.base`
Source:

(static) get(url, success, error) → {HTTP.Request}

Make a GET request to that URL
Parameters:
Name Type Description
url String The endpoint url
success function Success callback
error function Error callback
Source:
Returns:
Type
HTTP.Request

(static) getHeaders() → {Object}

Source:
Returns:
Type
Object

(static) getJSON(url, data, success, error) → {HTTP.Request}

Make a GET request to that url with that data and setting the format forced to JSON
Parameters:
Name Type Description
url String The endpoint url
data Object The data
success function Success callback
error function Error callback
Source:
Returns:
Type
HTTP.Request

(static) getQueue() → {Array}

Get the current requests queue
Source:
Returns:
Type
Array

(static) isQueueEmpty() → {Boolean}

Check if the requests queue is empty
Source:
Returns:
Type
Boolean

(static) post(url, data, success, error) → {HTTP.Request}

Make a POST request to that URL
Parameters:
Name Type Description
url String The endpoint url
data Object The data
success function Success callback
error function Error callback
Source:
Returns:
Type
HTTP.Request

(static) postJSON(url, data, success, error) → {HTTP.Request}

Make a POST request to that url with that data and setting the format forced to JSON
Parameters:
Name Type Description
url String The endpoint url
data Object The data
success function Success callback
error function Error callback
Source:
Returns:
Type
HTTP.Request

(static) removeFilter(name)

Parameters:
Name Type Description
name String The name of the middleware
Source:

(static) removeFromQueue()

Remove a request from queue
Source:

(static) removeHeader(key, domainopt)

Remove a global header
Parameters:
Name Type Attributes Default Description
key String The header key
domain String <optional>
null Optional domain
Source:

(static) resetCookies()

Reset the cookies for all requests
Source:

(static) resetHeaders(domainopt)

Reset all globals headers
Parameters:
Name Type Attributes Default Description
domain String <optional>
null Optional domain
Source:

(inner) send(opt) → {HTTP.Request}

The main function of the module. Create an HTTP.Request and resolve it
Parameters:
Name Type Description
opt Object The request dictionary
Properties
Name Type Attributes Default Description
url String The endpoint URL
method String <optional>
"GET" The HTTP method to use (GET|POST|PUT|PATCH|..)
headers Object <optional>
null An Object key-value of additional headers
timeout Number <optional>
30000 Timeout after stopping the request and triggering an error
cache Boolean <optional>
true Set to false to disable the cache
success function <optional>
The success callback
error function <optional>
The error callback
format String <optional>
Override the format for that request (like `json`)
ttl Number <optional>
Override the TTL seconds for the cache
Source:
Returns:
Type
HTTP.Request