当前位置: 首页>>代码示例>>Java>>正文


Java CookieHandler.get方法代码示例

本文整理汇总了Java中java.net.CookieHandler.get方法的典型用法代码示例。如果您正苦于以下问题:Java CookieHandler.get方法的具体用法?Java CookieHandler.get怎么用?Java CookieHandler.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.net.CookieHandler的用法示例。


在下文中一共展示了CookieHandler.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processCookie

import java.net.CookieHandler; //导入方法依赖的package包/类
void processCookie(String url, Map<String, List<String>> headers) {
    if (!isUseCookie()) {
        return;
    }
    try {
        CookieHandler cookieManager = getCookieHandler();
        Map<String, List<String>> singleMap =
                cookieManager.get(URI.create(url), new HashMap<String, List<String>>(0));
        List<String> cookies = singleMap.get("Cookie");
        if (cookies != null) {
            headers.put("Cookie", Collections.singletonList(TextUtils.join(";", cookies)));
        }
    } catch (Throwable ex) {
        LogUtil.e(ex.getMessage(), ex);
    }
}
 
开发者ID:alexclin0188,项目名称:httplite,代码行数:17,代码来源:URLite.java

示例2: printCookieInfo

import java.net.CookieHandler; //导入方法依赖的package包/类
static private void printCookieInfo(URI uri) throws IOException {
    CookieHandler handler = CookieHandler.getDefault();
    Map<String, List<String>> cookieMap = null;

    if (handler == null) {
        System.out.println("Failing due to lack of CookieHandler class!");
        return;
    }
    System.out.println("Using CookieHandler class: " + handler.getClass().getCanonicalName());

    cookieMap = handler.get(uri, new HashMap<String, List<String>>());
    for (Map.Entry<String, List<String>> entry : cookieMap.entrySet()) {
        System.out.println("Iterating cookiemap with " + entry.getKey() + " => " + entry.getValue());
        if (entry.getKey().contains("Cookie")) {
            for (String cookie : entry.getValue()) {
                System.out.println("Found cookie: " + cookie);
            }
        }
    }
}
 
开发者ID:GITNE,项目名称:icedtea-web,代码行数:21,代码来源:CheckingCookies.java

示例3: printEnvironment

import java.net.CookieHandler; //导入方法依赖的package包/类
private void printEnvironment() {
	Version version = new Version();
	addDetailMessage("eID browser applet version: " + version.getVersion());
	addDetailMessage("Java version: " + System.getProperty("java.version"));
	addDetailMessage("Java vendor: " + System.getProperty("java.vendor"));
	addDetailMessage("OS: " + System.getProperty("os.name"));
	addDetailMessage("OS version: " + System.getProperty("os.version"));
	addDetailMessage("OS arch: " + System.getProperty("os.arch"));
	addDetailMessage("Web application URL: " + this.runtime.getDocumentBase());
	addDetailMessage("Current time: " + new Date());

	/*
	 * Next we check for the presence of the session cookie.
	 */
	CookieHandler cookieHandler = CookieHandler.getDefault();
	if (null != cookieHandler) {
		URL documentBase = this.runtime.getApplet().getDocumentBase();
		try {
			Map<String, List<String>> headers = cookieHandler.get(documentBase.toURI(),
					new HashMap<String, List<String>>());
			List<String> cookieHeaderValues = headers.get("Cookie");
			if (null == cookieHeaderValues || cookieHeaderValues.isEmpty()) {
				addDetailMessage("ERROR: no session cookie detected!");
			} else {
				/*
				 * Of course we don't print out the session cookie...
				 */
				addDetailMessage("session cookie detected");
			}
		} catch (Exception e) {
			addDetailMessage("error getting cookies from default cookie handler");
		}
	}
}
 
开发者ID:e-Contract,项目名称:eid-applet,代码行数:35,代码来源:Controller.java

示例4: addCookie

import java.net.CookieHandler; //导入方法依赖的package包/类
/**
 * Conform to the URI of the Cookie is added to the head.
 *
 * @param uri           url.
 * @param cookieHandler cookieHandler.
 */
public void addCookie(URI uri, CookieHandler cookieHandler) {
    try {
        Map<String, List<String>> diskCookies = cookieHandler.get(uri, new HashMap<String, List<String>>());
        for (Map.Entry<String, List<String>> entry : diskCookies.entrySet()) {
            String key = entry.getKey();
            List<String> value = entry.getValue();
            if (HEAD_KEY_COOKIE.equalsIgnoreCase(key)) {
                add(key, TextUtils.join("; ", value));
            }
        }
    } catch (IOException e) {
        Logger.e(e);
    }
}
 
开发者ID:yanzhenjie,项目名称:NoHttp,代码行数:21,代码来源:Headers.java


注:本文中的java.net.CookieHandler.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。