APISonar


io.micronaut.http.MutableHttpHeaders.date

> io > micronaut > http > MutableHttpHeaders > date
io APIs micronaut APIs http APIs MutableHttpHeaders APIs date APIs

Example 1
private void applyConfiguredHeaders(MutableHttpHeaders headers) {
        if (serverConfiguration.isDateHeader() && !headers.contains("Date")) {
            headers.date(LocalDateTime.now());
        }
        serverConfiguration.getServerHeader().ifPresent((server) -> {
            if (!headers.contains("Server")) {
                headers.add("Server", server);
            }
        });
    }
Example 2
protected void setDateAndCacheHeaders(MutableHttpResponse response, long lastModified) {
        // Date header
        MutableHttpHeaders headers = response.getHeaders();
        LocalDateTime now = LocalDateTime.now();
        headers.date(now);

        // Add cache headers
        LocalDateTime cacheSeconds = now.plus(configuration.getCacheSeconds(), ChronoUnit.SECONDS);
        headers.expires(cacheSeconds);

        response.header(HttpHeaders.CACHE_CONTROL, "private, max-age=" + configuration.getCacheSeconds());
        headers.lastModified(lastModified);
    }