Hurl

Hurl is a command line tool that runs HTTP requests defined in a simple plain text format.

It can chain requests, capture values and evaluate queries on headers and body response. Hurl is very versatile: it can be used for both fetching data and testing HTTP sessions.

Hurl makes it easy to work with HTML content, REST / SOAP / GraphQL APIs, or any other XML / JSON based APIs.

Usage

Usage: hurl [OPTIONS] [FILES]...

HTTP options

OptionDescription
--aws-sigv4 <PROVIDER1[:PROVIDER2[:REGION[:SERVICE]]]>Use AWS V4 signature authentication in the transfer
--cacert <FILE>CA certificate to verify peer against (PEM format)
-E, --cert <CERTIFICATE[:PASSWORD]>Client certificate file and password
--compressedRequest compressed response (using deflate or gzip)
--connect-timeout <SECONDS>Maximum time allowed for connection [default: 300]
--connect-to <HOST1:PORT1:HOST2:PORT2>For a request to the given HOST1:PORT1 pair, connect to HOST2:PORT2 instead
-H, --header <HEADER>Pass custom header(s) to server
-0, --http1.0Tell Hurl to use HTTP version 1.0
--http1.1Tell Hurl to use HTTP version 1.1
--http2Tell Hurl to use HTTP version 2
--http3Tell Hurl to use HTTP version 3
-k, --insecureAllow insecure SSL connections
-4, --ipv4Tell Hurl to use IPv4 addresses only when resolving host names, and not for example try IPv6
-6, --ipv6Tell Hurl to use IPv6 addresses only when resolving host names, and not for example try IPv4
--key <KEY>Private key file name
--limit-rate <SPEED>Specify the maximum transfer rate in bytes/second, for both downloads and uploads
-L, --locationFollow redirects
--location-trustedFollow redirects but allows sending the name + password to all hosts that the site may redirect to
--max-filesize <BYTES>Specify the maximum size in bytes of a file to download
--max-redirs <NUM>Maximum number of redirects allowed, -1 for unlimited redirects [default: 50]
-m, --max-time <SECONDS>Maximum time allowed for the transfer [default: 300]
--noproxy <HOST(S)>List of hosts which do not use proxy
--path-as-isTell Hurl to not handle sequences of /../ or /./ in the given URL path
-x, --proxy <[PROTOCOL://]HOST[:PORT]>Use proxy on given PROTOCOL/HOST/PORT
--resolve <HOST:PORT:ADDR>Provide a custom address for a specific HOST and PORT pair
--ssl-no-revoke(Windows) Tell Hurl to disable certificate revocation checks
--unix-socket <PATH>(HTTP) Connect through this Unix domain socket, instead of using the network
-u, --user <USER:PASSWORD>Add basic Authentication header to each request
-A, --user-agent <NAME>Specify the User-Agent string to send to the HTTP server

Output options

OptionDescription
--colorColorize output
--curl <FILE>Export each request to a list of curl commands
--error-format <FORMAT>Control the format of error messages [default: short] [possible values: short, long]
-i, --includeInclude the HTTP headers in the output
--jsonOutput each Hurl file result to JSON
--no-colorDo not colorize output
--no-outputSuppress output. By default, Hurl outputs the body of the last response
-o, --output <FILE>Write to FILE instead of stdout
-v, --verboseTurn on verbose
--very-verboseTurn on verbose output, including HTTP response and libcurl logs

Run options

OptionDescription
--continue-on-errorContinue executing requests even if an error occurs
--delay <MILLISECONDS>Sets delay before each request (aka sleep) [default: 0]
--from-entry <ENTRY_NUMBER>Execute Hurl file from ENTRY_NUMBER (starting at 1)
--ignore-assertsIgnore asserts defined in the Hurl file
--interactiveTurn on interactive mode
--jobs <NUM>Maximum number of parallel jobs
--parallelRun files in parallel (default in test mode)
--repeat <NUM>Repeat the input files sequence NUM times, -1 for infinite loop
--retry <NUM>Maximum number of retries, 0 for no retries, -1 for unlimited retries
--retry-interval <MILLISECONDS>Interval in milliseconds before a retry [default: 1000]
--secret <NAME=VALUE>Define a variable which value is secret
--testActivate test mode (use parallel execution)
--to-entry <ENTRY_NUMBER>Execute Hurl file to ENTRY_NUMBER (starting at 1)
--variable <NAME=VALUE>Define a variable
--variables-file <FILE>Define a properties file in which you define your variables

Report options

OptionDescription
--report-html <DIR>Generate HTML report to DIR
--report-json <DIR>Generate JSON report to DIR
--report-junit <FILE>Write a JUnit XML report to FILE
--report-tap <FILE>Write a TAP report to FILE

Other options

OptionDescription
-b, --cookie <FILE>Read cookies from FILE
-c, --cookie-jar <FILE>Write cookies to FILE after running the session
--file-root <DIR>Set root directory to import files [default: input file directory]
--glob <GLOB>Specify input files that match the given GLOB. Multiple glob flags may be used
-n, --netrcMust read .netrc for username and password
--netrc-file <FILE>Specify FILE for .netrc
--netrc-optionalUse either .netrc or the URL

Hurl File

A Hurl file is a list of entries, each entry being a mandatory request, optionally followed by a response.

Responses are not mandatory, a Hurl file consisting only of requests is perfectly valid. To sum up, responses can be used to capture values to perform subsequent requests, or add asserts to HTTP responses.

# First, test home title.
GET https://acmecorp.net
HTTP 200
[Asserts]
xpath "normalize-space(//head/title)" == "Hello world!"
 
# Get some news, response description is optional
GET https://acmecorp.net/news
 
# Do a POST request without CSRF token and check
# that status code is Forbidden 403
POST https://acmecorp.net/contact
[Form]
default: false
email: john.doe@rookie.org
number: 33611223344
HTTP 403