diff --git a/src/main/java/org/cobbzilla/util/http/HttpUtil.java b/src/main/java/org/cobbzilla/util/http/HttpUtil.java index 62689dc..8f81b1c 100644 --- a/src/main/java/org/cobbzilla/util/http/HttpUtil.java +++ b/src/main/java/org/cobbzilla/util/http/HttpUtil.java @@ -69,16 +69,23 @@ public class HttpUtil { public static InputStream get (String urlString) throws IOException { return get(urlString, null); } public static InputStream get (String urlString, Map headers) throws IOException { + return get(urlString, headers, null); + } + + public static InputStream get (String urlString, Map headers, Map headers2) throws IOException { final URL url = new URL(urlString); final HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); - if (headers != null) { - for (Map.Entry h : headers.entrySet()) { - urlConnection.setRequestProperty(h.getKey(), h.getValue()); - } - } + if (headers != null) addHeaders(urlConnection, headers); + if (headers2 != null) addHeaders(urlConnection, headers2); return urlConnection.getInputStream(); } + public static void addHeaders(HttpURLConnection urlConnection, Map headers) { + for (Map.Entry h : headers.entrySet()) { + urlConnection.setRequestProperty(h.getKey(), h.getValue()); + } + } + public static HttpResponseBean upload (String url, File file, Map headers) throws IOException {