Package org.metricshub.http
Class HttpResponse
java.lang.Object
org.metricshub.http.HttpResponse
Represents an HTTP Response in a simplified way
- Status code (200, 400, etc.)
- Header (Content-type: application/json, etc.)
- Body
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendBody(String data) Append content to the body of the HTTP responsevoidappendHeader(String name, String value) Add one header valuegetBody()Get the HTTP header as a single string like below:intvoidsetStatusCode(int code) Sets the HTTP status codetoString()
-
Constructor Details
-
HttpResponse
public HttpResponse()Create a new HTTP Response
-
-
Method Details
-
getStatusCode
public int getStatusCode()- Returns:
- HTTP status code (200, 300, etc.)
-
setStatusCode
public void setStatusCode(int code) Sets the HTTP status code- Parameters:
code- HTTP status code (200, 302, etc.)
-
getHeader
Get the HTTP header as a single string like below:Content-type: text/html Content-length: 34094
- Returns:
- the HTTP header
-
appendHeader
Add one header value- Parameters:
name- Header name (e.g. "Content-type")value- Header value (e.g. "text/html")
-
getBody
- Returns:
- the body of the HTTP response
-
appendBody
Append content to the body of the HTTP response- Parameters:
data- Data to append
-
toString
-