Skip to content

Commit

Permalink
Added to the response headers doc example to show how to send multi-v…
Browse files Browse the repository at this point in the history
…alued response headers
  • Loading branch information
tomakehurst committed Jan 4, 2019
1 parent a05ce9f commit fea7cde
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions docs-v2/_docs/stubbing.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,22 @@ Priority is set via the `priority` attribute in JSON:

## Sending response headers

In addition to matching on request headers, it's also possible to send response headers:
In addition to matching on request headers, it's also possible to send response headers.


Java:

```java
stubFor(get(urlEqualTo("/whatever"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withHeader("Set-Cookie", "session_id=91837492837")
.withHeader("Set-Cookie", "split_test_group=B") // You can call withHeader more than once for the same header if multiple values are required
.withHeader("Cache-Control", "no-cache")));
```

Or
JSON:

```json
{
Expand All @@ -202,6 +207,7 @@ Or
"status": 200,
"headers": {
"Content-Type": "text/plain",
"Set-Cookie": ["session_id=91837492837", "split_test_group=B"],
"Cache-Control": "no-cache"
}
}
Expand Down

0 comments on commit fea7cde

Please sign in to comment.