![JAR search and dependency download from the Maven repository](/logo.png)
io.joshworks.restclient.request.body.FormEncodedBody 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
Rest Java client based on Unirest
package io.joshworks.restclient.request.body;
import io.joshworks.restclient.Constants;
import io.joshworks.restclient.http.ClientRequest;
import io.joshworks.restclient.request.BaseRequest;
import io.joshworks.restclient.request.HttpRequest;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.message.BasicNameValuePair;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
/**
* Created by Josh Gontijo on 10/25/17.
*/
public class FormEncodedBody extends BaseRequest implements Body {
private Map> parameters = new LinkedHashMap>();
public FormEncodedBody(HttpRequest httpRequest, ClientRequest config) {
super(config);
super.httpRequest = httpRequest;
}
public FormEncodedBody field(String name, String value) {
return add(name, value);
}
public FormEncodedBody field(String name, Integer value) {
return add(name, value);
}
public FormEncodedBody field(String name, Long value) {
return add(name, value);
}
public FormEncodedBody field(String name, Boolean value) {
return add(name, value);
}
public FormEncodedBody field(String name, Double value) {
return add(name, value);
}
public FormEncodedBody fields(Map params) {
if (params != null) {
for (Map.Entry param : params.entrySet()) {
if (param.getValue() == null) {
field(param.getKey(), "");
continue;
}
addField(param.getKey(), param.getValue());
}
}
return this;
}
public FormEncodedBody field(String name, Collection
© 2015 - 2025 Weber Informatics LLC | Privacy Policy