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

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

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

Cookie.value介绍

[英]Returns a possibly-empty string with this cookie's value.
[中]返回具有此cookie值的可能为空字符串。

代码示例

代码示例来源:origin: square/okhttp

/** Returns a 'Cookie' HTTP request header with all cookies, like {@code a=b; c=d}. */
 private String cookieHeader(List<Cookie> cookies) {
  StringBuilder cookieHeader = new StringBuilder();
  for (int i = 0, size = cookies.size(); i < size; i++) {
   if (i > 0) {
    cookieHeader.append("; ");
   }
   Cookie cookie = cookies.get(i);
   cookieHeader.append(cookie.name()).append('=').append(cookie.value());
  }
  return cookieHeader.toString();
 }
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

/** Returns a 'Cookie' HTTP request header with all cookies, like {@code a=b; c=d}. */
 private String cookieHeader(List<Cookie> cookies) {
  StringBuilder cookieHeader = new StringBuilder();
  for (int i = 0, size = cookies.size(); i < size; i++) {
   if (i > 0) {
    cookieHeader.append("; ");
   }
   Cookie cookie = cookies.get(i);
   cookieHeader.append(cookie.name()).append('=').append(cookie.value());
  }
  return cookieHeader.toString();
 }
}

代码示例来源:origin: biezhi/wechat-api

public String cookie(String name) {
  for (Cookie cookie : cookies()) {
    if (cookie.name().equalsIgnoreCase(name)) {
      return cookie.value();
    }
  }
  return null;
}

代码示例来源: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: TommyLemon/Android-ZBLibrary

@Override
public void saveFromResponse(HttpUrl url, List<Cookie> cookies) {
  Map<String, String> map = new LinkedHashMap<>();
  if (cookies != null) {
    for (Cookie c : cookies) {
      if (c != null && c.name() != null && c.value() != null) {
        map.put(c.name(), StringUtil.get(c.value()));
      }
    }
  }
  saveCookie(url == null ? null : url.host(), JSON.toJSONString(map));//default constructor not found  cookies));
}

代码示例来源: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

switch (cookie.name()) {
  case EhCookieStore.KEY_IPD_MEMBER_ID:
    ipbMemberId = cookie.value();
    break;
  case EhCookieStore.KEY_IPD_PASS_HASH:
    ipbPassHash = cookie.value();
    break;
  case EhCookieStore.KEY_IGNEOUS:
    igneous = cookie.value();
    break;

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

private Cookie longLive(Cookie cookie) {
 return new Cookie.Builder()
   .name(cookie.name())
   .value(cookie.value())
   .domain(cookie.domain())
   .path(cookie.path())
   .expiresAt(Long.MAX_VALUE)
   .build();
}

代码示例来源: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: duzechao/OKHttpUtils

/** Returns a 'Cookie' HTTP request header with all cookies, like {@code a=b; c=d}. */
private String cookieHeader(List<Cookie> cookies) {
 StringBuilder cookieHeader = new StringBuilder();
 for (int i = 0, size = cookies.size(); i < size; i++) {
  if (i > 0) {
   cookieHeader.append("; ");
  }
  Cookie cookie = cookies.get(i);
  cookieHeader.append(cookie.name()).append('=').append(cookie.value());
 }
 return cookieHeader.toString();
}

代码示例来源:origin: czp3009/bilibili-api

public String getCookiesStringForHost(String host) {
  return getCookiesForHost(host).stream()
      .map(cookie -> String.format("%s=%s", cookie.name(), cookie.value()))
      .collect(Collectors.joining(";"));
}

代码示例来源: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: 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: 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: 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: 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());
}

相关文章