Class SimpleHttpClientResponse

java.lang.Object
org.forgerock.http.client.response.SimpleHttpClientResponse
All Implemented Interfaces:
HttpClientResponse

public class SimpleHttpClientResponse extends Object implements HttpClientResponse
A basic implementation of HttpClientResponse that a script can receive from sending a HttpClientRequest over a HttpClient.
Since:
12.0.0
  • Constructor Details

    • SimpleHttpClientResponse

      public SimpleHttpClientResponse(Integer statusCode, String reasonPhrase, Map<String,String> headers, String messageBody, Map<String,String> cookies)
      Creates a representation of an HTTP/1.1 response. Any or all of the fields can be set as null if desired.
      Parameters:
      statusCode - The three digit integer that corresponds to the HTTP status code.
      reasonPhrase - The HTTP reason phrase.
      headers - Any headers sent with the accessed resource.
      messageBody - The entity sent with the accessed resource.
      cookies - Any cookies sent with the accessed resource.
  • Method Details

    • getStatusCode

      public Integer getStatusCode()
      Retrieve the status code of the accessed resource.
      Specified by:
      getStatusCode in interface HttpClientResponse
      Returns:
      A three digit integer that corresponds to an HTTP status code. Can be null if no status code was set.
    • getReasonPhrase

      public String getReasonPhrase()
      Retrieve the reason phrase of the accessed resource.
      Specified by:
      getReasonPhrase in interface HttpClientResponse
      Returns:
      The HTTP reason phrase. Can be null if no status code was set.
    • hasHeaders

      public boolean hasHeaders()
      Indicates if the accessed resource has headers.
      Specified by:
      hasHeaders in interface HttpClientResponse
      Returns:
      True if the accessed resource has headers.
    • getHeaders

      public Map<String,String> getHeaders()
      Retrieve the headers sent with the accessed resource.
      Specified by:
      getHeaders in interface HttpClientResponse
      Returns:
      The headers sent with the accessed resource. Can be implemented as returning null or an empty map in the absence of any headers.
    • getEntity

      public String getEntity()
      Retrieve the entity sent with the accessed resource.
      Specified by:
      getEntity in interface HttpClientResponse
      Returns:
      The entity sent with the accessed resource. Can be null if no entity was set.
    • hasCookies

      public boolean hasCookies()
      Indicates if the accessed resource had cookies.
      Specified by:
      hasCookies in interface HttpClientResponse
      Returns:
      True if the accessed resource had cookies.
    • getCookies

      public Map<String,String> getCookies()
      Retrieve any cookies sent with the accessed resource.
      Specified by:
      getCookies in interface HttpClientResponse
      Returns:
      Any cookies sent with the accessed resource. Can be implemented as returning null or an empty map in the absence of any cookies.