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

org.opensearch.migrations.IHttpMessage Maven / Gradle / Ivy

package org.opensearch.migrations;

import java.util.List;
import java.util.Map;
import java.util.Optional;

public interface IHttpMessage {
    String method();

    String path();

    String protocol();

    Map> headers();

    default Optional getFirstHeaderValueCaseInsensitive(String key) {
           return Optional.ofNullable(headers().get(key))
               .map(val -> val.get(0))
               .or(() -> {
                var lowerKey = key.toLowerCase();
                return headers().entrySet().stream().filter(
                        entry -> entry.getKey().equalsIgnoreCase(lowerKey)).findFirst()
                    .map(entry -> entry.getValue().get(0));});
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy