HttpResponse
Result of an HTTP request executed with HttpRequest::execute() or one of the HttpSession request methods.
Instance attributes
- body: String
-
Response body as string (empty string if there is no body).
- bodySize: uint64
-
Response body size in bytes.
- contentType: String
-
Value of the
Content-Typeresponse header, ornullif not present.
- errorMessage: String
-
Description of the communication error (connection failure, timeout, TLS error, response size limit exceeded), or
nullif the request completed and a response was received. HTTP error status codes (4xx, 5xx) are not reported here; check statusCode.
- headers: HashMap
-
Response headers as hash map. Header names are converted to lower case; values of repeated headers are joined with comma.
- json ⇒ JsonObject or JsonArray
-
Response body parsed as JSON: JsonObject for objects, JsonArray for arrays, or
nullif the body is empty or is not valid JSON.
- responseTime: int
-
Total request time in milliseconds.
- statusCode: int
-
HTTP status code, or
0if the request failed before a response was received.
- success: bool
-
TRUEif no communication error occurred and status code is in 2xx range.
- url: String
-
Effective URL of the response (final URL after redirects).
Instance methods
- getHeader(name): String
-
Get response header value. Header name is matched case-insensitively.
Table 1. Parameters name
String
Header name.
ReturnHeader value, or
nullif the header is not present.response = new HttpRequest("https://api.example.com/items").execute(); println("Rate limit remaining: " .. response.getHeader("X-RateLimit-Remaining"));