okhttp3.Cookie.persistent()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(281)

本文整理了Java中okhttp3.Cookie.persistent()方法的一些代码示例,展示了Cookie.persistent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cookie.persistent()方法的具体详情如下:
包路径:okhttp3.Cookie
类名称:Cookie
方法名:persistent

Cookie.persistent介绍

[英]Returns true if this cookie expires at the end of the current session.
[中]如果此cookie在当前会话结束时过期,则返回true。

代码示例

代码示例来源:origin: GitLqr/LQRWeChat

private static List<Cookie> filterPersistentCookies(List<Cookie> cookies) {
  List<Cookie> persistentCookies = new ArrayList<>();
  for (Cookie cookie : cookies) {
    if (cookie.persistent()) {
      persistentCookies.add(cookie);
    }
  }
  return persistentCookies;
}

代码示例来源:origin: jeasonlzy/okhttp-OkGo

private void writeObject(ObjectOutputStream out) throws IOException {
  out.defaultWriteObject();
  out.writeObject(cookie.name());
  out.writeObject(cookie.value());
  out.writeLong(cookie.expiresAt());
  out.writeObject(cookie.domain());
  out.writeObject(cookie.path());
  out.writeBoolean(cookie.secure());
  out.writeBoolean(cookie.httpOnly());
  out.writeBoolean(cookie.hostOnly());
  out.writeBoolean(cookie.persistent());
}

代码示例来源:origin: seven332/EhViewer

public ContentValues toContentValues(Cookie cookie) {
 ContentValues contentValues = new ContentValues(9);
 contentValues.put(COLUMN_NAME, cookie.name());
 contentValues.put(COLUMN_VALUE, cookie.value());
 contentValues.put(COLUMN_EXPIRES_AT, cookie.expiresAt());
 contentValues.put(COLUMN_DOMAIN, cookie.domain());
 contentValues.put(COLUMN_PATH, cookie.path());
 contentValues.put(COLUMN_SECURE, cookie.secure());
 contentValues.put(COLUMN_HTTP_ONLY, cookie.httpOnly());
 contentValues.put(COLUMN_PERSISTENT, cookie.persistent());
 contentValues.put(COLUMN_HOST_ONLY, cookie.hostOnly());
 return contentValues;
}

代码示例来源:origin: GitLqr/LQRWeChat

private void writeObject(ObjectOutputStream out) throws IOException {
  out.writeObject(cookie.name());
  out.writeObject(cookie.value());
  out.writeLong(cookie.persistent() ? cookie.expiresAt() : NON_VALID_EXPIRES_AT);
  out.writeObject(cookie.domain());
  out.writeObject(cookie.path());
  out.writeBoolean(cookie.secure());
  out.writeBoolean(cookie.httpOnly());
  out.writeBoolean(cookie.hostOnly());
}

代码示例来源:origin: seven332/EhViewer

public synchronized List<Cookie> getCookies(HttpUrl url) {
 List<Cookie> accepted = new ArrayList<>();
 List<Cookie> expired = new ArrayList<>();
 for (Map.Entry<String, CookieSet> entry : map.entrySet()) {
  String domain = entry.getKey();
  CookieSet cookieSet = entry.getValue();
  if (domainMatch(url, domain)) {
   cookieSet.get(url, accepted, expired);
  }
 }
 for (Cookie cookie : expired) {
  if (cookie.persistent()) {
   db.remove(cookie);
  }
 }
 // RFC 6265 Section-5.4 step 2, sort the cookie-list
 // Cookies with longer paths are listed before cookies with shorter paths.
 // Ignore creation-time, we don't store them.
 Collections.sort(accepted, new Comparator<Cookie>() {
  @Override
  public int compare(Cookie o1, Cookie o2) {
   return o2.path().length() - o1.path().length();
  }
 });
 return accepted;
}

代码示例来源:origin: seven332/EhViewer

