Class HttpResponse<T>

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class HttpResponse<T>
    extends java.lang.Object
    implements java.io.Closeable
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.io.InputStream rawBody  
    • Method Summary

      Modifier and Type Method Description
      java.lang.String asString()  
      T body()  
      <E> E bodyAs​(java.lang.Class<E> type)  
      void close()  
      protected java.io.InputStream consumeBody​(org.apache.http.HttpResponse response)  
      static <T> HttpResponse<T> create​(org.apache.http.client.methods.HttpRequestBase request, org.apache.http.HttpResponse response, java.lang.Class<T> responseClass)  
      Headers getHeaders()  
      java.io.InputStream getRawBody()
      Returns the raw response data stream, the data will no be cached for further readings
      int getStatus()  
      java.lang.String getStatusText()  
      boolean isSuccessful()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • rawBody

        protected final java.io.InputStream rawBody
    • Method Detail

      • create

        public static <T> HttpResponse<T> create​(org.apache.http.client.methods.HttpRequestBase request,
                                                 org.apache.http.HttpResponse response,
                                                 java.lang.Class<T> responseClass)
      • consumeBody

        protected java.io.InputStream consumeBody​(org.apache.http.HttpResponse response)
      • getStatus

        public int getStatus()
      • isSuccessful

        public boolean isSuccessful()
      • getStatusText

        public java.lang.String getStatusText()
      • getHeaders

        public Headers getHeaders()
        Returns:
        Response Headers (map) with same case as server response. For instance use getHeaders().getFirst("Location") and not getHeaders().getFirst("location") to get first header "Location"
      • getRawBody

        public java.io.InputStream getRawBody()
        Returns the raw response data stream, the data will no be cached for further readings
        Returns:
        The raw data stream
      • bodyAs

        public <E> E bodyAs​(java.lang.Class<E> type)
      • asString

        public java.lang.String asString()
      • body

        public T body()
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable