getPath ( )源码实例Demo

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

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

源代码1 项目: Kalle   文件: CookieManager.java
/**
 * Cookie for the specified URI to save, where path and port will be verified.
 *
 * @param uri        uri.
 * @param cookieList all you want to save the Cookie, does not meet the rules will not be saved.
 */
public void add(URI uri, List<String> cookieList) {
    for (String cookieValue : cookieList) {
        List<HttpCookie> cookies = HttpCookie.parse(cookieValue);
        for (HttpCookie cookie : cookies) {
            if (cookie.getPath() == null) {
                String path = normalizePath(uri.getPath());
                cookie.setPath(path);
            } else if (!pathMatches(uri, cookie)) {
                continue;
            }

            if (cookie.getDomain() == null) cookie.setDomain(uri.getHost());

            String portList = cookie.getPortlist();
            int port = getPort(uri);
            if (TextUtils.isEmpty(portList) || containsPort(portList, port)) {
                cookieJar.add(uri, cookie);
            }
        }
    }
}
 
源代码2 项目: Kalle   文件: DBCookieStore.java
@Override
public void remove(HttpCookie httpCookie) {
    mLock.lock();
    try {
        Where.Builder whereBuilder = Where.newBuilder().add(NAME, Where.Options.EQUAL, httpCookie.getName());

        String domain = httpCookie.getDomain();
        if (!TextUtils.isEmpty(domain)) whereBuilder.and(DOMAIN, Where.Options.EQUAL, domain);

        String path = httpCookie.getPath();
        if (!TextUtils.isEmpty(path)) {
            if (path.length() > 1 && path.endsWith("/")) {
                path = path.substring(0, path.length() - 1);
            }
            whereBuilder.and(PATH, Where.Options.EQUAL, path);
        }
        mCookieDao.delete(whereBuilder.build().toString());
    } finally {
        mLock.unlock();
    }
}
 
源代码3 项目: Nimingban   文件: CookieDBJar.java
private Cookie httpCookie2Cookie(URL url, HttpCookie httpCookie) {
    String domain = httpCookie.getDomain();
    String path = httpCookie.getPath();
    if (TextUtils.isEmpty(domain)) {
        domain = url.getHost();
    }
    if (TextUtils.isEmpty(path)) {
        path = url.getPath();
    }

    Cookie.Builder builder = new Cookie.Builder()
            .name(httpCookie.getName())
            .value(httpCookie.getValue())
            .expiresAt(System.currentTimeMillis() + (httpCookie.getMaxAge() * 1000))
            .domain(domain)
            .path(path);
    if (httpCookie.getSecure()) {
        builder.secure();
    }
    return builder.build();
}
 
源代码4 项目: 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;
}
 
源代码5 项目: 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();
}
 
源代码6 项目: NoHttp   文件: DBCookieStore.java
@Override
public boolean remove(URI uri, HttpCookie httpCookie) {
    checkInitialization();

    mLock.lock();
    try {
        if (httpCookie == null || !isEnable()) return true;
        if (mCookieStoreListener != null) mCookieStoreListener.onRemoveCookie(uri, httpCookie);
        Where where = new Where(CookieSQLHelper.NAME, Options.EQUAL, httpCookie.getName());

        String domain = httpCookie.getDomain();
        if (!TextUtils.isEmpty(domain)) where.and(CookieSQLHelper.DOMAIN, Options.EQUAL, domain);

        String path = httpCookie.getPath();
        if (!TextUtils.isEmpty(path)) {
            if (path.length() > 1 && path.endsWith("/")) {
                path = path.substring(0, path.length() - 1);
            }
            where.and(CookieSQLHelper.PATH, Options.EQUAL, path);
        }
        return mCookieEntityDao.delete(where.toString());
    } finally {
        mLock.unlock();
    }
}
 
