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


Java Cookie.getName方法代码示例

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


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

示例1: saveCookies

import org.apache.http.cookie.Cookie; //导入方法依赖的package包/类
public void saveCookies(List<Cookie> cookies){
	String strCookie = "";
       Date sessionTime = null;
       
       if (cookies != null && !cookies.isEmpty()) {
           for (int i = 0; i < cookies.size(); i++) {
           	Cookie cookie = cookies.get(i);
           	if (cookie.getName().equalsIgnoreCase("JSESSIONID")){
            	strCookie += cookie.getName() + "="
	                     + cookie.getValue() + ";domain="
	                     +cookie.getDomain();
	            sessionTime = cookies.get(i).getExpiryDate();
           	}
           }
       }
       editor.putString("cookies", strCookie);
	editor.commit();
	editor.putString("cookiesExpiryDate", (sessionTime == null)?null:TimeUtil.getDTFormat().format(sessionTime));
	editor.commit();
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:21,代码来源:A6UserInfoSPUtil.java

示例2: addCookie

import org.apache.http.cookie.Cookie; //导入方法依赖的package包/类
@Override
public void addCookie(Cookie cookie) {
    String name = cookie.getName() + cookie.getDomain();

    // Save cookie into local store, or remove if expired
    if (!cookie.isExpired(new Date())) {
        cookies.put(name, cookie);
    } else {
        cookies.remove(name);
    }

    // Save cookie into persistent store
    SharedPreferences.Editor prefsWriter = cookiePrefs.edit();
    prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet()));
    prefsWriter.putString(COOKIE_NAME_PREFIX + name, encodeCookie(new SerializableCookie(cookie)));
    prefsWriter.apply();
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:18,代码来源:PersistentCookieStore.java

示例3: addCookie

import org.apache.http.cookie.Cookie; //导入方法依赖的package包/类
@Override
public void addCookie(Cookie cookie) {
    if (omitNonPersistentCookies && !cookie.isPersistent())
        return;
    String name = cookie.getName() + cookie.getDomain();

    // Save cookie into local store, or remove if expired
    if (!cookie.isExpired(new Date())) {
        cookies.put(name, cookie);
    } else {
        cookies.remove(name);
    }

    // Save cookie into persistent store
    SharedPreferences.Editor prefsWriter = cookiePrefs.edit();
    prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet()));
    prefsWriter.putString(COOKIE_NAME_PREFIX + name, encodeCookie(new SerializableCookie(cookie)));
    prefsWriter.commit();
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:20,代码来源:PersistentCookieStore.java

示例4: validate

import org.apache.http.cookie.Cookie; //导入方法依赖的package包/类
@Override
public void validate(final Cookie cookie, final CookieOrigin origin)
        throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    String name = cookie.getName();
    if (name.indexOf(' ') != -1) {
        throw new CookieRestrictionViolationException("Cookie name may not contain blanks");
    }
    if (name.startsWith("$")) {
        throw new CookieRestrictionViolationException("Cookie name may not start with $");
    }
    super.validate(cookie, origin);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:RFC2109Spec.java

示例5: makeHttpRequest

