List of usage examples for java.net CookieManager get
public Map<String, List<String>> get(URI uri, Map<String, List<String>> requestHeaders) throws IOException
From source file:com.exzogeni.dk.http.HttpTask.java
private void onPrepareConnectionInternal(HttpURLConnection cn) throws Exception { final URI uri = cn.getURL().toURI(); cn.setRequestMethod(getMethodName()); cn.setConnectTimeout(mTimeoutMs);//w w w . j av a 2s . c om cn.setReadTimeout(mTimeoutMs); final CookieManager cm = mHttpManager.getCookieManager(); final Map<String, List<String>> cookies = cm.get(uri, new HashMap<String, List<String>>()); for (final Map.Entry<String, List<String>> cookie : cookies.entrySet()) { for (final String value : cookie.getValue()) { cn.addRequestProperty(cookie.getKey(), value); } } for (final Map.Entry<String, List<String>> header : mHeaders.entrySet()) { for (final String value : header.getValue()) { cn.addRequestProperty(header.getKey(), value); } } onPrepareConnection(cn); }