Skip to content

Commit 039d1e4

Browse files
committed
Fix bug related to multiple headers with the same name
1 parent 82cdc7a commit 039d1e4

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/main/java/com/bitpay/sdk/client/HttpResponseProvider.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,21 @@
1717
public class HttpResponseProvider {
1818

1919
public static HttpResponse fromApacheHttpResponse(org.apache.http.HttpResponse apacheHttpResponse)
20-
throws BitPayApiException {
20+
throws BitPayApiException {
2121
try {
2222
final HttpEntity entity = apacheHttpResponse.getEntity();
2323
String body = EntityUtils.toString(entity, "UTF-8");
2424

2525
return new HttpResponse(
26-
apacheHttpResponse.getStatusLine().getStatusCode(),
27-
body,
28-
Arrays.stream(apacheHttpResponse.getAllHeaders())
29-
.collect(Collectors.toMap(Header::getName, Header::getValue)),
30-
apacheHttpResponse.getLocale().toString(),
31-
apacheHttpResponse.getStatusLine().getProtocolVersion().toString()
32-
);
26+
apacheHttpResponse.getStatusLine().getStatusCode(),
27+
body,
28+
Arrays.stream(apacheHttpResponse.getAllHeaders())
29+
.collect(Collectors.toMap(
30+
Header::getName,
31+
Header::getValue,
32+
(v1, v2) -> v1 + "," + v2)),
33+
apacheHttpResponse.getLocale().toString(),
34+
apacheHttpResponse.getStatusLine().getProtocolVersion().toString());
3335

3436
} catch (IOException e) {
3537
BitPayExceptionProvider.throwApiExceptionWithMessage(e.getMessage());

0 commit comments

Comments
 (0)