/** * Set a header with the given date as the value. * * @param name the name of the header * @param value the date value * @return this * @since 1.4 */ default MutableHeaders setDate(CharSequence name, Instant value) { return setDate(name, new Date(value.toEpochMilli())); }
@Override public void lastModified(Instant lastModified, Runnable runnable) { Instant ifModifiedSince = requestConstants.request.getHeaders().getInstant(IF_MODIFIED_SINCE); if (ifModifiedSince != null) { // Normalise to second resolution ifModifiedSince = Instant.ofEpochSecond(ifModifiedSince.getEpochSecond()); lastModified = Instant.ofEpochSecond(lastModified.getEpochSecond()); if (!lastModified.isAfter(ifModifiedSince)) { requestConstants.response.status(Status.NOT_MODIFIED).send(); return; } } requestConstants.response.getHeaders().setDate(HttpHeaderConstants.LAST_MODIFIED, lastModified); runnable.run(); }