源代码7 项目: Kalle   文件: Cookie.java
public static Cookie toCookie(String url, HttpCookie httpCookie) {
    Cookie cookie = new Cookie();
    cookie.setUrl(url);
    cookie.setName(httpCookie.getName());
    cookie.setValue(httpCookie.getValue());
    cookie.setComment(httpCookie.getComment());
    cookie.setCommentURL(httpCookie.getCommentURL());
    cookie.setDiscard(httpCookie.getDiscard());
    cookie.setDomain(httpCookie.getDomain());
    long maxAge = httpCookie.getMaxAge();
    if (maxAge > 0) {
        long expiry = (maxAge * 1000L) + System.currentTimeMillis();
        if (expiry < 0L) {
            expiry = System.currentTimeMillis() + 100L * 365L * 24L * 60L * 60L * 1000L;
        }
        cookie.setExpiry(expiry);
    } else if (maxAge < 0) {
        cookie.setExpiry(-1);
    } else {
        cookie.setExpiry(0);
    }

    String path = httpCookie.getPath();
    if (!TextUtils.isEmpty(path) && path.length() > 1 && path.endsWith("/")) {
        path = path.substring(0, path.length() - 1);
    }
    cookie.setPath(path);
    cookie.setPortList(httpCookie.getPortlist());
    cookie.setSecure(httpCookie.getSecure());
    cookie.setVersion(httpCookie.getVersion());
    return cookie;
}
 
源代码8 项目: SimpleProject   文件: CookieAdapter.java
public CookieAdapter(HttpCookie cookie) {
	this.name = cookie.getName();
	this.value = cookie.getValue();
	this.domain = cookie.getDomain();
	this.path = cookie.getPath();
	this.secure = cookie.getSecure();
}
 
源代码9 项目: hadoop   文件: TestAuthenticationFilter.java
private static void parseCookieMap(String cookieHeader, HashMap<String,
        String> cookieMap) {
  List<HttpCookie> cookies = HttpCookie.parse(cookieHeader);
  for (HttpCookie cookie : cookies) {
    if (AuthenticatedURL.AUTH_COOKIE.equals(cookie.getName())) {
      cookieMap.put(cookie.getName(), cookie.getValue());
      if (cookie.getPath() != null) {
        cookieMap.put("Path", cookie.getPath());
      }
      if (cookie.getDomain() != null) {
        cookieMap.put("Domain", cookie.getDomain());
      }
    }
  }
}
 
源代码10 项目: big-c   文件: TestAuthenticationFilter.java
private static void parseCookieMap(String cookieHeader, HashMap<String,
        String> cookieMap) {
  List<HttpCookie> cookies = HttpCookie.parse(cookieHeader);
  for (HttpCookie cookie : cookies) {
    if (AuthenticatedURL.AUTH_COOKIE.equals(cookie.getName())) {
      cookieMap.put(cookie.getName(), cookie.getValue());
      if (cookie.getPath() != null) {
        cookieMap.put("Path", cookie.getPath());
      }
      if (cookie.getDomain() != null) {
        cookieMap.put("Domain", cookie.getDomain());
      }
    }
  }
}
 
源代码11 项目: registry   文件: TestAuthenticationFilter.java
private static void parseCookieMap(String cookieHeader, HashMap<String,
        String> cookieMap) {
    List<HttpCookie> cookies = HttpCookie.parse(cookieHeader);
    for (HttpCookie cookie : cookies) {
        if (AuthenticatedURL.AUTH_COOKIE.equals(cookie.getName())) {
            cookieMap.put(cookie.getName(), cookie.getValue());
            if (cookie.getPath() != null) {
                cookieMap.put("Path", cookie.getPath());
            }
            if (cookie.getDomain() != null) {
                cookieMap.put("Domain", cookie.getDomain());
            }
        }
    }
}
 
源代码12 项目: http-builder-ng   文件: UriBuilder.java
public URI forCookie(final HttpCookie cookie) throws URISyntaxException {
    final String scheme = traverse(this, UriBuilder::getParent, UriBuilder::getScheme, Traverser::notNull);
    final Integer port = traverse(this, UriBuilder::getParent, UriBuilder::getPort, notValue(DEFAULT_PORT));
    final String host = traverse(this, UriBuilder::getParent, UriBuilder::getHost, Traverser::notNull);
    final String path = cookie.getPath();
    final String query = null;
    final String fragment = null;
    final String userInfo = null;

    return new URI(scheme, userInfo, host, (port == null ? -1 : port), path, query, fragment);
}
 
源代码13 项目: http-builder-ng   文件: NonBlockingCookieStore.java
public DomainKey(final HttpCookie cookie) {
    super(cookie.getName());
    this.domain = cookie.getDomain();
    this.path = cookie.getPath();
}