|
20 | 20 |
|
21 | 21 | import java.io.IOException; |
22 | 22 | import java.io.InputStream; |
23 | | -import java.net.URISyntaxException; |
24 | 23 | import java.net.URI; |
25 | | -import java.net.URL; |
26 | | -import java.time.LocalDateTime; |
27 | 24 | import java.util.ArrayList; |
28 | 25 | import java.util.HashMap; |
29 | | -import java.util.Iterator; |
30 | 26 | import java.util.List; |
31 | 27 | import java.util.Map; |
32 | 28 |
|
|
56 | 52 | import org.apache.hc.core5.http.HttpHost; |
57 | 53 | import org.apache.hc.core5.http.HttpVersion; |
58 | 54 | import org.apache.hc.core5.http.ProtocolVersion; |
59 | | -import org.apache.hc.core5.http.ProtocolException; |
| 55 | +import org.apache.hc.core5.http.HeaderElement; |
| 56 | +import org.apache.hc.core5.http.message.BasicHeaderValueParser; |
60 | 57 | import org.apache.hc.core5.http.message.HeaderGroup; |
61 | 58 | import org.apache.hc.core5.http.io.entity.EntityUtils; |
| 59 | +import org.apache.hc.core5.http.message.ParserCursor; |
62 | 60 | import org.apache.hc.core5.net.URIAuthority; |
63 | 61 | import org.apache.hc.core5.util.Timeout; |
64 | 62 |
|
@@ -195,8 +193,17 @@ public Header[] getResponseHeaders() { |
195 | 193 | public Map<String,String> getCookies() { |
196 | 194 | Map<String,String> cookies = new HashMap<>(); |
197 | 195 | for (String name : COOKIE_HEADER_NAMES) { |
198 | | - for (final org.apache.hc.core5.http.Header header : response.getHeaders()) { |
199 | | - cookies.put(header.getName(), header.getValue()); |
| 196 | + for (final org.apache.hc.core5.http.Header header : response.getHeaders(name)) { |
| 197 | + final String headerValue = header.getValue(); |
| 198 | + if (headerValue == null) { |
| 199 | + continue; |
| 200 | + } |
| 201 | + final ParserCursor cursor = new ParserCursor(0, headerValue.length()); |
| 202 | + final HeaderElement[] headerElements = BasicHeaderValueParser.INSTANCE.parseElements(headerValue, |
| 203 | + cursor); |
| 204 | + for (final HeaderElement headerElement : headerElements) { |
| 205 | + cookies.put(headerElement.getName(), headerElement.getValue()); |
| 206 | + } |
200 | 207 | } |
201 | 208 | } |
202 | 209 | return cookies; |
|
0 commit comments