
io.github.openunirest.http.Headers Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of unirest-java Show documentation
Show all versions of unirest-java Show documentation
Simplified, lightweight HTTP client library
package io.github.openunirest.http;
import org.apache.http.Header;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
public class Headers extends HashMap> {
private static final long serialVersionUID = 71310341388734766L;
public Headers() {
super();
}
public Headers(Header[] pairs) {
for (Header header : pairs) {
add(header.getName(), header.getValue());
}
}
public String getFirst(Object key) {
return getOrDefault(key, Collections.emptyList())
.stream()
.findFirst()
.orElse(null);
}
public void add(String name, String value) {
computeIfAbsent(name, k -> new ArrayList<>()).add(value);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy