java.net.HttpCookie#getVersion ( )源码实例Demo

下面列出了java.net.HttpCookie#getVersion ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Kalle   文件: CookieManager.java
private String sortByPath(List<HttpCookie> cookies) {
    Collections.sort(cookies, new CookiePathComparator());
    final StringBuilder result = new StringBuilder();
    int minVersion = 1;
    for (HttpCookie cookie : cookies) {
        if (cookie.getVersion() < minVersion) {
            minVersion = cookie.getVersion();
        }
    }

    if (minVersion == 1) {
        result.append("$Version=\"1\"; ");
    }

    for (int i = 0; i < cookies.size(); ++i) {
        if (i != 0) {
            result.append("; ");
        }

        result.append(cookies.get(i).toString());
    }

    return result.toString();
}
 
源代码2 项目: http-builder-ng   文件: NonBlockingCookieStore.java
private boolean matches(final Map.Entry<Key,HttpCookie> entry, final URI uri) {
    final HttpCookie cookie = entry.getValue();
    final boolean secureLink = "https".equalsIgnoreCase(uri.getScheme());
    if(!secureLink && cookie.getSecure()) {
        return false;
    }
    
    final String host = uri.getHost();
    if(entry.getKey() instanceof UriKey) {
        return ((UriKey) entry.getKey()).host.equalsIgnoreCase(host);
    }
    else {
        final String domain = cookie.getDomain();
        if(cookie.getVersion() == 0) {
            return netscapeDomainMatches(domain, host);
        }
        else {
            return HttpCookie.domainMatches(domain, host);
        }
    }
}
 
源代码3 项目: Nimingban   文件: TransportableHttpCookie.java
public static List<TransportableHttpCookie> from(URL url, List<HttpCookieWithId> list) {
    List<TransportableHttpCookie> result = new ArrayList<>(list.size());
    for (HttpCookieWithId hcwi : list) {
        HttpCookie cookie = hcwi.httpCookie;
        TransportableHttpCookie thc = new TransportableHttpCookie();
        thc.name = cookie.getName();
        thc.value = cookie.getValue();
        thc.comment = cookie.getComment();
        thc.commentURL = cookie.getCommentURL();
        thc.discard = cookie.getDiscard();
        thc.domain = cookie.getDomain();
        thc.maxAge = cookie.getMaxAge();
        thc.path = cookie.getPath();
        thc.portList = cookie.getPortlist();
        thc.secure = cookie.getSecure();
        thc.version = cookie.getVersion();
        thc.url = url.toString();
        result.add(thc);
    }
    return result;
}
 
源代码4 项目: NoHttp   文件: CookieEntity.java
/**
 * Cookie building database entities.
 *
 * @param uri    cookie corresponding uri.
 * @param cookie cookie.
 */
public CookieEntity(URI uri, HttpCookie cookie) {
    this.uri = uri == null ? null : uri.toString();
    this.name = cookie.getName();
    this.value = cookie.getValue();
    this.comment = cookie.getComment();
    this.commentURL = cookie.getCommentURL();
    this.discard = cookie.getDiscard();
    this.domain = cookie.getDomain();
    long maxAge = cookie.getMaxAge();
    if (maxAge != -1 && maxAge > 0) {
        this.expiry = (maxAge * 1000L) + System.currentTimeMillis();
        if (this.expiry < 0L) // 溢出
            this.expiry = HeaderUtils.getMaxExpiryMillis();
    } else
        this.expiry = -1L;

    this.path = cookie.getPath();
    if (!TextUtils.isEmpty(path) && path.length() > 1 && path.endsWith("/")) {
        this.path = path.substring(0, path.length() - 1);
    }
    this.portList = cookie.getPortlist();
    this.secure = cookie.getSecure();
    this.version = cookie.getVersion();
}
 
源代码5 项目: rest-client   文件: RESTViewImpl.java
@Override
public void setUIFromRequest(final Request request){
    // Clear first
    clearUIRequest();

    // URL
    jp_url_go.setUrlString(request.getUrl().toString());

    // Method
    final HTTPMethod reqMethod = request.getMethod();
    jp_req_method.setSelectedMethod(reqMethod);

    // Headers
    MultiValueMap<String, String> headers = request.getHeaders();
    jp_2col_req_headers.setData(headers);
    
    // Cookies
    List<HttpCookie> cookies = request.getCookies();
    MultiValueMap<String, String> cookiesMap = new MultiValueMapArrayList<>();
    
    int version = CookieVersion.DEFAULT_VERSION.getIntValue();
    for(HttpCookie cookie: cookies) {
        cookiesMap.put(cookie.getName(), cookie.getValue());
        version = cookie.getVersion();
    }
    jp_2col_req_cookies.setData(cookiesMap);
    
    // Cookie version
    jp_req_etc.setCookieVersion(CookieVersion.getValue(version));
    
    // Body
    ReqEntity body = request.getBody();
    if(body != null){
        if(jp_req_method.doesSelectedMethodSupportEntityBody()){
            jp_req_body.enableBody();
        }
        jp_req_body.setEntity(body);
    }

    // Authentication
    if(request.getAuth() != null) {
        jp_req_auth.setAuth(request.getAuth());
    }

    // SSL
    if(request.getSslReq() != null) {
        jp_req_ssl.setSslReq(request.getSslReq());
    }

    // HTTP Version
    if(request.getHttpVersion() == HTTPVersion.HTTP_1_1){
        jp_req_etc.setHttpVersion(HTTPVersion.HTTP_1_1);
    }
    else if(request.getHttpVersion() == HTTPVersion.HTTP_1_0){
        jp_req_etc.setHttpVersion(HTTPVersion.HTTP_1_0);
    }

    // Follow redirect
    jp_req_etc.setFollowRedirects(request.isFollowRedirect());
    
    // Ignore response body
    jp_req_etc.setIgnoreResponseBody(request.isIgnoreResponseBody());

    // Test script
    jp_req_test.setTestScript(request.getTestScript()==null?"":request.getTestScript());
}