@@ -0,0 +1,1982 @@
+package com.ajah.http;%0A%0Aimport java.io.IOException;%0Aimport java.math.BigDecimal;%0Aimport java.util.ArrayList;%0A%0Aimport org.apache.http.NameValuePair;%0Aimport org.apache.http.client.entity.UrlEncodedFormEntity;%0Aimport org.apache.http.client.methods.CloseableHttpResponse;%0Aimport org.apache.http.client.methods.HttpPost;%0Aimport org.apache.http.impl.client.CloseableHttpClient;%0Aimport org.apache.http.message.BasicNameValuePair;%0Aimport org.apache.http.util.EntityUtils;%0A%0Aimport com.ajah.util.ToStringable;%0A%0Aimport lombok.Getter;%0A%0Apublic class SimplePost %7B%0A%0A%09private CloseableHttpClient client;%0A%0A%09@Getter%0A%09private String host;%0A%0A%09@Getter%0A%09private String path;%0A%0A%09@Getter%0A%09private ArrayList%3CNameValuePair%3E params;%0A%0A%09public SimplePost(CloseableHttpClient client) %7B%0A%09%09this.client = client;%0A%09%7D%0A%0A%09public SimplePost host(String _host) %7B%0A%09%09this.host = _host;%0A%09%09return this;%0A%09%7D%0A%0A%09public SimplePost path(String _path) %7B%0A%09%09this.path = _path;%0A%09%09return this;%0A%09%7D%0A%0A%09public void addParam(String name, String value) %7B%0A%09%09if (this.params == null) %7B%0A%09%09%09this.params = new ArrayList%3C%3E();%0A%09%09%7D%0A%09%09this.params.add(new BasicNameValuePair(name, value));%0A%09%7D%0A%0A%09public String getResponseAsString() throws IOException %7B%0A%09%09HttpPost post = new HttpPost(this.host + this.path);%0A%09%09if (this.params != null) %7B%0A%09%09%09post.setEntity(new UrlEncodedFormEntity(this.params));%0A%09%09%7D%0A%09%09try (final CloseableHttpResponse response = this.client.execute(post)) %7B%0A%09%09%09final String string = EntityUtils.toString(response.getEntity());%0A%09%09%09EntityUtils.consumeQuietly(response.getEntity());%0A%09%09%09return string;%0A%09%09%7D%0A%09%7D%0A%0A%09public void addParam(String name, BigDecimal value) %7B%0A%09%09if (value != null) %7B%0A%09%09%09addParam(name, value.toString());%0A%09%09%7D else %7B%0A%09%09%09addParam(name, (String) null);%0A%09%09%7D%0A%09%7D%0A%0A%09public void addParam(String name, int value) %7B%0A%09%09addParam(name, String.valueOf(value));%0A%09%7D%0A%0A%09public void addParam(String name, ToStringable value) %7B%0A%09%09if (value != null) %7B%0A%09%09%09addParam(name, value.toString());%0A%09%09%7D else %7B%0A%09%09%09addParam(name, (String) null);%0A%09%09%7D%0A%09%7D%0A%0A%7D%0A

Add SimplePost