From 54382927dcd718c84bf120559c0e5c04ab67bcb8 Mon Sep 17 00:00:00 2001 From: "Ray J. Greenwell" Date: Fri, 17 Aug 2012 13:51:25 -0700 Subject: [PATCH] Don't hardcode a Content-Type in the newly-added overload. --- src/main/java/com/samskivert/net/HttpPostUtil.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/samskivert/net/HttpPostUtil.java b/src/main/java/com/samskivert/net/HttpPostUtil.java index d6aa5c81..662d84b7 100644 --- a/src/main/java/com/samskivert/net/HttpPostUtil.java +++ b/src/main/java/com/samskivert/net/HttpPostUtil.java @@ -25,7 +25,9 @@ public class HttpPostUtil { /** * Return the results of a form post. Note that the http request takes place on another - * thread, but this thread blocks until the results are returned or it times out. + * thread, but this thread blocks until the results are returned or it times out. This + * overload sets a single request property of + * "Content-Type" = "application/x-www-form-urlencoded". * * @param url from which to make the request. * @param submission the entire submission eg "foo=bar&baz=boo&futz=foo". @@ -34,7 +36,8 @@ public class HttpPostUtil public static String httpPost (URL url, String submission, int timeout) throws IOException, ServiceWaiter.TimeoutException { - return httpPost(url, submission, timeout, Collections.emptyMap()); + return httpPost(url, submission, timeout, + Collections.singletonMap("Content-Type", "application/x-www-form-urlencoded")); } /** @@ -59,7 +62,6 @@ public class HttpPostUtil conn.setDoInput(true); conn.setDoOutput(true); conn.setUseCaches(false); - conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); for (Map.Entry entry : requestProps.entrySet()) { conn.setRequestProperty(entry.getKey(), entry.getValue()); }