Package com.linecorp.armeria.server.file
Class AggregatedHttpFileBuilder
java.lang.Object
com.linecorp.armeria.server.file.AbstractHttpFileBuilder
com.linecorp.armeria.server.file.AggregatedHttpFileBuilder
Builds an
AggregatedHttpFile
from an HttpData
.
AggregatedHttpFile f =
AggregatedHttpFile.builder(HttpData.ofUtf8("content"), System.currentTimeMillis())
.entityTag((pathOrUri, attrs) -> "myCustomEntityTag")
.build();
-
Method Summary
Modifier and TypeMethodDescriptionaddHeader
(CharSequence name, Object value) Adds the specified HTTP header.addHeaders
(Iterable<? extends Map.Entry<? extends CharSequence, ?>> headers) Adds the specified HTTP headers.autoDetectedContentType
(boolean contentTypeAutoDetectionEnabled) Sets whether to set the"content-type"
header automatically based on the extension of the file.build()
Returns a newly createdAggregatedHttpFile
with the properties configured so far.cacheControl
(CacheControl cacheControl) Sets the"cache-control"
header.cacheControl
(CharSequence cacheControl) Sets the"cache-control"
header.Sets theClock
that provides the current date and time.contentType
(MediaType contentType) Sets the"content-type"
header.contentType
(CharSequence contentType) Sets the"content-type"
header.date
(boolean dateEnabled) Sets whether to set the"date"
header automatically.entityTag
(boolean enabled) Sets whether to set the"etag"
header automatically based on the path and attributes of the file.entityTag
(BiFunction<String, HttpFileAttributes, String> entityTagFunction) Sets the function which generates the entity tag that's used for setting the"etag"
header automatically.lastModified
(boolean lastModifiedEnabled) Sets whether to set the"last-modified"
header automatically.setHeader
(CharSequence name, Object value) Sets the specified HTTP header.setHeaders
(Iterable<? extends Map.Entry<? extends CharSequence, ?>> headers) Sets the specified HTTP headers.Methods inherited from class com.linecorp.armeria.server.file.AbstractHttpFileBuilder
buildHeaders, clock, entityTagFunction, isContentTypeAutoDetectionEnabled, isDateEnabled, isLastModifiedEnabled
-
Method Details
-
build
Returns a newly createdAggregatedHttpFile
with the properties configured so far. -
clock
Description copied from class:AbstractHttpFileBuilder
Sets theClock
that provides the current date and time. By default,Clock.systemUTC()
is used.- Overrides:
clock
in classAbstractHttpFileBuilder
-
date
Description copied from class:AbstractHttpFileBuilder
Sets whether to set the"date"
header automatically. By default, the"date"
header is set automatically.- Overrides:
date
in classAbstractHttpFileBuilder
-
lastModified
Description copied from class:AbstractHttpFileBuilder
Sets whether to set the"last-modified"
header automatically. By default, the"last-modified"
is set automatically.- Overrides:
lastModified
in classAbstractHttpFileBuilder
-
autoDetectedContentType
Description copied from class:AbstractHttpFileBuilder
Sets whether to set the"content-type"
header automatically based on the extension of the file. By default, the"content-type"
header is set automatically.- Overrides:
autoDetectedContentType
in classAbstractHttpFileBuilder
-
entityTag
Description copied from class:AbstractHttpFileBuilder
Sets whether to set the"etag"
header automatically based on the path and attributes of the file. By default, the"etag"
header is set automatically. UseAbstractHttpFileBuilder.entityTag(BiFunction)
to customize how an entity tag is generated.- Overrides:
entityTag
in classAbstractHttpFileBuilder
-
entityTag
public AggregatedHttpFileBuilder entityTag(BiFunction<String, HttpFileAttributes, String> entityTagFunction) Description copied from class:AbstractHttpFileBuilder
Sets the function which generates the entity tag that's used for setting the"etag"
header automatically.- Overrides:
entityTag
in classAbstractHttpFileBuilder
- Parameters:
entityTagFunction
- the entity tag function that generates the entity tag, ornull
to disable setting the"etag"
header.
-
addHeader
Description copied from class:AbstractHttpFileBuilder
Adds the specified HTTP header.- Overrides:
addHeader
in classAbstractHttpFileBuilder
-
addHeaders
public AggregatedHttpFileBuilder addHeaders(Iterable<? extends Map.Entry<? extends CharSequence, ?>> headers) Description copied from class:AbstractHttpFileBuilder
Adds the specified HTTP headers.- Overrides:
addHeaders
in classAbstractHttpFileBuilder
-
setHeader
Description copied from class:AbstractHttpFileBuilder
Sets the specified HTTP header.- Overrides:
setHeader
in classAbstractHttpFileBuilder
-
setHeaders
public AggregatedHttpFileBuilder setHeaders(Iterable<? extends Map.Entry<? extends CharSequence, ?>> headers) Description copied from class:AbstractHttpFileBuilder
Sets the specified HTTP headers.- Overrides:
setHeaders
in classAbstractHttpFileBuilder
-
contentType
Description copied from class:AbstractHttpFileBuilder
Sets the"content-type"
header. This method is a shortcut for:builder.autoDetectedContentType(false); builder.setHeader(HttpHeaderNames.CONTENT_TYPE, contentType);
- Overrides:
contentType
in classAbstractHttpFileBuilder
-
contentType
Description copied from class:AbstractHttpFileBuilder
Sets the"content-type"
header. This method is a shortcut for:builder.autoDetectedContentType(false); builder.setHeader(HttpHeaderNames.CONTENT_TYPE, contentType);
- Overrides:
contentType
in classAbstractHttpFileBuilder
-
cacheControl
Description copied from class:AbstractHttpFileBuilder
Sets the"cache-control"
header. This method is a shortcut for:builder.setHeader(HttpHeaderNames.CACHE_CONTROL, cacheControl);
- Overrides:
cacheControl
in classAbstractHttpFileBuilder
-
cacheControl
Description copied from class:AbstractHttpFileBuilder
Sets the"cache-control"
header. This method is a shortcut for:builder.setHeader(HttpHeaderNames.CACHE_CONTROL, cacheControl);
- Overrides:
cacheControl
in classAbstractHttpFileBuilder
-