Package io.meeds.commons.http
Record Class SafeFetchResponse
java.lang.Object
java.lang.Record
io.meeds.commons.http.SafeFetchResponse
- Record Components:
status- the HTTP status answerednotModified- whether the server answered 304: nothing changed since the validators senttruncated- whether the body was cut at the request's limit, as the request allowedbody- the body read; empty for an answer without one, null when not modifiedcontentType- theContent-Typeheader answered, as sent, or nullheaders- the first value of every header answered, by name, case ignored; a value carrying a control character other than a tab is left out, as a request would refuse to send ituri- the URL the answer came from, after the redirects followed
public record SafeFetchResponse(int status, boolean notModified, boolean truncated, byte[] body, String contentType, Map<String,String> headers, URI uri)
extends Record
What
SafeHttpFetcher read from a URL: a 2xx answer with its body, or
a 304 to a conditional read.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]body()Returns the value of thebodyrecord component.Returns the value of thecontentTyperecord component.booleanCompares by content: the body is an array.inthashCode()Hashes by content, the body included.The first value of a header answered.headers()Returns the value of theheadersrecord component.The media type answered: theContent-Typewithout its parameters, lower-cased.booleanReturns the value of thenotModifiedrecord component.intstatus()Returns the value of thestatusrecord component.toString()Describes the answer by its status, size and type; never the body, never the URL, which may embed a secret.booleanReturns the value of thetruncatedrecord component.uri()Returns the value of theurirecord component.
-
Constructor Details
-
SafeFetchResponse
public SafeFetchResponse(int status, boolean notModified, boolean truncated, byte[] body, String contentType, Map<String, String> headers, URI uri) Keeps the headers in a case-insensitive, unmodifiable map.- Parameters:
status- the HTTP status answerednotModified- whether the server answered 304truncated- whether the body was cut at the limitbody- the body readcontentType- theContent-Typeansweredheaders- the headers answereduri- the URL the answer came from
-
-
Method Details
-
header
The first value of a header answered.- Parameters:
name- the header name, case ignored- Returns:
- the value, or null when the header was not answered or its value carried a control character other than a tab
-
mediaType
The media type answered: theContent-Typewithout its parameters, lower-cased.- Returns:
- the media type, or null when none was answered
-
equals
Compares by content: the body is an array. -
hashCode
public int hashCode()Hashes by content, the body included. -
toString
Describes the answer by its status, size and type; never the body, never the URL, which may embed a secret. -
status
public int status()Returns the value of thestatusrecord component.- Returns:
- the value of the
statusrecord component
-
notModified
public boolean notModified()Returns the value of thenotModifiedrecord component.- Returns:
- the value of the
notModifiedrecord component
-
truncated
public boolean truncated()Returns the value of thetruncatedrecord component.- Returns:
- the value of the
truncatedrecord component
-
body
public byte[] body()Returns the value of thebodyrecord component.- Returns:
- the value of the
bodyrecord component
-
contentType
Returns the value of thecontentTyperecord component.- Returns:
- the value of the
contentTyperecord component
-
headers
Returns the value of theheadersrecord component.- Returns:
- the value of the
headersrecord component
-
uri
Returns the value of theurirecord component.- Returns:
- the value of the
urirecord component
-