本文整理汇总了Java中java.net.CookieManager.put方法的典型用法代码示例。如果您正苦于以下问题:Java CookieManager.put方法的具体用法?Java CookieManager.put怎么用?Java CookieManager.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.net.CookieManager
的用法示例。
在下文中一共展示了CookieManager.put方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: response
import java.net.CookieManager; //导入方法依赖的package包/类
@Override
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;
}
示例2: populateCookieStore
import java.net.CookieManager; //导入方法依赖的package包/类
void populateCookieStore(URI uri)
throws IOException {
CookieManager cm = new CookieManager(null, CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(cm);
Map<String,List<String>> header = new HashMap<>();
List<String> values = new ArrayList<>();
values.add("JSESSIONID=" + SESSION_ID + "; version=1; Path="
+ URI_PATH +"; HttpOnly");
values.add("CUSTOMER=WILE_E_COYOTE; version=1; Path=" + URI_PATH);
header.put("Set-Cookie", values);
cm.put(uri, header);
}