From 6d987e0dd18ef830484641166a816661f4b16074 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Sun, 27 Mar 2016 08:02:14 -0700 Subject: Adding the update_individual API --- src/main/java/com/p4square/ccbapi/ApacheHttpClientImpl.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/main/java/com/p4square/ccbapi/ApacheHttpClientImpl.java') diff --git a/src/main/java/com/p4square/ccbapi/ApacheHttpClientImpl.java b/src/main/java/com/p4square/ccbapi/ApacheHttpClientImpl.java index 0833c67..4c3a777 100644 --- a/src/main/java/com/p4square/ccbapi/ApacheHttpClientImpl.java +++ b/src/main/java/com/p4square/ccbapi/ApacheHttpClientImpl.java @@ -9,6 +9,8 @@ import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ByteArrayEntity; +import org.apache.http.entity.InputStreamEntity; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; @@ -52,14 +54,13 @@ public class ApacheHttpClientImpl implements HTTPInterface { } @Override - public InputStream sendPostRequest(URI uri, Map form) throws IOException { + public InputStream sendPostRequest(final URI uri, final byte[] form) throws IOException { // Build the request. final HttpPost httpPost = new HttpPost(uri); - final List formParameters = new ArrayList<>(); - for (Map.Entry entry : form.entrySet()) { - formParameters.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); + + if (form != null) { + httpPost.setEntity(new ByteArrayEntity(form)); } - httpPost.setEntity(new UrlEncodedFormEntity(formParameters)); // Make the request. final HttpResponse response = httpClient.execute(httpPost); -- cgit v1.2.3