equal
deleted
inserted
replaced
79 * to use it. |
79 * to use it. |
80 * </li> |
80 * </li> |
81 * <li> |
81 * <li> |
82 * Currently, only CookieStore.add(URI, HttpCookie) and CookieStore.get(URI) |
82 * Currently, only CookieStore.add(URI, HttpCookie) and CookieStore.get(URI) |
83 * are used by CookieManager. Others are for completeness and might be needed |
83 * are used by CookieManager. Others are for completeness and might be needed |
84 * by a more sophisticated CookieStore implementation, e.g. a NetscapeCookieSotre. |
84 * by a more sophisticated CookieStore implementation, e.g. a NetscapeCookieStore. |
85 * </li> |
85 * </li> |
86 * </ul> |
86 * </ul> |
87 * </blockquote> |
87 * </blockquote> |
88 * |
88 * |
89 * <p>There're various ways user can hook up his own HTTP cookie management behavior, e.g. |
89 * <p>There're various ways user can hook up his own HTTP cookie management behavior, e.g. |
199 // pre-condition check |
199 // pre-condition check |
200 if (uri == null || requestHeaders == null) { |
200 if (uri == null || requestHeaders == null) { |
201 throw new IllegalArgumentException("Argument is null"); |
201 throw new IllegalArgumentException("Argument is null"); |
202 } |
202 } |
203 |
203 |
204 Map<String, List<String>> cookieMap = new java.util.HashMap<>(); |
|
205 // if there's no default CookieStore, no way for us to get any cookie |
204 // if there's no default CookieStore, no way for us to get any cookie |
206 if (cookieJar == null) |
205 if (cookieJar == null) |
207 return Collections.unmodifiableMap(cookieMap); |
206 return Map.of(); |
208 |
207 |
209 boolean secureLink = "https".equalsIgnoreCase(uri.getScheme()); |
208 boolean secureLink = "https".equalsIgnoreCase(uri.getScheme()); |
210 List<HttpCookie> cookies = new java.util.ArrayList<>(); |
209 List<HttpCookie> cookies = new java.util.ArrayList<>(); |
211 String path = uri.getPath(); |
210 String path = uri.getPath(); |
212 if (path == null || path.isEmpty()) { |
211 if (path == null || path.isEmpty()) { |
242 } |
241 } |
243 |
242 |
244 // apply sort rule (RFC 2965 sec. 3.3.4) |
243 // apply sort rule (RFC 2965 sec. 3.3.4) |
245 List<String> cookieHeader = sortByPath(cookies); |
244 List<String> cookieHeader = sortByPath(cookies); |
246 |
245 |
247 cookieMap.put("Cookie", cookieHeader); |
246 return Map.of("Cookie", cookieHeader); |
248 return Collections.unmodifiableMap(cookieMap); |
|
249 } |
247 } |
250 |
248 |
251 public void |
249 public void |
252 put(URI uri, Map<String, List<String>> responseHeaders) |
250 put(URI uri, Map<String, List<String>> responseHeaders) |
253 throws IOException |
251 throws IOException |