Record Class SafeHttpResponse
java.lang.Object
java.lang.Record
com.kingsrook.qqq.backend.core.utils.http.SafeHttpResponse
public record SafeHttpResponse(int statusCode, Map<String,String> headers, byte[] body, boolean truncated, String remoteAddress, long durationMillis)
extends Record
The result of a
SafeHttpClient request: the status, the headers
(first value of each, names lower-cased), at most the policy's
maxResponseBytes of the body, whether the body was cut off, the
address actually connected to and the duration.-
Constructor Summary
ConstructorsConstructorDescriptionSafeHttpResponse(int statusCode, Map<String, String> headers, byte[] body, boolean truncated, String remoteAddress, long durationMillis) Defensive copies: the response is immutable. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]body()The body bytes read (a copy).bodyExcerpt(int maxChars) The body as UTF-8 text, cut to at mostmaxChars.longReturns the value of thedurationMillisrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.A header value (case-insensitive), or null.headers()Returns the value of theheadersrecord component.booleanTrue for a 2xx status.Returns the value of theremoteAddressrecord component.intReturns the value of thestatusCoderecord component.final StringtoString()Returns a string representation of this record class.booleanReturns the value of thetruncatedrecord component.
-
Constructor Details
-
SafeHttpResponse
-
-
Method Details
-
body
public byte[] body()The body bytes read (a copy). -
isSuccess
public boolean isSuccess()True for a 2xx status. -
header
-
bodyExcerpt
The body as UTF-8 text, cut to at mostmaxChars. -
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
statusCode
public int statusCode()Returns the value of thestatusCoderecord component.- Returns:
- the value of the
statusCoderecord component
-
headers
-
truncated
public boolean truncated()Returns the value of thetruncatedrecord component.- Returns:
- the value of the
truncatedrecord component
-
remoteAddress
Returns the value of theremoteAddressrecord component.- Returns:
- the value of the
remoteAddressrecord component
-
durationMillis
public long durationMillis()Returns the value of thedurationMillisrecord component.- Returns:
- the value of the
durationMillisrecord component
-