Search…
http
The http statement initiates an HTTP session using any settings previously configured using the set statement. It can also be used for querying response headers.

Syntax

httpmethod url
http dump_headers
http get_headerheaderNameasvarName

Details

Executing an HTTP request

The http statement performs an HTTP request against the server and resource specified in the url paramater. Any http-related settings previously configured using set will be applied to the request.
The method argument determines the HTTP method to use for the request and must be one of GET, PUT, POST or DELETE.
The url argument must start with either http: or https:. If https: is used then SSL will be used for the request.
The url argument must also contain a valid IP address or hostname. Optionally, it may also contain a port number (preceded by a colon and appended to the IP address or hostname) and a resource.
The following defaults apply if no port or resource is specified:
Field
Default
port
80 if using http 443 if using https
resource
/
The format of the http statement is identical when used in conjunction with the buffer statement.

Querying response headers

To dump a list of all the response headers returned by the server in the most recent session use the statement:
http dump_headers
This will render a list of the headers to standard output, and is useful when implementing and debugging USE scripts. The intention of this statement is to provide a tool to assist in script development, and as such it would normally be removed or suppressed with a debug mode switch in production environments.
To retrieve the value of a specific header, use the statement:
http get_headerheaderNameasvarName
This will set the variable varName to be the value of the header headerName.
If headerName was not found in the response, then a warning will be written to the log-file. In this case varName will not be created but if it already exists then its original value will be unmodified.

Examples

Example 1

1
# A simple request using the default port and no SSL
2
set http_savefile "/extracted/http/customers.json"
3
http GET "http://localhost/v1/customers"
4
​
5
# A more complex request requiring setup and a custom port
6
clear http_headers
7
set http_header "Accept: application/json"
8
set http_header "Authorization: FFDC-4567-AE53-1234"
9
set http_savefile "extracted/http/customers.json"
10
buffer customers = http GET "https://demo.server.com:4444/v1/customers"
Copied!

Example 2

The following shows the process of retrieving a header. The output of:
1
buffer temp = http GET https://www.google.com
2
http dump_headers
3
http get_header Date as responseDate
4
print The Date header from google.com was: ${responseDate}
Copied!
Takes the following form:
1
Last response headers:
2
HTTP/1.1 200 OK
3
Cache-Control: private, max-age=0
4
Date: Mon, 26 Mar 2018 13:50:39 GMT
5
Transfer-Encoding: chunked
6
Content-Type: text/html; charset=ISO-8859-1
7
Expires: -1
8
Accept-Ranges: none
9
P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
10
Server: gws
11
Set-Cookie: 1P_JAR=2018-03-26-13; expires=Wed, 25-Apr-2018 13:50:39 GMT; path=/; domain=.google.co.uk
12
Set-Cookie: [redacted]; expires=Tue, 25-Sep-2018 13:50:39 GMT; path=/; domain=.google.co.uk; HttpOnly
13
Vary: Accept-Encoding
14
X-XSS-Protection: 1; mode=block
15
X-Frame-Options: SAMEORIGIN
16
Alt-Svc: hq=":443"; ma=2592000; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="42,41,39,35"
17
​
18
The Date header from google.com was: Mon, 26 Mar 2018 13:50:39 GMT
Copied!
Last modified 2yr ago