Class TransportResponse
java.lang.Object
codes.grow.packages.skywalking.core.TransportResponse
A response returned by
HttpTransport (2xx or an accepted status).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintattempts()Returns the number of attempts the call needed.byte[]body()Returns a copy of the body.duration()Returns the call duration including retries.Returns the first value of a header.headers()Returns the response headers (case-insensitive keys).<T> Tjson(com.fasterxml.jackson.core.type.TypeReference<T> type) Decodes the JSON body into a generic type.<T> TDecodes the JSON body.com.fasterxml.jackson.databind.JsonNodejsonNode()Parses the JSON body into a tree.Returns the vendor request id header.intstatus()Returns the HTTP status.text()Returns the body decoded as UTF-8.toString()
-
Constructor Details
-
TransportResponse
public TransportResponse(int status, Map<String, List<String>> headers, byte[] body, int attempts, Duration duration, String operation) Creates a response (used by the transport and by tests).- Parameters:
status- HTTP statusheaders- response headersbody- response bodyattempts- number of attempts madeduration- total call durationoperation- operation name for error messages
-
-
Method Details
-
status
public int status()Returns the HTTP status.- Returns:
- the status
-
headers
Returns the response headers (case-insensitive keys).- Returns:
- the headers
-
header
Returns the first value of a header.- Parameters:
name- header name, case-insensitive- Returns:
- the value, or empty
-
requestId
Returns the vendor request id header.- Returns:
- the request id, or empty
-
body
public byte[] body()Returns a copy of the body.- Returns:
- the body bytes
-
text
Returns the body decoded as UTF-8.- Returns:
- the text
-
json
Decodes the JSON body.- Type Parameters:
T- target type- Parameters:
type- target class- Returns:
- the value
- Throws:
ValidationException- when the body is not valid JSON for the type
-
json
public <T> T json(com.fasterxml.jackson.core.type.TypeReference<T> type) Decodes the JSON body into a generic type.- Type Parameters:
T- target type- Parameters:
type- target type reference- Returns:
- the value
- Throws:
ValidationException- when the body is not valid JSON for the type
-
jsonNode
public com.fasterxml.jackson.databind.JsonNode jsonNode()Parses the JSON body into a tree.- Returns:
- the tree
- Throws:
ValidationException- when the body is not valid JSON
-
attempts
public int attempts()Returns the number of attempts the call needed.- Returns:
- attempts, starting at 1
-
duration
Returns the call duration including retries.- Returns:
- the duration
-
toString
-