當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。