cz.jalasoft.net.http.HttpGetRequest 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.util.HashMap;
import java.util.Map;
/**
* Created by Honza Lastovicka on 18.5.15.
*/
public abstract class HttpGetRequest extends HttpRequest {
private final Map parameters = new HashMap<>();
public HttpGetRequest urlParameter(String name, String value) {
this.parameters.put(name, value);
return this;
}
public HttpGetRequest rawUrlParameters(String parameters) {
if (parameters == null || parameters.isEmpty()) {
throw new IllegalArgumentException("Raw http get parameters must not be null or empty.");
}
String[] parameterPairs = parameters.split("&");
for(String parameterPair : parameterPairs) {
String[] keyValue = parameterPair.split("=");
if (keyValue.length != 2) {
throw new IllegalArgumentException("Incorrect format of parameter. Expected: key=value");
}
String key = keyValue[0];
String value = keyValue[1];
this.parameters.put(key, value);
}
return this;
}
protected final Map parameters() {
return parameters;
}
@Override
HttpGetRequest getThis() {
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy