Package org.cdlib.mrt.utility
Class HTTPUtil
java.lang.Object
org.cdlib.mrt.utility.HTTPUtil
This class will contain utilities for HTTP transactions
- Author:
- dloy
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.http.client.HttpClient
static org.apache.http.HttpResponse
deleteHttpResponse
(String requestURL, int timeout) Perform a DELETE operationstatic InputStream
deleteObject
(String requestURL, int timeout) Deletestatic InputStream
deleteObject
(String requestURL, int timeout, int retry) getObject with timeout and retrystatic void
dumpHttpResponse
(org.apache.http.HttpResponse response, int goodStatus) Used to trace IT callsstatic final String
getBasicAuthenticationHeader
(String username, String password) static InputStream
getFTPInputStream
(String ftpURLS, int timeout) static org.apache.http.client.HttpClient
getHttpClient
(int timeout) static org.apache.http.client.HttpClient
getHttpClient
(String requestURL, int timeout) static org.apache.http.HttpResponse
getHttpResponse
(String requestURL, int timeout) Perform a GET operationstatic org.apache.http.HttpResponse
getHttpResponse
(String requestURL, int timeout, long startByte, long endByte) Perform a GET operationstatic org.apache.http.HttpResponse
getHttpResponse
(URL hrefURL, int timeout, int retry) static InputStream
Send this manifestFile to mrt storestatic InputStream
getObject with timeout and retrystatic InputStream
getObject404
(String requestURL, int timeout, int retry) getObject with timeout and retrystatic org.apache.http.HttpEntity
getObjectEntity
(String requestURL, int timeout) Send this manifestFile to mrt storestatic org.apache.http.HttpEntity
getObjectEntity
(String requestURL, int timeout, long startByte, long endByte) Send this manifestFile to mrt storestatic Properties
getObjectProperties
(String requestURL, int timeout, int retry) Get structured properties from a Get requeststatic org.apache.http.HttpResponse
getObjectResponse
(String requestURL, int timeout, int retry) Get structured properties from a Get requeststatic LinkedHashList<String,
String> static InputStream
getTimeoutInputStream
(URL sourceURL, int timeout) Make a connection using URL and perform timeout test using threadsstatic boolean
static org.apache.http.HttpResponse
postHttpResponse
(String requestURL, Properties prop, int timeout) Send this manifestFile to mrt storestatic org.apache.http.HttpResponse
postMultipartHeader
(String requestURL, Properties mainHeaders, Properties stringParts, Map<String, File> fileParts, int timeout) Do multipart poststatic org.apache.http.HttpResponse
postMultipartHttpResponse
(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) Do multipart poststatic org.apache.http.HttpResponse
postMultipartHttpResponse2
(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) Do multipart poststatic InputStream
postMultipartObject
(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) Return InputStream from multipart requeststatic InputStream
postMultipartObject2
(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) Return InputStream from multipart requeststatic InputStream
postObject
(String requestURL, Properties prop, int timeout) Send this manifestFile to mrt storestatic org.apache.http.HttpResponse
putMultipartHttpResponse
(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) Do multipart poststatic InputStream
putMultipartObject
(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) Return InputStream from multipart requeststatic Properties
response2Property
(org.apache.http.HttpResponse response)
-
Constructor Details
-
HTTPUtil
public HTTPUtil()
-
-
Method Details
-
getObject
Send this manifestFile to mrt store- Parameters:
manifestFile
-- Returns:
- Throws:
org.cdlib.framework.utility.FrameworkException
TException
-
getObjectEntity
public static org.apache.http.HttpEntity getObjectEntity(String requestURL, int timeout, long startByte, long endByte) throws TException Send this manifestFile to mrt store- Parameters:
manifestFile
-- Returns:
- Throws:
org.cdlib.framework.utility.FrameworkException
TException
-
getObjectEntity
public static org.apache.http.HttpEntity getObjectEntity(String requestURL, int timeout) throws TException Send this manifestFile to mrt store- Parameters:
manifestFile
-- Returns:
- Throws:
org.cdlib.framework.utility.FrameworkException
TException
-
getObject
getObject with timeout and retry- Parameters:
requestURL
- build inputStream to this URLtimeout
- milliseconds for timeoutretry
- number of retry attemps- Returns:
- InputStream to URL service
- Throws:
TException
-
getObject404
getObject with timeout and retry- Parameters:
requestURL
- build inputStream to this URLtimeout
- milliseconds for timeoutretry
- number of retry attemps- Returns:
- InputStream to URL service
- Throws:
TException
-
deleteObject
Delete- Parameters:
requestURL
- delete URLtimeout
- timeout in .001 seconds- Returns:
- delete response
- Throws:
TException
-
deleteObject
getObject with timeout and retry- Parameters:
requestURL
- build inputStream to this URLtimeout
- milliseconds for timeoutretry
- number of retry attemps- Returns:
- InputStream to URL service
- Throws:
TException
-
getHttpResponse
public static org.apache.http.HttpResponse getHttpResponse(String requestURL, int timeout) throws TException Perform a GET operation- Parameters:
requestURL
- get requesttimeout
- connection timeout- Returns:
- http response
- Throws:
TException
- process exception
-
getHttpResponse
public static org.apache.http.HttpResponse getHttpResponse(String requestURL, int timeout, long startByte, long endByte) throws TException Perform a GET operation- Parameters:
requestURL
- get requesttimeout
- connection timeout- Returns:
- http response
- Throws:
TException
- process exception
-
dumpHttpResponse
public static void dumpHttpResponse(org.apache.http.HttpResponse response, int goodStatus) Used to trace IT calls- Parameters:
response
- http responsegoodStatus
- expected status to skip dump
-
getObjectProperties
public static Properties getObjectProperties(String requestURL, int timeout, int retry) throws TException Get structured properties from a Get request- Parameters:
requestURL
- build inputStream to this URLtimeout
- milliseconds for timeoutretry
- number of retry attemps- Returns:
- Properties generated from HTTPResponse
- Throws:
TException
- process Exception
-
getObjectResponse
public static org.apache.http.HttpResponse getObjectResponse(String requestURL, int timeout, int retry) throws TException Get structured properties from a Get request- Parameters:
requestURL
- build inputStream to this URLtimeout
- milliseconds for timeoutretry
- number of retry attemps- Returns:
- Properties generated from HTTPResponse
- Throws:
TException
- process Exception
-
response2Property
- Throws:
TException
-
deleteHttpResponse
public static org.apache.http.HttpResponse deleteHttpResponse(String requestURL, int timeout) throws TException Perform a DELETE operation- Parameters:
requestURL
- get requesttimeout
- connection timeout- Returns:
- http response
- Throws:
TException
- process exception
-
postObject
public static InputStream postObject(String requestURL, Properties prop, int timeout) throws TException Send this manifestFile to mrt store- Parameters:
manifestFile
-- Returns:
- Throws:
org.cdlib.framework.utility.FrameworkException
TException
-
postHttpResponse
public static org.apache.http.HttpResponse postHttpResponse(String requestURL, Properties prop, int timeout) throws TException Send this manifestFile to mrt store- Parameters:
manifestFile
-- Returns:
- Throws:
org.cdlib.framework.utility.FrameworkException
TException
-
postMultipartHeader
public static org.apache.http.HttpResponse postMultipartHeader(String requestURL, Properties mainHeaders, Properties stringParts, Map<String, File> fileParts, int timeout) throws TExceptionDo multipart post- Parameters:
requestURL
- request URLstringParts
- multipart String bodiesfileParts
- multipart File bodiestimeout
- client timeout- Returns:
- HttpReponse from POST request
- Throws:
TException
-
postMultipartObject2
public static InputStream postMultipartObject2(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) throws TExceptionReturn InputStream from multipart request- Parameters:
requestURL
- request URLstringParts
- multipart String bodiesfileParts
- multipart File bodiestimeout
- client timeout- Returns:
- response stream from multipart request
- Throws:
TException
-
postMultipartHttpResponse2
public static org.apache.http.HttpResponse postMultipartHttpResponse2(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) throws TExceptionDo multipart post- Parameters:
requestURL
- request URLstringParts
- multipart String bodiesfileParts
- multipart File bodiestimeout
- client timeout- Returns:
- HttpReponse from POST request
- Throws:
TException
-
putMultipartObject
public static InputStream putMultipartObject(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) throws TExceptionReturn InputStream from multipart request- Parameters:
requestURL
- request URLstringParts
- multipart String bodiesfileParts
- multipart File bodiestimeout
- client timeout- Returns:
- response stream from multipart request
- Throws:
TException
-
putMultipartHttpResponse
public static org.apache.http.HttpResponse putMultipartHttpResponse(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) throws TExceptionDo multipart post- Parameters:
requestURL
- request URLstringParts
- multipart String bodiesfileParts
- multipart File bodiestimeout
- client timeout- Returns:
- HttpReponse from POST request
- Throws:
TException
-
postMultipartObject
public static InputStream postMultipartObject(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) throws TExceptionReturn InputStream from multipart request- Parameters:
requestURL
- request URLstringParts
- multipart String bodiesfileParts
- multipart File bodiestimeout
- client timeout- Returns:
- response stream from multipart request
- Throws:
TException
-
postMultipartHttpResponse
public static org.apache.http.HttpResponse postMultipartHttpResponse(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) throws TExceptionDo multipart post- Parameters:
requestURL
- request URLstringParts
- multipart String bodiesfileParts
- multipart File bodiestimeout
- client timeout- Returns:
- HttpReponse from POST request
- Throws:
TException
-
getHttpResponse
public static org.apache.http.HttpResponse getHttpResponse(URL hrefURL, int timeout, int retry) throws TException - Throws:
TException
-
isFTP
-
getFTPInputStream
- Throws:
TException
-
getTimeoutInputStream
Make a connection using URL and perform timeout test using threads- Parameters:
sourceURL
- connect to this URLtimeout
- connection timeout in secondsfw
- framework instance- Throws:
TException
-
getQuery
-
createHttpClient_AcceptsUntrustedCerts
public static org.apache.http.client.HttpClient createHttpClient_AcceptsUntrustedCerts() throws Exception- Throws:
Exception
-
getHttpClient
- Throws:
Exception
-
getHttpClient
public static org.apache.http.client.HttpClient getHttpClient(String requestURL, int timeout) throws Exception - Throws:
Exception
-
getBasicAuthenticationHeader
-