Class HTTPUtil

java.lang.Object
org.cdlib.mrt.utility.HTTPUtil

public class HTTPUtil extends Object
This class will contain utilities for HTTP transactions
Author:
dloy
  • Constructor Details

    • HTTPUtil

      public HTTPUtil()
  • Method Details

    • getObject

      public static InputStream getObject(String requestURL, int timeout) 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, 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

      public static InputStream getObject(String requestURL, int timeout, int retry) throws TException
      getObject with timeout and retry
      Parameters:
      requestURL - build inputStream to this URL
      timeout - milliseconds for timeout
      retry - number of retry attemps
      Returns:
      InputStream to URL service
      Throws:
      TException
    • getObject404

      public static InputStream getObject404(String requestURL, int timeout, int retry) throws TException
      getObject with timeout and retry
      Parameters:
      requestURL - build inputStream to this URL
      timeout - milliseconds for timeout
      retry - number of retry attemps
      Returns:
      InputStream to URL service
      Throws:
      TException
    • deleteObject

      public static InputStream deleteObject(String requestURL, int timeout) throws TException
      Delete
      Parameters:
      requestURL - delete URL
      timeout - timeout in .001 seconds
      Returns:
      delete response
      Throws:
      TException
    • deleteObject

      public static InputStream deleteObject(String requestURL, int timeout, int retry) throws TException
      getObject with timeout and retry
      Parameters:
      requestURL - build inputStream to this URL
      timeout - milliseconds for timeout
      retry - 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 request
      timeout - 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 request
      timeout - 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 response
      goodStatus - 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 URL
      timeout - milliseconds for timeout
      retry - 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 URL
      timeout - milliseconds for timeout
      retry - number of retry attemps
      Returns:
      Properties generated from HTTPResponse
      Throws:
      TException - process Exception
    • response2Property

      public static Properties response2Property(org.apache.http.HttpResponse response) throws TException
      Throws:
      TException
    • deleteHttpResponse

      public static org.apache.http.HttpResponse deleteHttpResponse(String requestURL, int timeout) throws TException
      Perform a DELETE operation
      Parameters:
      requestURL - get request
      timeout - 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 TException
      Do multipart post
      Parameters:
      requestURL - request URL
      stringParts - multipart String bodies
      fileParts - multipart File bodies
      timeout - 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 TException
      Return InputStream from multipart request
      Parameters:
      requestURL - request URL
      stringParts - multipart String bodies
      fileParts - multipart File bodies
      timeout - 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 TException
      Do multipart post
      Parameters:
      requestURL - request URL
      stringParts - multipart String bodies
      fileParts - multipart File bodies
      timeout - 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 TException
      Return InputStream from multipart request
      Parameters:
      requestURL - request URL
      stringParts - multipart String bodies
      fileParts - multipart File bodies
      timeout - 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 TException
      Do multipart post
      Parameters:
      requestURL - request URL
      stringParts - multipart String bodies
      fileParts - multipart File bodies
      timeout - 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 TException
      Return InputStream from multipart request
      Parameters:
      requestURL - request URL
      stringParts - multipart String bodies
      fileParts - multipart File bodies
      timeout - 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 TException
      Do multipart post
      Parameters:
      requestURL - request URL
      stringParts - multipart String bodies
      fileParts - multipart File bodies
      timeout - 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

      public static boolean isFTP(String urlS)
    • getFTPInputStream

      public static InputStream getFTPInputStream(String ftpURLS, int timeout) throws TException
      Throws:
      TException
    • getTimeoutInputStream

      public static InputStream getTimeoutInputStream(URL sourceURL, int timeout) throws TException
      Make a connection using URL and perform timeout test using threads
      Parameters:
      sourceURL - connect to this URL
      timeout - connection timeout in seconds
      fw - framework instance
      Throws:
      TException
    • getQuery

      public static LinkedHashList<String,String> getQuery(String url)
    • createHttpClient_AcceptsUntrustedCerts

      public static org.apache.http.client.HttpClient createHttpClient_AcceptsUntrustedCerts() throws Exception
      Throws:
      Exception
    • getHttpClient

      public static org.apache.http.client.HttpClient getHttpClient(int timeout) throws Exception
      Throws:
      Exception
    • getHttpClient

      public static org.apache.http.client.HttpClient getHttpClient(String requestURL, int timeout) throws Exception
      Throws:
      Exception
    • getBasicAuthenticationHeader

      public static final String getBasicAuthenticationHeader(String username, String password)