toRemove = set.remove(cookie);
if (toRemove != null && !toRemove.persistent()) {
 toRemove = null;
toUpdate = set.add(cookie);
if (!toAdd.persistent()) toAdd = null;
if (toUpdate != null && !toUpdate.persistent()) toUpdate = null;

代码示例来源:origin: franmontiel/PersistentCookieJar

private static List<Cookie> filterPersistentCookies(List<Cookie> cookies) {
  List<Cookie> persistentCookies = new ArrayList<>();
  for (Cookie cookie : cookies) {
    if (cookie.persistent()) {
      persistentCookies.add(cookie);
    }
  }
  return persistentCookies;
}

代码示例来源:origin: seven332/EhViewer

public static Cookie newCookie(Cookie cookie, String newDomain, boolean forcePersistent,
    boolean forceLongLive, boolean forceNotHostOnly) {
  Cookie.Builder builder = new Cookie.Builder();
  builder.name(cookie.name());
  builder.value(cookie.value());
  if (forceLongLive) {
    builder.expiresAt(Long.MAX_VALUE);
  } else if (cookie.persistent()) {
    builder.expiresAt(cookie.expiresAt());
  } else if (forcePersistent) {
    builder.expiresAt(Long.MAX_VALUE);
  }
  if (cookie.hostOnly() && !forceNotHostOnly) {
    builder.hostOnlyDomain(newDomain);
  } else {
    builder.domain(newDomain);
  }
  builder.path(cookie.path());
  if (cookie.secure()) {
    builder.secure();
  }
  if (cookie.httpOnly()) {
    builder.httpOnly();
  }
  return builder.build();
}

代码示例来源:origin: franmontiel/PersistentCookieJar

private void writeObject(ObjectOutputStream out) throws IOException {
  out.writeObject(cookie.name());
  out.writeObject(cookie.value());
  out.writeLong(cookie.persistent() ? cookie.expiresAt() : NON_VALID_EXPIRES_AT);
  out.writeObject(cookie.domain());
  out.writeObject(cookie.path());
  out.writeBoolean(cookie.secure());
  out.writeBoolean(cookie.httpOnly());
  out.writeBoolean(cookie.hostOnly());
}

代码示例来源:origin: limedroid/XDroidMvp

private void writeObject(ObjectOutputStream out) throws IOException {
  out.writeObject(cookie.name());
  out.writeObject(cookie.value());
  out.writeLong(cookie.expiresAt());
  out.writeObject(cookie.domain());
  out.writeObject(cookie.path());
  out.writeBoolean(cookie.secure());
  out.writeBoolean(cookie.httpOnly());
  out.writeBoolean(cookie.hostOnly());
  out.writeBoolean(cookie.persistent());
}

代码示例来源:origin: limedroid/XDroidMvp

protected void add(HttpUrl uri, Cookie cookie) {
  String name = getCookieToken(cookie);
  if (cookie.persistent()) {
    if (!cookies.containsKey(uri.host())) {
      cookies.put(uri.host(), new ConcurrentHashMap<String, Cookie>());
    }
    cookies.get(uri.host()).put(name, cookie);
  } else {
    if (cookies.containsKey(uri.host())) {
      cookies.get(uri.host()).remove(name);
    } else {
      return;
    }
  }
  // Save cookie into persistent store
  SharedPreferences.Editor prefsWriter = cookiePrefs.edit();
  prefsWriter.putString(uri.host(), TextUtils.join(",", cookies.get(uri.host()).keySet()));
  prefsWriter.putString(COOKIE_NAME_PREFIX + name, encodeCookie(new SerializableHttpCookie(cookie)));
  prefsWriter.apply();
}

代码示例来源:origin: FussenYu/MVP_Project

private static List<Cookie> filterPersistentCookies(List<Cookie> cookies) {
  List<Cookie> persistentCookies = new ArrayList<>();
  for (Cookie cookie : cookies) {
    Log.i(TAG,"=====cookie===="+ cookie.toString());
    if (cookie.persistent()) {
      persistentCookies.add(cookie);
    }
  }
  return persistentCookies;
}

代码示例来源:origin: lygttpod/RxHttpUtils

private void writeObject(ObjectOutputStream out) throws IOException {
  out.defaultWriteObject();
  out.writeObject(cookie.name());
  out.writeObject(cookie.value());
  out.writeLong(cookie.expiresAt());
  out.writeObject(cookie.domain());
  out.writeObject(cookie.path());
  out.writeBoolean(cookie.secure());
  out.writeBoolean(cookie.httpOnly());
  out.writeBoolean(cookie.hostOnly());
  out.writeBoolean(cookie.persistent());
}

代码示例来源:origin: yoyiyi/bilisoleil

private void writeObject(ObjectOutputStream out) throws IOException {
  out.defaultWriteObject();
  out.writeObject(cookie.name());
  out.writeObject(cookie.value());
  out.writeLong(cookie.expiresAt());
  out.writeObject(cookie.domain());
  out.writeObject(cookie.path());
  out.writeBoolean(cookie.secure());
  out.writeBoolean(cookie.httpOnly());
  out.writeBoolean(cookie.hostOnly());
  out.writeBoolean(cookie.persistent());
}

代码示例来源:origin: 0xm1nam0/RxCore

private void writeObject(ObjectOutputStream out) throws IOException {
  out.writeObject(cookie.name());
  out.writeObject(cookie.value());
  out.writeLong(cookie.expiresAt());
  out.writeObject(cookie.domain());
  out.writeObject(cookie.path());
  out.writeBoolean(cookie.secure());
  out.writeBoolean(cookie.httpOnly());
  out.writeBoolean(cookie.hostOnly());
  out.writeBoolean(cookie.persistent());
}

代码示例来源:origin: jinguangyue/Android-CustomCamera

private void writeObject(ObjectOutputStream out) throws IOException {
  out.writeObject(cookie.name());
  out.writeObject(cookie.value());
  out.writeLong(cookie.expiresAt());
  out.writeObject(cookie.domain());
  out.writeObject(cookie.path());
  out.writeBoolean(cookie.secure());
  out.writeBoolean(cookie.httpOnly());
  out.writeBoolean(cookie.hostOnly());
  out.writeBoolean(cookie.persistent());
}

代码示例来源:origin: guanpj/JReadHub

private void writeObject(ObjectOutputStream out) throws IOException {
  out.writeObject(cookies.name());
  out.writeObject(cookies.value());
  out.writeLong(cookies.expiresAt());
  out.writeObject(cookies.domain());
  out.writeObject(cookies.path());
  out.writeBoolean(cookies.secure());
  out.writeBoolean(cookies.httpOnly());
  out.writeBoolean(cookies.hostOnly());
  out.writeBoolean(cookies.persistent());
}

代码示例来源:origin: com.couchbase.lite/couchbase-lite-java-core

private void writeObject(ObjectOutputStream out) throws IOException {
  out.writeObject(cookie.name());
  out.writeObject(cookie.value());
  out.writeLong(cookie.persistent() ? cookie.expiresAt() : NON_VALID_EXPIRES_AT);
  out.writeObject(cookie.domain());
  out.writeObject(cookie.path());
  out.writeBoolean(cookie.secure());
  out.writeBoolean(cookie.httpOnly());
  out.writeBoolean(cookie.hostOnly());
}

代码示例来源:origin: huangweicai/OkLibDemo

private void writeObject(ObjectOutputStream out) throws IOException {
  out.writeObject(cookie.name());
  out.writeObject(cookie.value());
  out.writeLong(cookie.expiresAt());
  out.writeObject(cookie.domain());
  out.writeObject(cookie.path());
  out.writeBoolean(cookie.secure());
  out.writeBoolean(cookie.httpOnly());
  out.writeBoolean(cookie.hostOnly());
  out.writeBoolean(cookie.persistent());
}

代码示例来源:origin: couchbase/couchbase-lite-java-core

private void writeObject(ObjectOutputStream out) throws IOException {
  out.writeObject(cookie.name());
  out.writeObject(cookie.value());
  out.writeLong(cookie.persistent() ? cookie.expiresAt() : NON_VALID_EXPIRES_AT);
  out.writeObject(cookie.domain());
  out.writeObject(cookie.path());
  out.writeBoolean(cookie.secure());
  out.writeBoolean(cookie.httpOnly());
  out.writeBoolean(cookie.hostOnly());
}

相关文章