Skip to content

Commit

Permalink
documenting existing behaviour when Content-Length or Transfer-Encodi…
Browse files Browse the repository at this point in the history
…ng will be returned
  • Loading branch information
wojciechbulaty committed Dec 15, 2016
1 parent 1cece0a commit 3b5cf0e
Showing 1 changed file with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,47 @@ public void readsJsonMapping() {
assertThat(response.statusCode(), is(200));
assertThat(response.content(), is("{\"key\":\"value\",\"array\":[1,2,3]}"));
}


@Test
public void appendsTransferEncodingHeaderIfNoContentLengthHeaderIsPresentInMapping() throws Exception {
testClient.addResponse(
"{ \n" +
" \"request\": { \n" +
" \"method\": \"GET\", \n" +
" \"url\": \"/with/body\" \n" +
" }, \n" +
" \"response\": { \n" +
" \"status\": 200, \n" +
" \"body\": \"Some content\" \n" +
" } \n" +
"} ");

WireMockResponse response = testClient.get("/with/body");

assertThat(response.firstHeader("Transfer-Encoding"), is("chunked"));
}

@Test
public void responseContainsContentLengthHeaderIfItIsDefinedInTheMapping() throws Exception {
testClient.addResponse(
"{ \n" +
" \"request\": { \n" +
" \"method\": \"GET\", \n" +
" \"url\": \"/with/body\" \n" +
" }, \n" +
" \"response\": { \n" +
" \"status\": 200, \n" +
" \"headers\": { \n" +
" \"Content-Length\": \"12\" \n" +
" }, \n" +
" \"body\": \"Some content\" \n" +
" } \n" +
"} ");
WireMockResponse response = testClient.get("/with/body");

assertThat(response.firstHeader("Content-Length"), is("12"));
}

private void getResponseAndAssert200Status(String url) {
WireMockResponse response = testClient.get(url);
assertThat(response.statusCode(), is(200));
Expand Down

0 comments on commit 3b5cf0e

Please sign in to comment.