예제 #1
0
  public NextHeaders(Map<String, List<String>> rawHeaders) {
    this.rawHeaders = rawHeaders;

    for (String key : rawHeaders.keySet()) {
      String value = rawHeaders.get(key).get(0);
      if (CACHE_CONTROL.equalsIgnoreCase(key)) {
        cacheControl = value;
      } else if (DATE.equalsIgnoreCase(key)) {
        servedDate = DateParser.parse(value);
      } else if (EXPIRES.equalsIgnoreCase(key)) {
        expires = DateParser.parse(value);
      } else if (LAST_MODIFIED.equalsIgnoreCase(key)) {
        lastModified = DateParser.parse(value);
      } else if (ETAG.equalsIgnoreCase(key)) {
        etag = value;
      } else if (PRAGMA.equalsIgnoreCase(key)) {
        if ("no-cache".equalsIgnoreCase(value)) {
          noCache = true;
        }
      } else if (SET_COOKIE.equals(key)) {
        rawCookies = rawHeaders.get(key);
      } else if ("Age".equalsIgnoreCase(key)) {
        ageSeconds = parseSeconds(value);
      } else if (CONTENT_TYPE.equalsIgnoreCase(key)) {
        contentType = value;
      } else if (CONTENT_ENCODING.equalsIgnoreCase(key)) {
        contentEncoding = value;
      } else if (TRANSFER_ENCODING.equalsIgnoreCase(key)) {
        transferEncoding = value;
      } else if (CONTENT_LENGTH.equalsIgnoreCase(key)) {
        contentLength = parseInt(value);
      }
    }
  }
예제 #2
0
  // start date before end date
  static LocalDateTime[] parse(String startDateTimeString, String endDateTimeString) {
    LocalDateTime[] dates = new LocalDateTime[2];
    String startDateString = null;
    String startTimeString = null;
    String endDateString = null;
    String endTimeString = null;

    Pattern pattern = Pattern.compile(DATE_TIME_PATTERN);

    Matcher matcher = pattern.matcher(startDateTimeString);
    matcher.find();
    startDateString = matcher.group(1);
    startTimeString = matcher.group(2);

    matcher = pattern.matcher(endDateTimeString);
    matcher.find();
    endDateString = matcher.group(1);
    endTimeString = matcher.group(2);

    if (startDateString == null) {
      startDateString = processNullStartDate(endDateString);
    }

    if (startDateString.equals("now")) {
      startTimeString = getCurrentTime();
    }

    if (endDateString == null) {
      endDateString = startDateString;
    }

    if (startTimeString == null) {
      startTimeString = processNullStartTime(startDateString);
    }

    if (endTimeString == null) {
      endTimeString = processNullEndTime(startDateString, endDateString, startTimeString);
    }

    LocalDate startDate = DateParser.parse(startDateString);
    LocalTime startTime = TimeParser.parse(startTimeString);
    LocalDateTime startDateTime = startDate.atTime(startTime);

    LocalDate endDate = DateParser.parse(endDateString);
    LocalTime endTime = TimeParser.parse(endTimeString);
    LocalDateTime endDateTime = endDate.atTime(endTime);

    if (endDateTime.isBefore(startDateTime)) {
      endDateTime.plusDays(1);
    }

    dates[0] = startDateTime;
    dates[1] = endDateTime;

    return dates;
  }
예제 #3
0
  static LocalDateTime parse(String endDateTimeString) {

    String endDateString = null;
    String endTimeString = null;

    Pattern pattern = Pattern.compile(DATE_TIME_PATTERN);
    Matcher matcher = pattern.matcher(endDateTimeString);

    matcher.find();
    endDateString = matcher.group(1);
    endTimeString = matcher.group(2);

    if (endDateString == null) {
      endDateString = "today";
    }

    if (endTimeString == null) {
      endTimeString = END_TIME_DEFAULT;
    }

    LocalDate endDate = DateParser.parse(endDateString);
    LocalTime endTime = TimeParser.parse(endTimeString);

    LocalDateTime endDateTime = endDate.atTime(endTime);

    if (endDateTime.isBefore(LocalDateTime.now())) {
      endDateTime = endDateTime.plusDays(1);
    }

    return endDateTime;
  }
예제 #4
0
  static long computeExpires(String expires) {
    if (expires != null) {
      Date expiresDate = DateParser.parse(expires);
      if (expiresDate != null) return expiresDate.getTime();
    }

    return Long.MIN_VALUE;
  }
예제 #5
0
 @Deprecated
 public static java.util.Date ISO8601DateFromString(String formatted) {
   java.util.Date rv = null;
   if (formatted != null) {
     // try {
     rv = DateParser.parse(formatted);
     // } catch (InvalidDateException ide) {
     //	if (ERROR_ENABLED) logger.error("ComHelper.ISO8601DateFromString caught
     // InvalidDateException "+ide.getMessage()+" parsing "+formatted);
     // }
   }
   return rv;
 }