import org.apache.http.cookie.Cookie; //导入方法依赖的package包/类
@Override
protected HttpResponse makeHttpRequest(HttpEntity entity, long startTime) {
    if (entity != null) {
        requestBuilder.setEntity(entity);
        requestBuilder.setHeader(entity.getContentType());
    }
    HttpUriRequest httpRequest = requestBuilder.build();
    CloseableHttpClient client = clientBuilder.build();
    BasicHttpContext context = new BasicHttpContext();
    context.setAttribute(URI_CONTEXT_KEY, getRequestUri());
    CloseableHttpResponse httpResponse;
    byte[] bytes;
    try {
        httpResponse = client.execute(httpRequest, context);
        HttpEntity responseEntity = httpResponse.getEntity();
        if (responseEntity == null || responseEntity.getContent() == null) {
            bytes = new byte[0];
        } else {
            InputStream is = responseEntity.getContent();
            bytes = FileUtils.toBytes(is);
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    long responseTime = getResponseTime(startTime);
    HttpResponse response = new HttpResponse(responseTime);
    response.setUri(getRequestUri());
    response.setBody(bytes);
    response.setStatus(httpResponse.getStatusLine().getStatusCode());
    for (Cookie c : cookieStore.getCookies()) {
        com.intuit.karate.http.Cookie cookie = new com.intuit.karate.http.Cookie(c.getName(), c.getValue());
        cookie.put(DOMAIN, c.getDomain());
        cookie.put(PATH, c.getPath());
        if (c.getExpiryDate() != null) {
            cookie.put(EXPIRES, c.getExpiryDate().getTime() + "");
        }
        cookie.put(PERSISTENT, c.isPersistent() + "");
        cookie.put(SECURE, c.isSecure() + "");
        response.addCookie(cookie);
    }
    cookieStore.clear(); // we rely on the StepDefs for cookie 'persistence'
    for (Header header : httpResponse.getAllHeaders()) {
        response.addHeader(header.getName(), header.getValue());
    }
    return response;
}
 
开发者ID:intuit,项目名称:karate,代码行数:47,代码来源:ApacheHttpClient.java

示例6: addCookie

import org.apache.http.cookie.Cookie; //导入方法依赖的package包/类
public void addCookie(Cookie cookie) {
    String name = cookie.getName() + cookie.getDomain();
    if (cookie.isExpired(new Date())) {
        this.cookies.remove(name);
    } else {
        this.cookies.put(name, cookie);
    }
    Editor prefsWriter = this.cookiePrefs.edit();
    prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", this.cookies.keySet()));
    prefsWriter.putString(new StringBuilder(COOKIE_NAME_PREFIX).append(name).toString(), encodeCookie(new SerializableCookie(cookie)));
    prefsWriter.commit();
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:13,代码来源:PersistentCookieStore.java

示例7: getCaptchaId

import org.apache.http.cookie.Cookie; //导入方法依赖的package包/类
private String getCaptchaId(HttpClient httpClient) {
    List<Cookie> cookies = ((AbstractHttpClient) httpClient).getCookieStore().getCookies();
    String captchaId = null;
    for (int i = 0; i < cookies.size(); i++) {
        Cookie cookie = (Cookie) cookies.get(i);
        String cookieName = cookie.getName();
        if (!TextUtils.isEmpty(cookieName) && cookieName.equals("captchaId")) {
            captchaId = cookie.getValue();
        }
    }
    return captchaId;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:13,代码来源:RegisterMobileFragment.java

示例8: addCookie

import org.apache.http.cookie.Cookie; //导入方法依赖的package包/类
public void addCookie(Cookie cookie) {
    if (!this.omitNonPersistentCookies || cookie.isPersistent()) {
        String name = cookie.getName() + cookie.getDomain();
        if (cookie.isExpired(new Date())) {
            this.cookies.remove(name);
        } else {
            this.cookies.put(name, cookie);
        }
        Editor prefsWriter = this.cookiePrefs.edit();
        prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", this.cookies.keySet()));
        prefsWriter.putString(COOKIE_NAME_PREFIX + name, encodeCookie(new SerializableCookie
                (cookie)));
        prefsWriter.commit();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:16,代码来源:PersistentCookieStore.java

示例9: deleteCookie

import org.apache.http.cookie.Cookie; //导入方法依赖的package包/类
public void deleteCookie(Cookie cookie) {
    String name = cookie.getName() + cookie.getDomain();
    this.cookies.remove(name);
    Editor prefsWriter = this.cookiePrefs.edit();
    prefsWriter.remove(COOKIE_NAME_PREFIX + name);
    prefsWriter.commit();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:PersistentCookieStore.java

示例10: deleteCookie

import org.apache.http.cookie.Cookie; //导入方法依赖的package包/类
/**
 * Non-standard helper method, to delete cookie
 *
 * @param cookie cookie to be removed
 */
public void deleteCookie(Cookie cookie) {
    String name = cookie.getName() + cookie.getDomain();
    cookies.remove(name);
    SharedPreferences.Editor prefsWriter = cookiePrefs.edit();
    prefsWriter.remove(COOKIE_NAME_PREFIX + name);
    prefsWriter.commit();
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:13,代码来源:PersistentCookieStore.java

示例11: DCookieStore

import org.apache.http.cookie.Cookie; //导入方法依赖的package包/类
public DCookieStore(DSession permanentSession) {
    this.permanentSession = permanentSession;

    if (this.permanentSession != null && this.permanentSession.getCookies() != null) {
        for (Cookie cookie : this.permanentSession.getCookies()) {
            BasicClientCookie bcc = new BasicClientCookie(cookie.getName(), cookie.getValue());
            bcc.setDomain(((BasicClientCookie)cookie).getDomain());
            bcc.setPath(((BasicClientCookie)cookie).getPath());
            bcc.setVersion(((BasicClientCookie)cookie).getVersion());
            super.addCookie(bcc);
        }
    }
}
 
开发者ID:indiketa,项目名称:degiro-java-client,代码行数:14,代码来源:DCookieStore.java


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