Http extension
The Http extension allows to send any kind of Http request.
It adds the following functions to WarpScript:
The HTTP
function sends an HTTP request, waits for the response then returns it.
Its input is a MAP or arguments, and its output is a MAP of response items.
The input MAP can have these fields:
url
(mandatory)method
headers
body
chunk.size
chunk.macro
username
password
The response MAP can have these fields:
status.code
status.message
headers
content
chunk.number
(if streaming)
The response is streamed if a positive chunk.size
is provided.
More explanation can be found on the documention page of the function.
Installation
In a configuration file, usually etc/conf.d/70--extensions.conf
, set:
warpscript.extension.http = io.warp10.script.ext.http.HttpWarpScriptExtension
Configuration
Your custom configurations can be stored in a new etc/conf.d/99-myWarp10.conf
file. Your custom configurations will override all the predefined Warp 10 configurations.
// If set to true, HTTP requires the stack to be authenticated
#warpscript.http.authentication.required =
// If set, the capability <warpscript.http.capability> is checked to grant access to HTTP function
#warpscript.http.capability =
// Maximum number of HTTP calls, 1 by default, can be raised with capability http.requests
#warpscript.http.maxrequests =
// Maximum downloaded bytes by HTTP, 65536 by default, can be raised with capability http.size
#warpscript.http.maxsize =
// Maximum chunk size allowed when dowloading per chunk using HTTP, 65536 by default, can be raised with capability http.chunksize
#warpscript.http.maxchunksize =
// List of patterns to include/exclude for hosts, works the same way as webcall.host.patterns. Defaults to the value of webcall.host.patterns.
#warpscript.http.host.patterns =
Capabilities
This extension makes use of the following token's capabilities.
Capability | Description |
---|---|
http.requests | Raise the limit configured by warpscript.http.maxrequests |
http.size | Raise the limit configured by warpscript.http.maxsize |
http.chunksize | Raise the limit configured by warpscript.http.maxchunksize |
$ | If set, this capability is required to call HTTP |
Example
This basic example will send a GET request.