Package com.veeva.vault.vapil.connector
Class HttpResponseConnector
java.lang.Object
com.veeva.vault.vapil.connector.HttpResponseConnector
HTTP response class, instantiated via the HttpRequestConnector response.
This class provides methods for accessing the response status code, headers,
and the response body.
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor to retrieve response as a stringHttpResponseConnector
(HttpRequestConnector.ResponseOption responseOption) Constructor to set specific response option (String, write to file, byte array) -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
int
headerFirstValue
(String name) Return first header string value of the given named header.void
processResponse
(okhttp3.Response httpResponse) Process the HTTP responsevoid
processResponse
(okhttp3.Response httpResponse, String outputFilePath) Process the HTTP response and optionally write to a file
-
Constructor Details
-
HttpResponseConnector
public HttpResponseConnector()Default constructor to retrieve response as a string -
HttpResponseConnector
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
Process the HTTP response and optionally write to a file- Parameters:
httpResponse
- The HTTP response from the requestoutputFilePath
- Destination for writing files
-
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
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
- Returns:
- The HTTP response status message
-
getContentType
- Returns:
- The HTTP Content-Type
-
getResponse
- Returns:
- The HTTP response as a string
-
getByteArray
public byte[] getByteArray()- Returns:
- The HTTP response as a byte array
-
getOutputFilePath
- Returns:
- The file path of the output
-