cz.jalasoft.net.http.HttpRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of HttpClient Show documentation
Show all versions of HttpClient Show documentation
API for communicating over HTTP.
package cz.jalasoft.net.http;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
/**
* Created by honzales on 18.5.15.
*/
public abstract class HttpRequest> {
private URI uri;
private final Map headers = new HashMap<>();
public final T to(URIBuilder uriBuilder) {
return to(uriBuilder.build());
}
public final T to(URI uri) {
this.uri = uri;
return getThis();
}
protected URI uri() {
return uri;
}
public final T header(String key, String value) {
if (key == null || key.isEmpty()) {
throw new IllegalArgumentException("Header key must not be null or empty.");
}
if (value == null || value.isEmpty()) {
throw new IllegalArgumentException("Header value must not be null or empty");
}
headers.put(key, value);
return getThis();
}
protected final Map headers() {
return headers;
}
abstract T getThis();
public abstract HttpResponse send();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy