Class MarshaledResponse.FileBuilder
java.lang.Object
com.soklet.MarshaledResponse.FileBuilder
- Enclosing class:
MarshaledResponse
File-specific builder used by
MarshaledResponse.withFile(Path, Request).
Files are special among known-length response bodies because validators, byte ranges, and
HEAD behavior depend on the current request and filesystem metadata. This builder produces
the final MarshaledResponse directly from those inputs; for ordinary precomputed bytes,
buffers, channels, or path-backed bodies without HTTP file semantics, use MarshaledResponse.Builder.body(byte[]),
MarshaledResponse.Builder.body(ByteBuffer), MarshaledResponse.Builder.body(FileChannel, Long, Long, Boolean), or
MarshaledResponse.Builder.body(Path) instead.
This class is intended for use by a single thread.
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionbuild()cacheControl(@Nullable String cacheControl) Sets theCache-Controlheader.contentEncoding(@Nullable String contentEncoding) Sets theContent-Encodingheader for the file representation.contentType(@Nullable String contentType) Sets theContent-Typeheader for the file representation.Sets the entity tag used for conditional requests and theETagheader.Replaces the additional response headers.lastModified(@Nullable Instant lastModified) Sets the last-modified time used for conditional requests and theLast-Modifiedheader.rangeRequests(@Nullable Boolean rangeRequests) Controls whether byte-range requests are honored.
-
Method Details
-
contentType
Sets theContent-Typeheader for the file representation.- Parameters:
contentType- the content type, ornullor a blank string to clear the configured value and omit the header- Returns:
- this builder
-
contentEncoding
Sets theContent-Encodingheader for the file representation.- Parameters:
contentEncoding- the content encoding, ornullor a blank string to clear the configured value and omit the header- Returns:
- this builder
-
entityTag
Sets the entity tag used for conditional requests and theETagheader.- Parameters:
entityTag- the entity tag, ornullto clear the configured value and omit the header- Returns:
- this builder
-
lastModified
Sets the last-modified time used for conditional requests and theLast-Modifiedheader.- Parameters:
lastModified- the last-modified time, ornullto clear the configured value and omit the header- Returns:
- this builder
-
cacheControl
Sets theCache-Controlheader.- Parameters:
cacheControl- the cache-control value, ornullor a blank string to clear the configured value and omit the header- Returns:
- this builder
-
headers
public @NonNull MarshaledResponse.FileBuilder headers(@Nullable Map<@NonNull String, @NonNull List<@NonNull String>> headers) Replaces the additional response headers.Headers controlled by the file response are rejected during
build(); use the corresponding dedicated builder methods where available.- Parameters:
headers- additional headers to write, ornullor an empty map to configure no additional headers- Returns:
- this builder
-
rangeRequests
Controls whether byte-range requests are honored.- Parameters:
rangeRequests-trueto honor byte-range requests,falseto ignore them, ornullto restore the default oftrue- Returns:
- this builder
-
build
-