All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.split.engine.common.FastlyHeadersCaptor Maven / Gradle / Ivy

There is a newer version: 4.13.0
Show newest version
package io.split.engine.common;

import java.util.*;
import java.util.stream.Collectors;

public class FastlyHeadersCaptor {

    private static final Set HEADERS_TO_CAPTURE = new HashSet<>(Arrays.asList(
            "Fastly-Debug-Path",
            "Fastly-Debug-TTL",
            "Fastly-Debug-Digest",
            "X-Served-By",
            "X-Cache",
            "X-Cache-Hits",
            "X-Timer",
            "Surrogate-Key",
            "ETag",
            "Cache-Control",
            "X-Request-ID",
           "Last-Modified"
    ));

    private final List> _headers = new ArrayList<>();

    public Void handle(Map responseHeaders) {
        _headers.add(responseHeaders.entrySet().stream()
                .filter(e -> HEADERS_TO_CAPTURE.contains(e.getKey()))
                .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));
        return null;
    }

    public List> get() {
        return _headers;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy