Package net.lenni0451.commons.httpclient
Class HttpResponse
- java.lang.Object
-
- net.lenni0451.commons.httpclient.HeaderStore<HttpResponse>
-
- net.lenni0451.commons.httpclient.HttpResponse
-
public class HttpResponse extends HeaderStore<HttpResponse>
-
-
Constructor Summary
Constructors Constructor Description HttpResponse(java.net.URL url, int statusCode, byte[] content, java.util.Map<java.lang.String,java.util.List<java.lang.String>> headers)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]getContent()java.lang.StringgetContentAsString()java.lang.StringgetContentAsString(java.nio.charset.Charset charset)Get the response body as a string with the given charset.java.util.Optional<ContentType>getContentType()intgetStatusCode()java.lang.StringgetStatusMessage()java.net.URLgetURL()-
Methods inherited from class net.lenni0451.commons.httpclient.HeaderStore
appendHeader, appendHeader, appendHeader, clearHeaders, getFirstHeader, getHeader, getHeaders, getLastHeader, hasHeader, hasHeader, hasHeader, removeHeader, setHeader, setHeader, setHeader
-
-
-
-
Method Detail
-
getURL
public java.net.URL getURL()
- Returns:
- The request url
-
getStatusCode
public int getStatusCode()
- Returns:
- The status code of the response
-
getStatusMessage
public java.lang.String getStatusMessage()
- Returns:
- The message of the status code
-
getContent
public byte[] getContent()
- Returns:
- The response body
-
getContentAsString
public java.lang.String getContentAsString()
- Returns:
- The response body as a string
-
getContentAsString
public java.lang.String getContentAsString(java.nio.charset.Charset charset)
Get the response body as a string with the given charset.- Parameters:
charset- The charset to use- Returns:
- The response body as a string
-
getContentType
public java.util.Optional<ContentType> getContentType()
- Returns:
- The content type of the response
-
-