@@ -0,0 +1,2219 @@
+/**%0A * %0A */%0Apackage com.trendrr.oss.networking.http;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.InputStreamReader;%0Aimport java.io.OutputStreamWriter;%0Aimport java.net.URL;%0Aimport java.net.URLConnection;%0A%0Aimport org.apache.commons.logging.Log;%0Aimport org.apache.commons.logging.LogFactory;%0A%0Aimport com.trendrr.oss.DynMap;%0Aimport com.trendrr.oss.exceptions.TrendrrIOException;%0Aimport com.trendrr.oss.exceptions.TrendrrNetworkingException;%0A%0A%0A/**%0A * Simple http class.%0A * %0A * %0A * @author Dustin Norlander%0A * @created Jun 13, 2012%0A * %0A */%0Apublic class Http %7B%0A%0A%09protected static Log log = LogFactory.getLog(Http.class);%0A%09%0A%09public static String get(String url, DynMap params) throws TrendrrNetworkingException %7B%0A%09%09try %7B%0A%09%09%09if (!url.contains(%22?%22)) %7B%0A%09%09%09%09url += %22?%22;%0A%09%09%09%7D%0A%09%09%09if (params != null) %7B%0A%09%09%09%09url += params.toURLString();%0A%09%09%09%7D%0A%09%09%09%0A%09%09%09URL u = new URL(url);%0A%09        URLConnection c = u.openConnection();%0A%09        BufferedReader in = new BufferedReader(%0A%09                                new InputStreamReader(%0A%09                                c.getInputStream()));%0A%09        String inputLine;%0A%09        StringBuilder response = new StringBuilder();%0A%09        while ((inputLine = in.readLine()) != null) %7B%0A%09        %09response.append(inputLine);%0A%09        %7D%0A%09        in.close();%0A%09%09%09return response.toString();%0A%09%09%7D catch (Exception x) %7B%0A%09%09%09throw new TrendrrIOException(x);%0A%09%09%7D%0A%09%7D%0A%09%0A%09public static String post(String url, DynMap params) throws TrendrrNetworkingException %7B%0A%09%09try %7B%0A%09%09%09%09%09%09%0A%09%09%09URL u = new URL(url);%0A%09        URLConnection c = u.openConnection();%0A%09        c.setDoOutput(true);%0A%09        OutputStreamWriter wr = new OutputStreamWriter(c.getOutputStream());%0A%09        wr.write(params.toURLString());%0A%09        wr.flush();%0A%09        %0A%09        %0A%09        BufferedReader in = new BufferedReader(%0A%09                                new InputStreamReader(%0A%09                                c.getInputStream()));%0A%09        String inputLine;%0A%09        StringBuilder response = new StringBuilder();%0A%09        while ((inputLine = in.readLine()) != null) %7B%0A%09        %09response.append(inputLine);%0A%09        %7D%0A%09        in.close();%0A%09%09%09return response.toString();%0A%09%09%7D catch (Exception x) %7B%0A%09%09%09throw new TrendrrIOException(x);%0A%09%09%7D%0A%09%09%0A%09%7D%0A%09%0A%09%0A%09%0A%7D%0A

add simple http class