ru.tinkoff.kora.http.client.jdk.JdkHttpClientHeaders Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of http-client-jdk Show documentation
Show all versions of http-client-jdk Show documentation
Kora http-client-jdk module
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