HTTP
Browse implementations
How to request a secured service
For all HTTP actions, authentication or secured connexion to a service is configured by setting properties on the target.
-
Basic Authentication:
- To use a basic authorization header, set properties
usernameandpasswordon the target.
- To use a basic authorization header, set properties
-
SSL:
- To use an SSL context, set a
keystoreortruststoreone the target.
Propertieskeystore,keystorePassword,keyPassword,truststoreandtruststorePasswordcould be alternatively used.
- To use an SSL context, set a
-
Proxy, 2 solutions:
- You can set a system property http.proxyHost or https.proxyHost, the HTTP client will use this as the default route planner.
- You can set a target property
proxy- Default port value is 3128.
- Target property
proxyoverride system property if set
How to read response headers
For all HTTP actions, the headers output holds the response headers as a multi-valued map.
A header may legally appear more than once, so each name maps to a list of values.
Header names are case-insensitive, so #headers['Set-Cookie'] and #headers['set-cookie'] are equivalent.
Spring's typed getters, such as ${#headers.getContentType()}, remain available for scenarios
written before Chutney 4.3.0, but map access is preferred and typed getters may be removed in a
future major version.
usernameoruserto define user for basic authentificationuserPasswordorpasswordto define password for basic authentification
Get🔗
| Required | Name | Type | Default |
|---|---|---|---|
| * | target |
String | |
| * | uri |
String | |
headers |
Map<String, String> | ||
timeout |
Duration (String) | "2000 ms" |
| Name | Type |
|---|---|
status |
int |
body |
String |
headers |
HttpHeaders |
Example🔗
Post🔗
| Required | Name | Type | Default |
|---|---|---|---|
| * | target |
String | |
| * | uri |
String | |
body |
String | {} |
|
headers |
Map<String, String> | ||
timeout |
Duration (String) | "2000 ms" |
| Name | Type |
|---|---|
status |
int |
body |
String |
headers |
HttpHeaders |
Example🔗
Put🔗
| Required | Name | Type | Default |
|---|---|---|---|
| * | target |
String | |
| * | uri |
String | |
body |
String | {} |
|
headers |
Map<String, String> | ||
timeout |
Duration (String) | "2000 ms" |
| Name | Type |
|---|---|
status |
int |
body |
String |
headers |
HttpHeaders |
Example🔗
Delete🔗
| Required | Name | Type | Default |
|---|---|---|---|
| * | target |
String | |
| * | uri |
String | |
headers |
Map<String, String> | ||
timeout |
Duration (String) | "2000 ms" |
| Name | Type |
|---|---|
status |
int |
body |
String |
headers |
HttpHeaders |
Example🔗
Patch🔗
| Required | Name | Type | Default |
|---|---|---|---|
| * | target |
String | |
| * | uri |
String | |
body |
String | {} |
|
headers |
Map<String, String> | ||
timeout |
Duration (String) | "2000 ms" |
| Name | Type |
|---|---|
status |
int |
body |
String |
headers |
HttpHeaders |
Example🔗
Mocking an HTTP Server🔗
Start🔗
| Required | Name | Type | Default |
|---|---|---|---|
port |
String | "8443" | |
truststore-path |
String | ||
truststore-password |
String | ||
keystore-path |
String | ||
keystore-password |
String |
| Name | Type |
|---|---|
| httpsServer | WireMockServer |
Example🔗
Note
This action automatically registers a teardown to stop the server at the end of the scenario.
Listened routes🔗
This actions allows you to check which requests have been received by a wiremock server.
Available verbs are : GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD, TRACE, ANY
Warning
If this action succeeds, requests will be removed from the Wiremock server.
| Required | Name | Type | Default |
|---|---|---|---|
| * | https-server |
WireMockServer | |
| * | uri |
String (regex) | |
| * | verb |
String | |
expected-message-count |
String | 1 |
| Name | Type |
|---|---|
| requests | List<LoggedRequest> |