Package co.ecg.alpaca.core.framework
Class HTTPUtils
java.lang.Object
co.ecg.alpaca.core.framework.HTTPUtils
HTTP Utility Methods to aid in standard RESTful tasks
- Version:
- $Id: $Id
- Author:
- Matthew Keathley on 6/15/15
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.hc.client5.http.impl.classic.CloseableHttpClientCreates a CloseableHttpClient for the given address with attached credentials.static org.apache.hc.core5.http.ClassicHttpResponsedelete.static InputStreamgetInputStreamFromURL(String address) Utility Method to Get the InputStream From the given URLstatic InputStreamgetInputStreamFromURL(URI address) Utility Method to Get the InputStream From the given URLstatic org.apache.hc.core5.http.ClassicHttpResponsegetResponseFromURL(String address) Utility method to get the HTTP Response from a URL.static org.apache.hc.core5.http.ClassicHttpResponsegetResponseFromURL(URI address) Utility method to get the HTTP Response from a URL.static StringgetStringFromURL(String address) Utility Method to Download a File as String from the given URLstatic org.apache.hc.core5.http.ClassicHttpResponseheadStringToURL(String address) Utility method to get the header of the HTTP Response from a URL.static org.apache.hc.core5.http.ClassicHttpResponseheadStringToURL(URI address) Utility method to get the header of the HTTP Response from a URL.static org.apache.hc.core5.http.ClassicHttpResponseputEntityToURL(URI address, org.apache.hc.core5.http.io.entity.AbstractHttpEntity entity) Utility method to send a entity to the given HTTP address via HTTP PUTstatic org.apache.hc.core5.http.ClassicHttpResponseputStringToURL(String address, String string) Utility method to send a String to the given HTTP address via HTTP PUTstatic org.apache.hc.core5.http.ClassicHttpResponseputStringToURL(URI address, String string) Utility method to send a String to the given HTTP address via HTTP PUT
-
Constructor Details
-
HTTPUtils
Constructor for HTTPUtils.
- Parameters:
alpacaProperties- aAlpacaPropertiesobject.
-
-
Method Details
-
createHttpClientFromURL
public static org.apache.hc.client5.http.impl.classic.CloseableHttpClient createHttpClientFromURL(URL url) throws HTTPException Creates a CloseableHttpClient for the given address with attached credentials.- Parameters:
url- The URL create the client- Returns:
CloseableHttpClient- Throws:
HTTPException- Thrown if an error occurs while retrieving the client.
-
getInputStreamFromURL
public static InputStream getInputStreamFromURL(String address) throws URISyntaxException, HTTPException Utility Method to Get the InputStream From the given URL- Parameters:
address- The String form of the URL.- Returns:
- The file as String
- Throws:
HTTPException- Thrown if an error occurs while retrieving the input stream.URISyntaxException- Thrown if the URI is malformed.
-
getInputStreamFromURL
Utility Method to Get the InputStream From the given URL- Parameters:
address- The URL to download- Returns:
- The file as String
- Throws:
HTTPException- Thrown if an error occurs while retrieving the input stream.
-
getResponseFromURL
public static org.apache.hc.core5.http.ClassicHttpResponse getResponseFromURL(String address) throws URISyntaxException, HTTPException Utility method to get the HTTP Response from a URL.- Parameters:
address- The String address to retrieve- Returns:
- The ClassicHttpResponse from the given address
- Throws:
HTTPException- Thrown if an error occurs while retrieving response.URISyntaxException- Thrown if the URI is malformed.
-
getResponseFromURL
public static org.apache.hc.core5.http.ClassicHttpResponse getResponseFromURL(URI address) throws HTTPException Utility method to get the HTTP Response from a URL.- Parameters:
address- The address to retrieve- Returns:
- The CloseableHttpResponse from the given address
- Throws:
HTTPException- Thrown if an error occurs while retrieving response.
-
getStringFromURL
Utility Method to Download a File as String from the given URL- Parameters:
address- The URL to download- Returns:
- The file as String
- Throws:
HTTPException- Thrown if an error occurs while retrieving the URL.
-
putStringToURL
public static org.apache.hc.core5.http.ClassicHttpResponse putStringToURL(String address, String string) throws URISyntaxException, HTTPException Utility method to send a String to the given HTTP address via HTTP PUT- Parameters:
address- The String form of the address to retrievestring- The string to send- Returns:
- The ClassicHttpResponse from the given address
- Throws:
HTTPException- Thrown if an error occurs during PUT.URISyntaxException- Thrown if the URI is malformed.
-
putStringToURL
public static org.apache.hc.core5.http.ClassicHttpResponse putStringToURL(URI address, String string) throws HTTPException Utility method to send a String to the given HTTP address via HTTP PUT- Parameters:
address- The address to retrievestring- The string to send- Returns:
- The ClassicHttpResponse from the given address
- Throws:
HTTPException- Thrown if an error occurs during PUT.
-
putEntityToURL
public static org.apache.hc.core5.http.ClassicHttpResponse putEntityToURL(URI address, org.apache.hc.core5.http.io.entity.AbstractHttpEntity entity) throws HTTPException Utility method to send a entity to the given HTTP address via HTTP PUT- Parameters:
address- The address to retrieveentity- The entity to send- Returns:
- The ClassicHttpResponse from the given address
- Throws:
HTTPException- Thrown if an error occurs during PUT.
-
headStringToURL
public static org.apache.hc.core5.http.ClassicHttpResponse headStringToURL(String address) throws HTTPException, URISyntaxException Utility method to get the header of the HTTP Response from a URL.- Parameters:
address- The String address to retrieve- Returns:
- The ClassicHttpResponse from the given address
- Throws:
HTTPException- Thrown if an error occurs while retrieving response.URISyntaxException- if any.
-
headStringToURL
public static org.apache.hc.core5.http.ClassicHttpResponse headStringToURL(URI address) throws HTTPException Utility method to get the header of the HTTP Response from a URL.- Parameters:
address- The address to retrieve- Returns:
- The ClassicHttpResponse from the given address
- Throws:
HTTPException- Thrown if an error occurs while retrieving response.
-
delete
delete.
- Parameters:
address- aURIobject.- Returns:
- a
CloseableHttpResponseobject. - Throws:
HTTPException- if any.
-