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

ru.tinkoff.kora.http.client.jdk.JdkHttpClientHeaders Maven / Gradle / Ivy

There is a newer version: 1.1.16
Show newest version
package ru.tinkoff.kora.http.client.jdk;

import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
import ru.tinkoff.kora.http.common.header.AbstractHttpHeaders;
import ru.tinkoff.kora.http.common.header.HttpHeaders;

import java.util.*;

public class JdkHttpClientHeaders extends AbstractHttpHeaders implements HttpHeaders {
    private final Map> headers;

    public JdkHttpClientHeaders(java.net.http.HttpHeaders headers) {
        this.headers = headers.map();
    }

    @Nullable
    @Override
    public String getFirst(String headerName) {
        var headers = this.headers.get(headerName);
        if (headers == null || headers.isEmpty()) {
            return null;
        }
        return headers.get(0);
    }

    @Nullable
    @Override
    public List getAll(String headerName) {
        return this.headers.get(headerName);
    }

    @Override
    public int size() {
        return this.headers.size();
    }

    @Override
    public boolean has(String headerName) {
        return this.headers.containsKey(headerName);
    }

    @Override
    public boolean isEmpty() {
        return this.headers.isEmpty();
    }

    @Override
    public Set names() {
        return Collections.unmodifiableSet(this.headers.keySet());
    }

    @Nonnull
    @Override
    public Iterator>> iterator() {
        return this.headers.entrySet().iterator();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy