Class HttpResponseConnector

java.lang.Object
com.veeva.vault.vapil.connector.HttpResponseConnector

public class HttpResponseConnector extends Object
HTTP response class, instantiated via the HttpRequestConnector response. This class provides methods for accessing the response status code, headers, and the response body.
  • Constructor Details

    • HttpResponseConnector

      public HttpResponseConnector()
      Default constructor to retrieve response as a string
    • HttpResponseConnector

      public HttpResponseConnector(HttpRequestConnector.ResponseOption responseOption)
      Constructor to set specific response option (String, write to file, byte array)
      Parameters:
      responseOption - Option for processing the response
  • Method Details

    • processResponse

      public void processResponse(okhttp3.Response httpResponse)
      Process the HTTP response
      Parameters:
      httpResponse - The HTTP response from the request
    • processResponse

      public void processResponse(okhttp3.Response httpResponse, String outputFilePath)
      Process the HTTP response and optionally write to a file
      Parameters:
      httpResponse - The HTTP response from the request
      outputFilePath - Destination for writing files
    • getHeaders

      public Map<String,List<String>> getHeaders()
      Returns:
      The HTTP response headers. Single element headers, such as Content-Type, can be retrieved by getting the first element in the list.
    • headerFirstValue

      public String headerFirstValue(String name)
      Return first header string value of the given named header. It is up to calling code to check for multi-valued headers.
      Parameters:
      name - The header name (key) to retrieve
      Returns:
      The first value as a string, null if not found
    • getStatusCode

      public int getStatusCode()
      Returns:
      The HTTP response status code
    • getStatusMessage

      public String getStatusMessage()
      Returns:
      The HTTP response status message
    • getContentType

      public String getContentType()
      Returns:
      The HTTP Content-Type
    • getResponse

      public String getResponse()
      Returns:
      The HTTP response as a string
    • getByteArray

      public byte[] getByteArray()
      Returns:
      The HTTP response as a byte array
    • getOutputFilePath

      public String getOutputFilePath()
      Returns:
      The file path of the output