Package io.joshworks.restclient.http
Class HttpResponse<T>
- java.lang.Object
-
- io.joshworks.restclient.http.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.InputStreamrawBody
-
Method Summary
Modifier and Type Method Description java.lang.StringasString()Tbody()<E> EbodyAs(java.lang.Class<E> type)voidclose()protected java.io.InputStreamconsumeBody(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)HeadersgetHeaders()java.io.InputStreamgetRawBody()Returns the raw response data stream, the data will no be cached for further readingsintgetStatus()java.lang.StringgetStatusText()booleanisSuccessful()
-
-
-
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 notgetHeaders().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:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
-