Top Description Inners Fields Constructors Methods
org.eclipse.jetty.server

public Class ResourceService

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.jetty.server.handler.ResourceHandler.HandlerResourceService
Imports
java.io.IOException, java.nio.ByteBuffer, java.nio.channels.ReadableByteChannel, java.nio.charset.Charset, .StandardCharsets, java.nio.file.Path, java.util.ArrayList, .Collection, .Collections, .Enumeration, .List, .Map, .Objects, java.util.concurrent.ConcurrentHashMap, org.eclipse.jetty.http.ByteRange, .CompressedContentFormat, .DateParser, .EtagUtils, .HttpField, .HttpFields, .HttpHeader, .HttpStatus, .HttpURI, .MultiPart, .MultiPartByteRanges, .PreEncodedHttpField, .QuotedCSV, .QuotedQualityCSV, org.eclipse.jetty.http.content.HttpContent, .PreCompressedHttpContent, org.eclipse.jetty.io.ByteBufferPool, .Content, .RetainableByteBuffer, org.eclipse.jetty.server.handler.ContextHandler, org.eclipse.jetty.util.BufferUtil, .Callback, .IO, .IteratingCallback, .URIUtil, org.slf4j.Logger, .LoggerFactory

Resource service, used by DefaultServlet and ResourceHandler

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public static record
ResourceService.WelcomeAction

A welcome target paired with how to process it.

public static interface
public static enum
ResourceService.WelcomeMode

How welcome targets should be processed.

Field Summary

Modifier and TypeField and Description
private boolean
private HttpField
private HttpContent.Factory
private boolean
private int
private boolean
private List<String>
private final List<CompressedContentFormat>
private final List<String>
private final Map<String, List<String>>
private ResourceService.WelcomeFactory
private ResourceService.WelcomeMode
private static final Logger
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
doGet(Request request, Response response, Callback callback, HttpContent content)

public String

Returns:

the cacheControl header to set on all static content.
getCacheControl
()

Get the cacheControl header to set on all static content..

public HttpContent
getContent(String path, Request request)

public int
public List<String>
getGzipEquivalentFileExtensions()

Returns: file extensions that signify that a file is gzip compressed.

public HttpContent.Factory
public List<CompressedContentFormat>
getPrecompressedFormats()

Returns: Precompressed resources formats that can be used to serve compressed variant of resources.

private List<String>
public ResourceService.WelcomeFactory
public ResourceService.WelcomeMode
protected void
handleWelcomeAction(Request request, Response response, Callback callback, ResourceService.WelcomeAction welcomeAction)

public boolean
isAcceptRanges()

Returns: If true, range requests and responses are supported

public boolean
isDirAllowed()

Returns: If true, directory listings are returned if no welcome target is found.

private CompressedContentFormat
public boolean
isEtags()

Returns: True if ETag processing is done

private boolean
private String

Returns:

the matched etag, or null if no matches.
matchesEtag
(String
the content etag to match against (can be null)
contentETag
,
String
the request etag (can be null, a single entry, or even a CSV list)
requestEtag
)

Find a matches between a Content ETag and a Request Field ETag reference.

protected boolean
passConditionalHeaders(Request request, Response response, HttpContent content, Callback callback)

Returns: true if the request was processed, false otherwise.

private ResourceService.WelcomeAction
protected void
putHeaders(Response response, HttpContent content, long contentLength)

protected void
redirectWelcome(Request
the request to redirect
request
,
Response
the response
response
,
Callback
the callback to complete
callback
,
String
the welcome target to redirect to
welcomeTarget
)

Redirects to the given welcome target.

protected void
rehandleWelcome(Request
the request
request
,
Response
the response
response
,
Callback
the callback to complete
callback
,
String
the welcome target to rehandle to
welcomeTarget
)

Rehandles the given welcome target.

private void
sendData(Request request, Response response, Callback callback, HttpContent content, List<String> reqRanges)

private void
sendDirectory(Request request, Response response, HttpContent httpContent, Callback callback, String pathInContext)

protected void
sendRedirect(Request request, Response response, Callback callback, String target)

protected void
sendWelcome(HttpContent content, String pathInContext, boolean endsWithSlash, Request request, Response response, Callback callback)

protected void
serveWelcome(Request
the request
request
,
Response
the response
response
,
Callback
the callback to complete
callback
,
String
the welcome target to serve
welcomeTarget
)

Serves the given welcome target.

public void
setAcceptRanges(boolean
If true, range requests and responses are supported
acceptRanges
)

public void
setCacheControl(String
the cacheControl header to set on all static content.
cacheControl
)

Set the cacheControl header to set on all static content..

public void
setDirAllowed(boolean
If true, directory listings are returned if no welcome target is found. Else 403 Forbidden.
dirAllowed
)

public void
setEncodingCacheSize(int encodingCacheSize)

public void
setEtags(boolean
True if ETag processing is done
etags
)

public void
setGzipEquivalentFileExtensions(List<String>
file extensions that signify that a file is gzip compressed. Eg ".svgz"
gzipEquivalentFileExtensions
)

Set file extensions that signify that a file is gzip compressed.

public void
public void
setPrecompressedFormats(List<CompressedContentFormat>
The list of precompresed formats to serve in encoded format if matching resource found. For example serve gzip encoded file if ".gz" suffixed resource is found.
precompressedFormats
)

public void
public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private boolean
welcome(HttpContent content, Request request, Response response, Callback callback)

protected void
writeHttpContent(Request request, Response response, Callback callback, HttpContent content)

protected void
writeHttpError(Request request, Response response, Callback callback, int status)

protected void
writeHttpError(Request request, Response response, Callback callback, Throwable cause)

protected void
writeHttpError(Request request, Response response, Callback callback, int status, String msg, Throwable cause)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait