< prev index next >
src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/CookieFilter.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 24,34 ****
*/
package jdk.incubator.http;
import java.io.IOException;
! import java.net.CookieManager;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import jdk.incubator.http.internal.common.HttpHeadersImpl;
import jdk.incubator.http.internal.common.Log;
--- 24,34 ----
*/
package jdk.incubator.http;
import java.io.IOException;
! import java.net.CookieHandler;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import jdk.incubator.http.internal.common.HttpHeadersImpl;
import jdk.incubator.http.internal.common.Log;
*** 39,53 ****
}
@Override
public void request(HttpRequestImpl r, MultiExchange<?,?> e) throws IOException {
HttpClientImpl client = e.client();
! Optional<CookieManager> cookieManOpt = client.cookieManager();
! if (cookieManOpt.isPresent()) {
! CookieManager cookieMan = cookieManOpt.get();
Map<String,List<String>> userheaders = r.getUserHeaders().map();
! Map<String,List<String>> cookies = cookieMan.get(r.uri(), userheaders);
// add the returned cookies
HttpHeadersImpl systemHeaders = r.getSystemHeaders();
if (cookies.isEmpty()) {
Log.logTrace("Request: no cookie to add for {0}",
--- 39,53 ----
}
@Override
public void request(HttpRequestImpl r, MultiExchange<?,?> e) throws IOException {
HttpClientImpl client = e.client();
! Optional<CookieHandler> cookieHandlerOpt = client.cookieHandler();
! if (cookieHandlerOpt.isPresent()) {
! CookieHandler cookieHandler = cookieHandlerOpt.get();
Map<String,List<String>> userheaders = r.getUserHeaders().map();
! Map<String,List<String>> cookies = cookieHandler.get(r.uri(), userheaders);
// add the returned cookies
HttpHeadersImpl systemHeaders = r.getSystemHeaders();
if (cookies.isEmpty()) {
Log.logTrace("Request: no cookie to add for {0}",
*** 72,86 ****
public HttpRequestImpl response(Response r) throws IOException {
HttpHeaders hdrs = r.headers();
HttpRequestImpl request = r.request();
Exchange<?> e = r.exchange;
Log.logTrace("Response: processing cookies for {0}", request.uri());
! Optional<CookieManager> cookieManOpt = e.client().cookieManager();
! if (cookieManOpt.isPresent()) {
! CookieManager cookieMan = cookieManOpt.get();
Log.logTrace("Response: parsing cookies from {0}", hdrs.map());
! cookieMan.put(request.uri(), hdrs.map());
} else {
Log.logTrace("Response: No cookie manager found for {0}",
request.uri());
}
return null;
--- 72,86 ----
public HttpRequestImpl response(Response r) throws IOException {
HttpHeaders hdrs = r.headers();
HttpRequestImpl request = r.request();
Exchange<?> e = r.exchange;
Log.logTrace("Response: processing cookies for {0}", request.uri());
! Optional<CookieHandler> cookieHandlerOpt = e.client().cookieHandler();
! if (cookieHandlerOpt.isPresent()) {
! CookieHandler cookieHandler = cookieHandlerOpt.get();
Log.logTrace("Response: parsing cookies from {0}", hdrs.map());
! cookieHandler.put(request.uri(), hdrs.map());
} else {
Log.logTrace("Response: No cookie manager found for {0}",
request.uri());
}
return null;
< prev index next >