okhttp3.internal.http.HttpDate Java Examples
The following examples show how to use
okhttp3.internal.http.HttpDate.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Cookie.java From styT with Apache License 2.0 | 5 votes |
/** * @param forObsoleteRfc2965 true to include a leading {@code .} on the domain pattern. This is * necessary for {@code example.com} to match {@code www.example.com} under RFC 2965. This * extra dot is ignored by more recent specifications. */ String toString(boolean forObsoleteRfc2965) { StringBuilder result = new StringBuilder(); result.append(name); result.append('='); result.append(value); if (persistent) { if (expiresAt == Long.MIN_VALUE) { result.append("; max-age=0"); } else { result.append("; expires=").append(HttpDate.format(new Date(expiresAt))); } } if (!hostOnly) { result.append("; domain="); if (forObsoleteRfc2965) { result.append("."); } result.append(domain); } result.append("; path=").append(path); if (secure) { result.append("; secure"); } if (httpOnly) { result.append("; httponly"); } return result.toString(); }
Example #2
Source File: CacheStrategy.java From styT with Apache License 2.0 | 5 votes |
public Factory(long nowMillis, Request request, Response cacheResponse) { this.nowMillis = nowMillis; this.request = request; this.cacheResponse = cacheResponse; if (cacheResponse != null) { this.sentRequestMillis = cacheResponse.sentRequestAtMillis(); this.receivedResponseMillis = cacheResponse.receivedResponseAtMillis(); Headers headers = cacheResponse.headers(); for (int i = 0, size = headers.size(); i < size; i++) { String fieldName = headers.name(i); String value = headers.value(i); if ("Date".equalsIgnoreCase(fieldName)) { servedDate = HttpDate.parse(value); servedDateString = value; } else if ("Expires".equalsIgnoreCase(fieldName)) { expires = HttpDate.parse(value); } else if ("Last-Modified".equalsIgnoreCase(fieldName)) { lastModified = HttpDate.parse(value); lastModifiedString = value; } else if ("ETag".equalsIgnoreCase(fieldName)) { etag = value; } else if ("Age".equalsIgnoreCase(fieldName)) { ageSeconds = HttpHeaders.parseSeconds(value, -1); } } } }
Example #3
Source File: Cookie.java From AndroidProjects with MIT License | 5 votes |
/** * @param forObsoleteRfc2965 true to include a leading {@code .} on the domain pattern. This is * necessary for {@code example.com} to match {@code www.example.com} under RFC 2965. This * extra dot is ignored by more recent specifications. */ String toString(boolean forObsoleteRfc2965) { StringBuilder result = new StringBuilder(); result.append(name); result.append('='); result.append(value); if (persistent) { if (expiresAt == Long.MIN_VALUE) { result.append("; max-age=0"); } else { result.append("; expires=").append(HttpDate.format(new Date(expiresAt))); } } if (!hostOnly) { result.append("; domain="); if (forObsoleteRfc2965) { result.append("."); } result.append(domain); } result.append("; path=").append(path); if (secure) { result.append("; secure"); } if (httpOnly) { result.append("; httponly"); } return result.toString(); }
Example #4
Source File: CacheStrategy.java From AndroidProjects with MIT License | 5 votes |
public Factory(long nowMillis, Request request, Response cacheResponse) { this.nowMillis = nowMillis; this.request = request; this.cacheResponse = cacheResponse; if (cacheResponse != null) { this.sentRequestMillis = cacheResponse.sentRequestAtMillis(); this.receivedResponseMillis = cacheResponse.receivedResponseAtMillis(); Headers headers = cacheResponse.headers(); for (int i = 0, size = headers.size(); i < size; i++) { String fieldName = headers.name(i); String value = headers.value(i); if ("Date".equalsIgnoreCase(fieldName)) { servedDate = HttpDate.parse(value); servedDateString = value; } else if ("Expires".equalsIgnoreCase(fieldName)) { expires = HttpDate.parse(value); } else if ("Last-Modified".equalsIgnoreCase(fieldName)) { lastModified = HttpDate.parse(value); lastModifiedString = value; } else if ("ETag".equalsIgnoreCase(fieldName)) { etag = value; } else if ("Age".equalsIgnoreCase(fieldName)) { ageSeconds = HttpHeaders.parseSeconds(value, -1); } } } }
Example #5
Source File: Headers.java From styT with Apache License 2.0 | 4 votes |
/** * Returns the last value corresponding to the specified field parsed as an HTTP date, or null if * either the field is absent or cannot be parsed as a date. */ public Date getDate(String name) { String value = get(name); return value != null ? HttpDate.parse(value) : null; }
Example #6
Source File: Headers.java From AndroidProjects with MIT License | 4 votes |
/** * Returns the last value corresponding to the specified field parsed as an HTTP date, or null if * either the field is absent or cannot be parsed as a date. */ public Date getDate(String name) { String value = get(name); return value != null ? HttpDate.parse(value) : null; }