org.apache.http.impl.cookie.DateParseException Java Examples
The following examples show how to use
org.apache.http.impl.cookie.DateParseException.
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: CachingHttpClient.java From apigee-android-sdk with Apache License 2.0 | 6 votes |
private boolean alreadyHaveNewerCacheEntry(HttpHost target, HttpRequest request, HttpResponse backendResponse) throws IOException { HttpCacheEntry existing = null; try { existing = responseCache.getCacheEntry(target, request); } catch (IOException ioe) { // nop } if (existing == null) return false; Header entryDateHeader = existing.getFirstHeader("Date"); if (entryDateHeader == null) return false; Header responseDateHeader = backendResponse.getFirstHeader("Date"); if (responseDateHeader == null) return false; try { Date entryDate = DateUtils.parseDate(entryDateHeader.getValue()); Date responseDate = DateUtils.parseDate(responseDateHeader .getValue()); return responseDate.before(entryDate); } catch (DateParseException e) { } return false; }
Example #2
Source File: CacheEntryUpdater.java From apigee-android-sdk with Apache License 2.0 | 6 votes |
private boolean entryDateHeaderNewerThenResponse(HttpCacheEntry entry, HttpResponse response) { try { Date entryDate = DateUtils.parseDate(entry.getFirstHeader( HTTP.DATE_HEADER).getValue()); Date responseDate = DateUtils.parseDate(response.getFirstHeader( HTTP.DATE_HEADER).getValue()); if (!entryDate.after(responseDate)) { return false; } } catch (DateParseException e) { return false; } return true; }
Example #3
Source File: HttpHeaderParser.java From jus with Apache License 2.0 | 5 votes |
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
Example #4
Source File: WarningValue.java From apigee-android-sdk with Apache License 2.0 | 5 votes |
protected void consumeWarnDate() { int curr = offs; Matcher m = WARN_DATE_PATTERN.matcher(src.substring(offs)); if (!m.lookingAt()) parseError(); offs += m.end(); try { warnDate = DateUtils.parseDate(src.substring(curr + 1, offs - 1)); } catch (DateParseException e) { throw new IllegalStateException("couldn't parse a parseable date"); } }
Example #5
Source File: CachedResponseSuitabilityChecker.java From apigee-android-sdk with Apache License 2.0 | 5 votes |
private boolean hasValidDateField(HttpRequest request, String headerName) { for (Header h : request.getHeaders(headerName)) { try { DateUtils.parseDate(h.getValue()); return true; } catch (DateParseException dpe) { // ignore malformed dates } } return false; }
Example #6
Source File: CacheValidityPolicy.java From apigee-android-sdk with Apache License 2.0 | 5 votes |
protected Date getExpirationDate(final HttpCacheEntry entry) { Header expiresHeader = entry.getFirstHeader(HeaderConstants.EXPIRES); if (expiresHeader == null) return null; try { return DateUtils.parseDate(expiresHeader.getValue()); } catch (DateParseException dpe) { // malformed expires header } return null; }
Example #7
Source File: CacheValidityPolicy.java From apigee-android-sdk with Apache License 2.0 | 5 votes |
protected Date getLastModifiedValue(final HttpCacheEntry entry) { Header dateHdr = entry.getFirstHeader(HeaderConstants.LAST_MODIFIED); if (dateHdr == null) return null; try { return DateUtils.parseDate(dateHdr.getValue()); } catch (DateParseException dpe) { // ignore malformed date } return null; }
Example #8
Source File: CacheValidityPolicy.java From apigee-android-sdk with Apache License 2.0 | 5 votes |
protected Date getDateValue(final HttpCacheEntry entry) { Header dateHdr = entry.getFirstHeader(HTTP.DATE_HEADER); if (dateHdr == null) return null; try { return DateUtils.parseDate(dateHdr.getValue()); } catch (DateParseException dpe) { // ignore malformed date } return null; }
Example #9
Source File: HttpHeaderParser.java From CrossBow with Apache License 2.0 | 5 votes |
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
Example #10
Source File: HttpHeaderParser.java From WayHoo with Apache License 2.0 | 5 votes |
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
Example #11
Source File: HttpHeaderParser.java From barterli_android with Apache License 2.0 | 5 votes |
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
Example #12
Source File: HttpHeaderParser.java From android_tv_metro with Apache License 2.0 | 5 votes |
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
Example #13
Source File: HttpHeaderParser.java From FeedListViewDemo with MIT License | 5 votes |
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
Example #14
Source File: HttpHeaderParser.java From okulus with Apache License 2.0 | 5 votes |
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
Example #15
Source File: HttpHeaderParser.java From Android-Application-ZJB with Apache License 2.0 | 5 votes |
public static long parseDateAsEpoch(String dateStr) { try { return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException var2) { return 0L; } }
Example #16
Source File: HttpHeaderParser.java From volley with Apache License 2.0 | 5 votes |
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
Example #17
Source File: HttpHeaderParser.java From volley_demo with Apache License 2.0 | 5 votes |
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
Example #18
Source File: HttpHeaderParser.java From DaVinci with Apache License 2.0 | 5 votes |
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
Example #19
Source File: HttpHeaderParser.java From product-emm with Apache License 2.0 | 5 votes |
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
Example #20
Source File: HttpHeaderParser.java From product-emm with Apache License 2.0 | 5 votes |
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
Example #21
Source File: HttpHeaderParser.java From android-discourse with Apache License 2.0 | 5 votes |
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
Example #22
Source File: HttpHeaderParser.java From TitanjumNote with Apache License 2.0 | 5 votes |
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
Example #23
Source File: HttpHeaderParser.java From android-common-utils with Apache License 2.0 | 5 votes |
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
Example #24
Source File: HttpHeaderParser.java From SimplifyReader with Apache License 2.0 | 5 votes |
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
Example #25
Source File: HttpHeaderParser.java From android-project-wo2b with Apache License 2.0 | 5 votes |
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
Example #26
Source File: HttpHeaderParser.java From SaveVolley with Apache License 2.0 | 5 votes |
/** * Parse date in RFC1123 format, and return its value as epoch */ /* * 解析时间,将 RFC1123 的时间格式,解析成 epoch 时间 */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one // 耦合了 Apache 的时间工具类 return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
Example #27
Source File: HttpHeaderParser.java From device-database with Apache License 2.0 | 5 votes |
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
Example #28
Source File: HttpHeaderParser.java From AndroidProjects with MIT License | 5 votes |
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
Example #29
Source File: HttpHeaderParser.java From pearl with Apache License 2.0 | 5 votes |
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
Example #30
Source File: ResponseCachingPolicy.java From apigee-android-sdk with Apache License 2.0 | 4 votes |
/** * Determines if an HttpResponse can be cached. * * @param httpMethod * What type of request was this, a GET, PUT, other? * @param response * The origin response * @return <code>true</code> if response is cacheable */ public boolean isResponseCacheable(String httpMethod, HttpResponse response) { boolean cacheable = false; if (!HeaderConstants.GET_METHOD.equals(httpMethod)) { log.debug("Response was not cacheable."); return false; } switch (response.getStatusLine().getStatusCode()) { case HttpStatus.SC_OK: case HttpStatus.SC_NON_AUTHORITATIVE_INFORMATION: case HttpStatus.SC_MULTIPLE_CHOICES: case HttpStatus.SC_MOVED_PERMANENTLY: case HttpStatus.SC_GONE: // these response codes MAY be cached cacheable = true; log.debug("Response was cacheable"); break; case HttpStatus.SC_PARTIAL_CONTENT: // we don't implement Range requests and hence are not // allowed to cache partial content log.debug("Response was not cacheable (Partial Content)"); return cacheable; default: // If the status code is not one of the recognized // available codes in HttpStatus Don't Cache log.debug("Response was not cacheable (Unknown Status code)"); return cacheable; } Header contentLength = response.getFirstHeader(HTTP.CONTENT_LEN); if (contentLength != null) { int contentLengthValue = Integer.parseInt(contentLength.getValue()); if (contentLengthValue > this.maxObjectSizeBytes) return false; } Header[] ageHeaders = response.getHeaders(HeaderConstants.AGE); if (ageHeaders.length > 1) return false; Header[] expiresHeaders = response.getHeaders(HeaderConstants.EXPIRES); if (expiresHeaders.length > 1) return false; Header[] dateHeaders = response.getHeaders(HTTP.DATE_HEADER); if (dateHeaders.length != 1) return false; try { DateUtils.parseDate(dateHeaders[0].getValue()); } catch (DateParseException dpe) { return false; } for (Header varyHdr : response.getHeaders(HeaderConstants.VARY)) { for (HeaderElement elem : varyHdr.getElements()) { if ("*".equals(elem.getName())) { return false; } } } if (isExplicitlyNonCacheable(response)) return false; return (cacheable || isExplicitlyCacheable(response)); }