當前位置: 首頁>>代碼示例>>Java>>正文


Java BasicClientCookie.setAttribute方法代碼示例

本文整理匯總了Java中org.apache.http.impl.cookie.BasicClientCookie.setAttribute方法的典型用法代碼示例。如果您正苦於以下問題:Java BasicClientCookie.setAttribute方法的具體用法?Java BasicClientCookie.setAttribute怎麽用?Java BasicClientCookie.setAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.http.impl.cookie.BasicClientCookie的用法示例。


在下文中一共展示了BasicClientCookie.setAttribute方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: makeCookie

import org.apache.http.impl.cookie.BasicClientCookie; //導入方法依賴的package包/類
/**
 * Create an HttpClient cookie from a JMeter cookie
 */
private org.apache.http.cookie.Cookie makeCookie(Cookie jmc) {
    long exp = jmc.getExpiresMillis();
    BasicClientCookie ret = new BasicClientCookie(jmc.getName(),
            jmc.getValue());
    ret.setDomain(jmc.getDomain());
    ret.setPath(jmc.getPath());
    ret.setExpiryDate(exp > 0 ? new Date(exp) : null); // use null for no expiry
    ret.setSecure(jmc.getSecure());
    ret.setVersion(jmc.getVersion());
    if(jmc.isDomainSpecified()) {
        ret.setAttribute(ClientCookie.DOMAIN_ATTR, jmc.getDomain());
    }
    if(jmc.isPathSpecified()) {
        ret.setAttribute(ClientCookie.PATH_ATTR, jmc.getPath());
    }
    return ret;
}
 
開發者ID:johrstrom,項目名稱:cloud-meter,代碼行數:21,代碼來源:HC4CookieHandler.java

示例2: convertCookie

import org.apache.http.impl.cookie.BasicClientCookie; //導入方法依賴的package包/類
/**
 * Converts Selenium cookie to Apache http client.
 * @param browserCookie selenium cookie.
 * @return http client format.
 */
protected ClientCookie convertCookie(Cookie browserCookie) {
    BasicClientCookie cookie = new BasicClientCookie(browserCookie.getName(), browserCookie.getValue());
    String domain = browserCookie.getDomain();
    if (domain != null && domain.startsWith(".")) {
        // http client does not like domains starting with '.', it always removes it when it receives them
        domain = domain.substring(1);
    }
    cookie.setDomain(domain);
    cookie.setPath(browserCookie.getPath());
    cookie.setExpiryDate(browserCookie.getExpiry());
    cookie.setSecure(browserCookie.isSecure());
    if (browserCookie.isHttpOnly()) {
        cookie.setAttribute("httponly", "");
    }
    return cookie;
}
 
開發者ID:fhoeben,項目名稱:hsac-fitnesse-fixtures,代碼行數:22,代碼來源:CookieConverter.java

示例3: createCookie

import org.apache.http.impl.cookie.BasicClientCookie; //導入方法依賴的package包/類
public static Cookie createCookie(String name, String value) {
    final BasicClientCookie cookie = new BasicClientCookie(name, value);
    cookie.setAttribute(ClientCookie.DOMAIN_ATTR, Const.COOKIE_DOMAIN);
    cookie.setPath("/");
    cookie.setDomain(Const.COOKIE_DOMAIN);
    return cookie;
}
 
開發者ID:Roboroxx,項目名稱:itunesconnect-api,代碼行數:8,代碼來源:Utils.java

示例4: createCookieForHeaderElement

import org.apache.http.impl.cookie.BasicClientCookie; //導入方法依賴的package包/類
/**
 *  This method will create a {@link BasicClientCookie} with the given {@link HeaderElement}.
 *  It sill set the cookie's name and value according to the {@link HeaderElement#getName()} and {@link HeaderElement#getValue()} methods.
 *  Moreover, it will transport every {@link HeaderElement} parameter to the cookie using the {@link BasicClientCookie#setAttribute(String, String)}.
 *  Additionally, it configures the cookie path ({@link BasicClientCookie#setPath(String)}) to value '/client/api' and the cookie domain using {@link #configureDomainForCookie(BasicClientCookie)} method.
 */
protected BasicClientCookie createCookieForHeaderElement(HeaderElement element) {
    BasicClientCookie cookie = new BasicClientCookie(element.getName(), element.getValue());
    for (NameValuePair parameter : element.getParameters()) {
        cookie.setAttribute(parameter.getName(), parameter.getValue());
    }
    cookie.setPath("/client/api");
    configureDomainForCookie(cookie);
    return cookie;
}
 
開發者ID:Autonomiccs,項目名稱:apache-cloudstack-java-client,代碼行數:16,代碼來源:ApacheCloudStackClient.java

示例5: retrieveWsdl

import org.apache.http.impl.cookie.BasicClientCookie; //導入方法依賴的package包/類
static void retrieveWsdl(final Context context, final HttpGet httpGet, final String wsdlFileName) throws Exception {
    final BasicClientCookie cookie = new BasicClientCookie("sid", context.loginContext.getSessionId());
    cookie.setDomain(".salesforce.com");
    cookie.setAttribute(ClientCookie.DOMAIN_ATTR, "true");

    CookieStore cookieStore = new BasicCookieStore();
    cookieStore.addCookie(cookie);

    HttpContext localContext = new BasicHttpContext();
    localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    final String outputFile = StringUtils.concatWithSeparator(false, System.getProperty("file.separator"), context.outputDir, context.prefix + wsdlFileName);

    System.out.println("Retreiving [" + outputFile + "]");

    CloseableHttpResponse loginResponse = HttpClients.createDefault().execute(httpGet, localContext);

    final FileWriter writer = new FileWriter(outputFile);

    IOUtils.copy(loginResponse.getEntity().getContent(), writer);

    writer.close();

    loginResponse.close();

}
 
開發者ID:solenopsis,項目名稱:Metadata,代碼行數:27,代碼來源:RetrieveWsdls.java


注:本文中的org.apache.http.impl.cookie.BasicClientCookie.setAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。