[java] Jersey2 and resttemplate do not correctly send defaultCookies (#4821)

* Java/Jersey2 sends defaultCookies

* Send cookie value instead of [value] (resttemplate)

* Improve the javadoc string
This commit is contained in:
Ties de Kock
2019-12-21 03:15:29 +01:00
committed by William Cheng
parent 3eaafce569
commit 5740348902
7 changed files with 58 additions and 12 deletions

View File

@@ -647,14 +647,20 @@ public class ApiClient {
}
}
/**
* Build cookie header. Keeps a single value per cookie (as per <a href="https://tools.ietf.org/html/rfc6265#section-5.3">
* RFC6265 section 5.3</a>).
*
* @param cookies map all cookies
* @return header string for cookies.
*/
private String buildCookieHeader(MultiValueMap<String, String> cookies) {
final StringBuilder cookieValue = new StringBuilder();
String delimiter = "";
for (final Map.Entry<String, List<String>> entry : cookies.entrySet()) {
for (String value : entry.getValue()) {
cookieValue.append(String.format("%s%s=%s", delimiter, entry.getKey(), entry.getValue()));
delimiter = "; ";
}
final String value = entry.getValue().get(entry.getValue().size() - 1);
cookieValue.append(String.format("%s%s=%s", delimiter, entry.getKey(), value));
delimiter = "; ";
}
return cookieValue.toString();
}