public class HttpURLConnectionClient extends Object
| Constructor and Description |
|---|
HttpURLConnectionClient() |
| Modifier and Type | Method and Description |
|---|---|
static HttpResponse |
sendDeleteRequest(URL endpoint,
String requestParameters)
Sends an HTTP DELETE request to a url
|
static HttpResponse |
sendGetRequest(String endpoint,
String requestParameters)
Sends an HTTP GET request to a url
|
static HttpResponse |
sendGetRequest(String endpoint,
String requestParameters,
String contentType)
Sends an HTTP GET request to a url
|
static void |
sendPostRequest(Reader data,
URL endpoint,
Writer output)
Reads data from the data reader and posts it to a server via POST request.
|
static void |
sendPostRequest(Reader data,
URL endpoint,
Writer output,
String contentType)
Reads data from the data reader and posts it to a server via POST request.
|
static String |
sendPostRequestAndReadResponse(Reader data,
URL endpoint,
Writer output,
String contentType)
Reads data from the data reader and posts it to a server via POST request and read the response.
|
static void |
sendPutRequest(Reader data,
URL endpoint,
Writer output,
String contentType)
Reads data from the data reader and posts it to a server via PUT request.
|
public static HttpResponse sendGetRequest(String endpoint, String requestParameters) throws IOException
endpoint - - The URL of the server. (Example: " http://www.yahoo.com/search")requestParameters - - all the request parameters (Example: "param1=val1¶m2=val2").
Note: This method will add the question mark (?) to the request - DO NOT add it yourselfIOException - If an error occurs while sending the GET requestpublic static HttpResponse sendGetRequest(String endpoint, String requestParameters, String contentType) throws IOException
endpoint - - The URL of the server. (Example: " http://www.yahoo.com/search")requestParameters - - all the request parameters (Example: "param1=val1¶m2=val2").
Note: This method will add the question mark (?) to the request - DO NOT add it yourselfcontentType - - content typeIOException - If an error occurs while sending the GET requestpublic static void sendPostRequest(Reader data, URL endpoint, Writer output) throws Exception
data - Data to be sentendpoint - The endpoint to which the data has to be POSTedoutput - OutputException - If an error occurs while POSTingpublic static void sendPostRequest(Reader data, URL endpoint, Writer output, String contentType) throws Exception
data - Data to be sentendpoint - The endpoint to which the data has to be POSTedoutput - OutputcontentType - content type of the messageException - If an error occurs while POSTingpublic static void sendPutRequest(Reader data, URL endpoint, Writer output, String contentType) throws Exception
data - Data to be sentendpoint - The endpoint to which the data has to be POSTedoutput - OutputcontentType - content type of the messageException - If an error occurs while POSTingpublic static String sendPostRequestAndReadResponse(Reader data, URL endpoint, Writer output, String contentType) throws Exception
data - Data to be sentendpoint - The endpoint to which the data has to be POSTedoutput - OutputcontentType - content type of the messageException - If an error occurs while POSTingpublic static HttpResponse sendDeleteRequest(URL endpoint, String requestParameters) throws IOException
endpoint - - The URL of the server. (Example: " http://www.yahoo.com/search")requestParameters - - all the request parameters (Example: "param1=val1¶m2=val2").
Note: This method will add the question mark (?) to the request - DO NOT add it yourselfIOException - If an error occurs while sending the GET requestCopyright © 2014. All rights reserved.