Skip to content

Commit

Permalink
Use single Cookie header in HttpRequestSnippet
Browse files Browse the repository at this point in the history
  • Loading branch information
izeye authored and wilkinsona committed Oct 18, 2024
1 parent 1dcd748 commit 5d9b7ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,12 @@ private List<Map<String, String>> getHeaders(OperationRequest request) {
}
}

List<String> cookies = new ArrayList<>();
for (RequestCookie cookie : request.getCookies()) {
headers.add(header(HttpHeaders.COOKIE, String.format("%s=%s", cookie.getName(), cookie.getValue())));
cookies.add(String.format("%s=%s", cookie.getName(), cookie.getValue()));
}
if (!cookies.isEmpty()) {
headers.add(header(HttpHeaders.COOKIE, String.join("; ", cookies)));
}

if (requiresFormEncodingContentTypeHeader(request)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ public void getRequestWithCookies() throws IOException {
.build());
assertThat(this.generatedSnippets.httpRequest())
.is(httpRequest(RequestMethod.GET, "/foo").header(HttpHeaders.HOST, "localhost")
.header(HttpHeaders.COOKIE, "name1=value1")
.header(HttpHeaders.COOKIE, "name2=value2"));
.header(HttpHeaders.COOKIE, "name1=value1; name2=value2"));
}

@Test
Expand Down

0 comments on commit 5d9b7ec

Please sign in to comment.