Package com.linecorp.armeria.server.file
Class AbstractHttpFileBuilder
java.lang.Object
com.linecorp.armeria.server.file.AbstractHttpFileBuilder
- Direct Known Subclasses:
AggregatedHttpFileBuilder
,HttpFileBuilder
public abstract class AbstractHttpFileBuilder extends Object
A skeletal builder class which helps easier implementation of
HttpFileBuilder
or
AggregatedHttpFileBuilder
.-
Constructor Summary
Constructors Constructor Description AbstractHttpFileBuilder()
-
Method Summary
Modifier and Type Method Description AbstractHttpFileBuilder
addHeader(CharSequence name, Object value)
Adds the specified HTTP header.AbstractHttpFileBuilder
addHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
Adds the specified HTTP headers.AbstractHttpFileBuilder
autoDetectedContentType(boolean contentTypeAutoDetectionEnabled)
Sets whether to set the"content-type"
header automatically based on the extension of the file.protected HttpHeaders
buildHeaders()
Returns the immutable additionalHttpHeaders
which will be set when building anHttpResponse
.AbstractHttpFileBuilder
cacheControl(CacheControl cacheControl)
Sets the"cache-control"
header.AbstractHttpFileBuilder
cacheControl(CharSequence cacheControl)
Sets the"cache-control"
header.protected Clock
clock()
Returns theClock
that provides the current date and time.AbstractHttpFileBuilder
clock(Clock clock)
Sets theClock
that provides the current date and time.AbstractHttpFileBuilder
contentType(MediaType contentType)
Sets the"content-type"
header.AbstractHttpFileBuilder
contentType(CharSequence contentType)
Sets the"content-type"
header.AbstractHttpFileBuilder
date(boolean dateEnabled)
Sets whether to set the"date"
header automatically.AbstractHttpFileBuilder
entityTag(boolean enabled)
Sets whether to set the"etag"
header automatically based on the path and attributes of the file.AbstractHttpFileBuilder
entityTag(BiFunction<String,HttpFileAttributes,String> entityTagFunction)
Sets the function which generates the entity tag that's used for setting the"etag"
header automatically.protected BiFunction<String,HttpFileAttributes,String>
entityTagFunction()
Returns the function which generates the entity tag that's used for setting the"etag"
header automatically.protected boolean
isContentTypeAutoDetectionEnabled()
Sets whether to set the"content-type"
header automatically based on the extension of the file.protected boolean
isDateEnabled()
Returns whether to set the"date"
header automatically.protected boolean
isLastModifiedEnabled()
Returns whether to set the"last-modified"
header automatically.AbstractHttpFileBuilder
lastModified(boolean lastModifiedEnabled)
Sets whether to set the"last-modified"
header automatically.AbstractHttpFileBuilder
setHeader(CharSequence name, Object value)
Sets the specified HTTP header.AbstractHttpFileBuilder
setHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
Sets the specified HTTP headers.
-
Constructor Details
-
AbstractHttpFileBuilder
public AbstractHttpFileBuilder()
-
-
Method Details
-
clock
Returns theClock
that provides the current date and time. -
clock
Sets theClock
that provides the current date and time. By default,Clock.systemUTC()
is used. -
isDateEnabled
protected final boolean isDateEnabled()Returns whether to set the"date"
header automatically. -
date
Sets whether to set the"date"
header automatically. By default, the"date"
header is set automatically. -
isLastModifiedEnabled
protected final boolean isLastModifiedEnabled()Returns whether to set the"last-modified"
header automatically. -
lastModified
Sets whether to set the"last-modified"
header automatically. By default, the"last-modified"
is set automatically. -
isContentTypeAutoDetectionEnabled
protected final boolean isContentTypeAutoDetectionEnabled()Sets whether to set the"content-type"
header automatically based on the extension of the file. -
autoDetectedContentType
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. -
entityTagFunction
Returns the function which generates the entity tag that's used for setting the"etag"
header automatically.- Returns:
- the etag function, or
null
if the"etag"
header is not set automatically.
-
entityTag
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. UseentityTag(BiFunction)
to customize how an entity tag is generated. -
entityTag
public AbstractHttpFileBuilder entityTag(BiFunction<String,HttpFileAttributes,String> entityTagFunction)Sets the function which generates the entity tag that's used for setting the"etag"
header automatically.- Parameters:
entityTagFunction
- the entity tag function that generates the entity tag, ornull
to disable setting the"etag"
header.
-
buildHeaders
Returns the immutable additionalHttpHeaders
which will be set when building anHttpResponse
. -
addHeader
Adds the specified HTTP header. -
addHeaders
public AbstractHttpFileBuilder addHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)Adds the specified HTTP headers. -
setHeader
Sets the specified HTTP header. -
setHeaders
public AbstractHttpFileBuilder setHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)Sets the specified HTTP headers. -
contentType
Sets the"content-type"
header. This method is a shortcut for:builder.autoDetectedContentType(false); builder.setHeader(HttpHeaderNames.CONTENT_TYPE, contentType);
-
contentType
Sets the"content-type"
header. This method is a shortcut for:builder.autoDetectedContentType(false); builder.setHeader(HttpHeaderNames.CONTENT_TYPE, contentType);
-
cacheControl
Sets the"cache-control"
header. This method is a shortcut for:builder.setHeader(HttpHeaderNames.CACHE_CONTROL, cacheControl);
-
cacheControl
Sets the"cache-control"
header. This method is a shortcut for:builder.setHeader(HttpHeaderNames.CACHE_CONTROL, cacheControl);
-