http()
This function executes HTTP requests with HTTP methods like GET, POST, DELETE or PUT and returns the HTTP status. Request headers can be set.
The response data and headers can be stored in a map and a file.
Parameters
Parameter |
Description |
a |
URL without query. |
b |
(optional) true for execution via DMZ. Default: false |
c |
Query. |
d |
Body data (not for GET, HEAD, DELETE). Note: See also section Multipart Requests. |
e |
(optional) Encoding. Default: System encoding. |
f |
MIME type for PUT/POST/PATCH. Note: See also section Multipart Requests. Note: If you use POST, the MIME type and the charset (see parameter e) are specified in the Content Type header by default. If you only want to have the MIME type, you can use the suffix ;raw, e.g. text/plain;raw Note: Does not work formultipart/form-data. See also section Multipart Requests. |
g |
The HTTP method to be used. Use the three dots to select a value. |
h |
(optional) HTTP channel ID (if authentication is needed) or empty. The user is taken from field " Own ID" and the password from field " Own password" . |
i |
(optional) Certificate ID (if necessary) or empty. |
j |
(optional) Timeout in seconds. Default: 90 |
k |
(optional) Number of retries. Default: 0. Note: This setting only applies if no status code is returned. If a status code 4xx or 5xx is returned, no retry is triggered. In this case, a manual error handling must be implemented. |
l |
(optional) Name of a map, into which the response headers and response data are to be saved → See section "HTTP Response Headers and Data" below for details. It is also possible to add request headers → See section "HTTP Request Headers" below for details. |
m |
(optional) true clears map l before it is filled. Default: false |
n |
(optional) Path and name of a file, into which to save the response data → See section HTTP Response Headers and Data for details. |
o |
(optional) If true, the values will be written into the map in Base64 encoding. If false, the encoding in parameter e is used. Default: false |
p |
(optional, only relevant for multipart) The Multipart Mode, see section "Multipart Requests". Allowed values: STRICT, RFC6532, COMPATIBLE, SYSTEM. Default: SYSTEM Headers: STRICT ( Content-Disposition , Content-Type , Content-Transfer-Encoding ), RFC6532 ( Content-Disposition , Content-Type , Content-Transfer-Encoding ), COMPATIBLE (only Content-Disposition a nd additionally Content-Type for a file part). The mode when using value SYSTEM is determined by the system property "-Dhub.datawizard.multipart.browserMode". If "-Dhub.datawizard.multipart.browserMode=true", mode "COMPATIBLE" applies. If the property is not set or is set to false, STRICT applies. |
Multipart requests
Enter the value multipart/form-data in parameter f. Allowed methods in g are POST, PUT and PATCH. If an incorrect method is set, the system automatically switches to POST in the request.
Parameter d is then evaluated as a map name. The map must contain the individual part/file parts. Parameter p allows the multipart mode to be set.
Normal part
You create a normal part by specifying the name of the part as the key of the map entry and the content of the part as the value of the map entry.
Headers for STRICT and RFC6532 (see parameter p): Content-Type: text/plain;charset=<parameter e> Content-Transfer-Encoding: 8bit Note: The header values are fixed here, except for parameter e. |
File part
For a file part, use the following syntax for the key.
file:<key name of file part>:<file name>[:<Content-Type and optional Content-Transfer-Encoding with suffix #, see example>] |
The value to such a key is either
file:<path to file> |
or the actual content of the file.
Headers for STRICT and RFC6532 (see parameter p): Content-Type: application/octet-stream or optional Content-Type if a file path was specified and application/octet-stream; charset=<parameter e> if the actual content of the file was specified , see above and example. Content-Transfer-Encoding: binary or optional Content-Transfer-Encoding, see above and example. |
Example:
Key: file:testfile:phone.pdf:text/plain#7bit
Value: file:./webapps/root/upload/test.txt
That creates the following headers (for STRICT and RFC6532):
Content-Type: text/plain |
HTTP request headers
It is also possible to add request headers (with values) to a request by adding value pairs to the map specified in parameter l before the function execution. The following syntax has to be used.
REQUEST_HTTP_HEADER_<Value> |
Note: Please note that uppercase and lowercase in <Value> will be considered for the map key and subsequently also for the name of the actual HTTP request header.
Note: To make sure the values of the request (request headers) and the response (response headers) do not get mixed up, you can set parameter m to true, which will clear the map l before the HTTP response is stored in it.
Example:
We want to set the HTTP request header Max-Forwards (limits the number of times the message can be forwarded through proxies or gateways) to 10.
add to map(key a, value b, name of map c, [skip empty d])
a Wert: REQUEST_HTTP_HEADER_Max-Forwards
b Wert: 10
c Wert: map_Result
d Wert:
http(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o)
a Wert: http://example.com
b Wert:
c Wert:
d Wert:
e Wert:
f Wert:
g Wert: GET
h Wert:
i Wert:
j Wert:
k Wert:
l Wert: map_Result
m Wert: true
n Wert:
o Wert:
HTTP response headers and data
The response of the HTTP request can be stored into a map l. This map then contains the following keys with the associated values.
Key |
Value |
RESPONSE_HTTP_STATUS |
Returned HTTP status. |
RESPONSE_HTTP_STATUSLINE |
Returned status line. |
RESPONSE_HTTP_DATA |
Returned data. Important note: If the value for RESPONSE_HTTP_DATA is not to be stored in a map but in a file, because it is a PDF document, for example, or similar (binary), the file must be specified in parameter n. |
RESPONSE_HTTP_HEADER_<...> |
HTTP response headers. For example RESPONSE_HTTP_HEADER_CONTENT-TYPE for HTTP response header Content-Type . |
In addition, the returned data (not the response headers) can be stored in a file n. The following is an overview of all possible combinations.
Used parameters |
Saved data |
Only map l |
The map contains the response headers and the returned data (as value of key RESPONSE_HTTP_DATA). |
Only file n |
The file contains only the returned data (but no response headers). |
Map l and file n |
The map contains only the response headers (but not the key RESPONSE_HTTP_DATA). The file contains only the returned data (but no response headers). |
Raw request/response
If you want to see the raw request and the raw response (and the respective headers) for test purposes when using HTTP method POST (especially with multipart), you will find these in the log overview as a Base64-encoded string if you activate the trace messages for phase 3 in the profile logging configuration. You can decode this string with the plugin "Encode/Decode".
Examples
Note: The complete request string in the first example is http://maps.googleapis.com/maps/api/geocode/xml?address=82343+Hindenburgstra%C3%9Fe+15. The part before the ? must be specified in parameter a. The part after the ? must be specified in the parameter c.
Parameter a |
http://maps.googleapis.com/maps/api/geocode/xml |
http://www.lobster.de/img/150402_edm_data.jpg |
http://httpbin.org/post |
Parameter b |
|
|
|
Parameter c |
address=82343+Hindenburgstra%C3%9Fe+15 |
|
custname=Lobster&delivery=18:00 |
Parameter d |
|
|
|
Parameter e |
|
|
|
Parameter f |
|
|
application/x-www-form-urlencoded |
Parameter g |
GET |
GET |
POST |
Parameter h |
|
|
|
Parameter i |
|
|
|
Parameter j |
|
180 |
|
Parameter k |
|
|
2 |
Parameter l |
map_Result_1 |
map_Result_2 |
map_Result_3 |
Parameter m |
true |
true |
true |
Parameter n |
|
./temp/http/picture/logo.jpg |
|
Parameter o |
|
|
|
Result |
200 |
200 |
200 |
'RESPONSE_HTTP_HEADER_ACCEPT-RANGES'='none'
'RESPONSE_HTTP_HEADER_CONTENT-TYPE'='application/xml; charset=UTF-8'
'RESPONSE_HTTP_HEADER_TRANSFER-ENCODING'='chunked'
'RESPONSE_HTTP_HEADER_X-XSS-PROTECTION'='1; mode=block'
'RESPONSE_HTTP_HEADER_SERVER'='mafe'
'RESPONSE_HTTP_HEADER_ALTERNATE-PROTOCOL'='80:quic,p=0'
'RESPONSE_HTTP_HEADER_ACCESS-CONTROL-ALLOW-ORIGIN'='*'
'RESPONSE_HTTP_HEADER_VARY'='Accept-Language,Accept-Encoding'
'RESPONSE_HTTP_STATUS'='200'
'RESPONSE_HTTP_DATA'='
<GeocodeResponse>
<status>OK</status>
<result>
<type>street_address</type>
<formatted_address>1600 Amphitheatre Parkway, Mountain View, CA 94043, USA</formatted_address>
<address_component>
<long_name>1600</long_name>
<short_name>1600</short_name>
<type>street_number</type>
</address_component>
.
.
.
<geometry>
<location>
<lat>37.4224553</lat>
<lng>-122.0843062</lng>
</location>
<location_type>ROOFTOP</location_type>
<viewport>
<southwest>
<lat>37.4211063</lat>
<lng>-122.0856552</lng>
</southwest>
<northeast>
<lat>37.4238043</lat>
<lng>-122.0829572</lng>
</northeast>
</viewport>
</geometry>
<place_id>ChIJ2eUgeAK6j4ARbn5u_wAGqWA</place_id>
</result>
</GeocodeResponse>
'
'RESPONSE_HTTP_HEADER_X-FRAME-OPTIONS'='SAMEORIGIN'
'RESPONSE_HTTP_STATUSLINE'='OK'
'RESPONSE_HTTP_HEADER_EXPIRES'='Thu, 28 May 2015 06:58:53 GMT'
'RESPONSE_HTTP_HEADER_DATE'='Wed, 27 May 2015 06:58:53 GMT'
'RESPONSE_HTTP_HEADER_CACHE-CONTROL'='public, max-age=86400'
'RESPONSE_HTTP_HEADER_CONTENT-TYPE'='image/jpeg'
'RESPONSE_HTTP_HEADER_ACCEPT-RANGES'='bytes'
'RESPONSE_HTTP_HEADER_VARY'='Accept-Encoding'
'RESPONSE_HTTP_HEADER_SERVER'='Apache'
'RESPONSE_HTTP_HEADER_LAST-MODIFIED'='Thu, 02 Apr 2015 08:04:18 GMT'
'RESPONSE_HTTP_STATUS'='200'
'RESPONSE_HTTP_HEADER_KEEP-ALIVE'='timeout=15, max=100'
'RESPONSE_HTTP_STATUSLINE'='OK'
'RESPONSE_HTTP_HEADER_ETAG'='"1b53-512b9474c8480"'
'RESPONSE_HTTP_HEADER_DATE'='Wed, 27 May 2015 07:38:18 GMT'
'RESPONSE_HTTP_HEADER_CONNECTION'='Keep-Alive'
'RESPONSE_HTTP_HEADER_CONTENT-LENGTH'='6995'
'RESPONSE_HTTP_HEADER_CONTENT-TYPE'='application/json'
'RESPONSE_HTTP_HEADER_ACCESS-CONTROL-ALLOW-CREDENTIALS'='true'
'RESPONSE_HTTP_HEADER_SERVER'='nginx'
'RESPONSE_HTTP_STATUS'='200'
'RESPONSE_HTTP_DATA'='{
"args": {
"custname": "Lobster",
"delivery": "18:00"
},
"data": "",
"files": {},
"form": {},
"headers": {
"Accept-Encoding": "gzip,deflate",
"Cache-Control": "no-cache",
"Content-Length": "0",
"Content-Type": "application/x-www-form-urlencoded; charset=ISO-8859-1",
"Host": "httpbin.org",
"User-Agent": "Lobster"
},
"json": null,
"url": "http://httpbin.org/post?custname=Losbter&delivery=18:00"
}
'
'RESPONSE_HTTP_STATUSLINE'='OK'
'RESPONSE_HTTP_HEADER_ACCESS-CONTROL-ALLOW-ORIGIN'='*'
'RESPONSE_HTTP_HEADER_DATE'='Wed, 27 May 2015 07:50:30 GMT'
'RESPONSE_HTTP_HEADER_CONNECTION'='keep-alive'
'RESPONSE_HTTP_HEADER_CONTENT-LENGTH'='500'