当前位置: 首页>>代码示例>>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;未经允许,请勿转载。