private void addRequestHeaders() { Map<String, List<String>> cookies; try { cookies = cookieManager.get(httpRequest.getUri(), httpRequest.getHeaders()); } catch (IOException e) { handleError(e); return; } // unfortunately CookieManager returns ""Cookie" -> empty list" pair if the cookie is not set cookies.entrySet().stream().filter(cookieHeader -> cookieHeader.getValue() != null && !cookieHeader.getValue().isEmpty()) .forEach(cookieHeader -> httpRequest.getHeaders().put(cookieHeader.getKey(), cookieHeader.getValue())); }
Map<String, List<String>> cookieMap = cookieManager.get(uri, Collections.emptyMap()); for (Map.Entry<String, List<String>> entry : cookieMap.entrySet()) { request.addHeaderValues(entry.getKey(), entry.getValue());
Map<String, List<String>> cookieMap = cookieManager.get(uri, Collections.emptyMap()); for (Map.Entry<String, List<String>> entry : cookieMap.entrySet()) { request.addHeaderValues(entry.getKey(), entry.getValue());
Map<String, List<String>> requestCookieHeaders = cookieManager.get(connection .getURL().toURI(), connection.getRequestProperties()); for (Map.Entry<String, List<String>> requestCookieHeader :
@Override public Map<String, List<String>> get(URI uri, Map<String, List<String>> requestHeaders) throws IOException { return getPersonalCookieManager().get(uri, requestHeaders); }
@Override public Map<String, List<String>> loadCookies(Exchange exchange, URI uri) throws IOException { // the map is not used, so we do not need to fetch the headers from the // exchange return getCookieManager(exchange).get(uri, Collections.emptyMap()); }
@Override public Map<String, List<String>> get(URI uri, Map<String, List<String>> requestHeaders) throws IOException { return getPersonalCookieManager().get(uri, requestHeaders); }
headers.putAll(wrappedManager.get(uri, requestHeaders));
protected Map<String,String> cookiesToAdd(final HttpObjectConfig.Client clientConfig, final ChainedHttpConfig.ChainedRequest cr) { Map<String,String> tmp = new HashMap<>(); try { final URI uri = cr.getUri().toURI(); for(HttpCookie cookie : cr.actualCookies(new ArrayList<>())) { final String keyName = clientConfig.getCookieVersion() == 0 ? "Set-Cookie" : "Set-Cookie2"; final Map<String,List<String>> toPut = singletonMap(keyName, singletonList(cookie.toString())); cookieManager.put(uri, toPut); } for(Map.Entry<String,List<String>> e : cookieManager.get(uri, emptyMap()).entrySet()) { if(e.getValue() != null && !e.getValue().isEmpty()) { tmp.put(e.getKey(), String.join("; ", e.getValue())); } } } catch(IOException ioe) { throw new RuntimeException(ioe); } return tmp; }
protected Map<String, String> cookiesToAdd(final HttpObjectConfig.Client clientConfig, final ChainedHttpConfig.ChainedRequest cr) throws URISyntaxException { Map<String, String> tmp = new HashMap<>(); try { final URI uri = cr.getUri().toURI(); for (HttpCookie cookie : cr.actualCookies(new ArrayList<>())) { final String keyName = clientConfig.getCookieVersion() == 0 ? "Set-Cookie" : "Set-Cookie2"; final Map<String, List<String>> toPut = singletonMap(keyName, singletonList(cookie.toString())); cookieManager.put(cr.getUri().forCookie(cookie), toPut); } Map<String, List<String>> found = cookieManager.get(uri, emptyMap()); for (Map.Entry<String, List<String>> e : found.entrySet()) { if (e.getValue() != null && !e.getValue().isEmpty()) { tmp.put(e.getKey(), String.join("; ", e.getValue())); } } } catch (IOException ioe) { throw new TransportingException(ioe); } return tmp; }
protected Map<String, String> cookiesToAdd(final HttpObjectConfig.Client clientConfig, final ChainedHttpConfig.ChainedRequest cr) throws URISyntaxException { Map<String, String> tmp = new HashMap<>(); try { final URI uri = cr.getUri().toURI(); for (HttpCookie cookie : cr.actualCookies(new ArrayList<>())) { final String keyName = clientConfig.getCookieVersion() == 0 ? "Set-Cookie" : "Set-Cookie2"; final Map<String, List<String>> toPut = singletonMap(keyName, singletonList(cookie.toString())); cookieManager.put(cr.getUri().forCookie(cookie), toPut); } Map<String, List<String>> found = cookieManager.get(uri, emptyMap()); for (Map.Entry<String, List<String>> e : found.entrySet()) { if (e.getValue() != null && !e.getValue().isEmpty()) { tmp.put(e.getKey(), String.join("; ", e.getValue())); } } } catch (IOException ioe) { throw new TransportingException(ioe); } return tmp; }
@Override public Map<String, List<String>> get(URI uri, Map<String, List<String>> requestHeaders) throws IOException { var headers = super.get(uri, requestHeaders); var userList = requestHeaders.getOrDefault(HeaderNames.COOKIE, List.of()); var sessionList = headers.getOrDefault(HeaderNames.COOKIE, List.of()); var cookieValues = Lists.concat(userList, sessionList); if (cookieValues.isEmpty()) { return Map.of(); } return Map.of(HeaderNames.COOKIE, cookieValues); } }
get(URI uri, Map<String, List<String>> requestHeaders) throws IOException { return s_impl.get().get(uri, requestHeaders);
Map<String, List<String>> headers = requester.getConfig().getCookieManager().get(URI.create(resolvedUri), Collections.<String, List<String>>emptyMap()); List<String> cookies = headers.get(COOKIE);