Package com.avoka.tm.http
Class HttpResponse
- java.lang.Object
-
- com.avoka.tm.http.HttpResponse
-
public class HttpResponse extends Object
Provides a HttpResponse value object class.
- Since:
- 5.0.0
-
-
Constructor Summary
Constructors Constructor Description HttpResponse()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
getContent()
String
getContentEncoding()
long
getContentLength()
String
getContentType()
Document
getDocumentContent()
Return the content as a XML Document object, or null if not defined.Map<String,String>
getHeaders()
Return the map of HTTP response headers.Path
getPathContent()
Return the content as a Path object, or null if not defined.int
getStatus()
String
getStatusLine()
String
getTextContent()
Return the content as a UTF-8 encoded string, or null if not defined.boolean
isClientError()
Return true if HTTP response is an client error status code (400-499).boolean
isInformational()
Return true if HTTP response is an informational status code (100-199).boolean
isRedirection()
Return true if HTTP response is an redirection status code (300-399).boolean
isServerError()
Return true if HTTP response is an server error status code (500-599).boolean
isStatusNotFound()
Return true if the HTTP response status code is NOT FOUND (404).boolean
isStatusOK()
Return true if the HTTP response status code is OK (200).boolean
isSuccess()
Return true if HTTP response is an success status code (200-299).HttpResponse
setContent(byte[] content)
HttpResponse
setContentEncoding(String contentEncoding)
HttpResponse
setContentLength(long contentLength)
HttpResponse
setContentType(String contentType)
HttpResponse
setHeaders(Map<String,String> headers)
Set the map of HTTP response headers.HttpResponse
setStatus(int status)
HttpResponse
setStatusLine(String statusLine)
HttpResponse
setTextContent(String content)
Sets the text content in the response.String
toString()
Return the string representation of this class.
-
-
-
Method Detail
-
getPathContent
public Path getPathContent()
Return the content as a Path object, or null if not defined.- Returns:
- the content as Path object
-
getDocumentContent
public Document getDocumentContent()
Return the content as a XML Document object, or null if not defined.- Returns:
- the content as a XML Document object, or null if not defined.
-
getHeaders
public Map<String,String> getHeaders()
Return the map of HTTP response headers.- Returns:
- the map of HTTP response headers
-
setHeaders
public HttpResponse setHeaders(Map<String,String> headers)
Set the map of HTTP response headers.- Parameters:
headers
- the map of HTTP response headers- Returns:
- the HttpResponse value object
-
isStatusOK
public boolean isStatusOK()
Return true if the HTTP response status code is OK (200).- Returns:
- true if the HTTP response status code is OK (200).
-
isStatusNotFound
public boolean isStatusNotFound()
Return true if the HTTP response status code is NOT FOUND (404).- Returns:
- true if the HTTP response status code is NOT FOUND (404).
-
isInformational
public boolean isInformational()
Return true if HTTP response is an informational status code (100-199).- Returns:
- true if HTTP response is an informational status code (100-199).
-
isSuccess
public boolean isSuccess()
Return true if HTTP response is an success status code (200-299).- Returns:
- true if HTTP response is an success status code (200-299).
-
isRedirection
public boolean isRedirection()
Return true if HTTP response is an redirection status code (300-399).- Returns:
- true if HTTP response is an redirection status code (300-399).
-
isClientError
public boolean isClientError()
Return true if HTTP response is an client error status code (400-499).- Returns:
- true if HTTP response is an client error status code (400-499).
-
isServerError
public boolean isServerError()
Return true if HTTP response is an server error status code (500-599).- Returns:
- true if HTTP response is an server error status code (500-599).
-
getStatus
public int getStatus()
- Returns:
- the HTTP response status code
-
setStatus
public HttpResponse setStatus(int status)
- Parameters:
status
- the status to set- Returns:
- the HttpResponse value object
-
getStatusLine
public String getStatusLine()
- Returns:
- the statusLine
-
setStatusLine
public HttpResponse setStatusLine(String statusLine)
- Parameters:
statusLine
- the statusLine to set- Returns:
- the HttpResponse value object
-
getContent
public byte[] getContent()
- Returns:
- the content
-
setContent
public HttpResponse setContent(byte[] content)
- Parameters:
content
- the content to set- Returns:
- the HttpResponse value object
-
getContentLength
public long getContentLength()
- Returns:
- the contentLength
-
setContentLength
public HttpResponse setContentLength(long contentLength)
- Parameters:
contentLength
- the contentLength to set- Returns:
- the HttpResponse value object
-
getContentType
public String getContentType()
- Returns:
- the contentType
-
setContentType
public HttpResponse setContentType(String contentType)
- Parameters:
contentType
- the contentType to set- Returns:
- the HttpResponse value object
-
getContentEncoding
public String getContentEncoding()
- Returns:
- the contentEncoding
-
setContentEncoding
public HttpResponse setContentEncoding(String contentEncoding)
- Parameters:
contentEncoding
- the contentEncoding to set- Returns:
- the HttpResponse value object
-
getTextContent
public String getTextContent()
Return the content as a UTF-8 encoded string, or null if not defined.- Returns:
- the content as a UTF-8 encoded string, or null if not defined.
-
setTextContent
public HttpResponse setTextContent(String content)
Sets the text content in the response.- Parameters:
content
- the plain text content to set- Returns:
- the HttpResponse value object
- Since:
- 5.1.7
-
-