eu.larkc.core.util
Class HttpUtils

java.lang.Object
  extended by eu.larkc.core.util.HttpUtils

public class HttpUtils
extends java.lang.Object

A collection of handy HTTP methods.


Constructor Summary
HttpUtils()
           
 
Method Summary
static void postData(java.io.Reader data, java.net.URL endpoint, java.io.Writer output)
          Reads data from the data reader and posts it to a server via a POST request.
static java.lang.String sendGetRequest(java.lang.String url)
          HTTP GET request with text/xml content type.
static java.lang.String sendGetRequest(java.lang.String resourceUrl, java.lang.String contentType)
          Send an HTTP GET request to the given url
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpUtils

public HttpUtils()
Method Detail

sendGetRequest

public static java.lang.String sendGetRequest(java.lang.String url)
HTTP GET request with text/xml content type.

Parameters:
url - The URL to the resource.
Returns:
The returned content.

sendGetRequest

public static java.lang.String sendGetRequest(java.lang.String resourceUrl,
                                              java.lang.String contentType)
Send an HTTP GET request to the given url

Parameters:
resourceUrl - - The full URL of the resource
contentType - Type of the content
Returns:
- The response from the end point

postData

public static void postData(java.io.Reader data,
                            java.net.URL endpoint,
                            java.io.Writer output)
                     throws java.io.IOException
Reads data from the data reader and posts it to a server via a POST request.

Parameters:
data - The data to send
endpoint - The server's address
output - Where to write the server's response
Throws:
java.io.IOException