Class ResourceService

java.lang.Object
org.eclipse.jetty.server.ResourceService

public class ResourceService extends Object
Resource service, used by DefaultServlet and ResourceHandler
  • Constructor Details

    • ResourceService

      public ResourceService()
  • Method Details

    • getContent

      public HttpContent getContent(String path, Request request) throws IOException
      Throws:
      IOException
    • getHttpContentFactory

      public HttpContent.Factory getHttpContentFactory()
    • setHttpContentFactory

      public void setHttpContentFactory(HttpContent.Factory contentFactory)
    • getCacheControl

      public String getCacheControl()
      Get the cacheControl header to set on all static content..
      Returns:
      the cacheControl header to set on all static content.
    • getGzipEquivalentFileExtensions

      public List<String> getGzipEquivalentFileExtensions()
      Returns:
      file extensions that signify that a file is gzip compressed. Eg ".svgz"
    • doGet

      public void doGet(Request request, Response response, Callback callback, HttpContent content)
    • writeHttpError

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

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

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

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

      protected boolean passConditionalHeaders(Request request, Response response, HttpContent content, Callback callback) throws IOException
      Returns:
      true if the request was processed, false otherwise.
      Throws:
      IOException
    • sendWelcome

      protected void sendWelcome(HttpContent content, String pathInContext, boolean endsWithSlash, Request request, Response response, Callback callback) throws Exception
      Throws:
      Exception
    • handleWelcomeAction

      protected void handleWelcomeAction(Request request, Response response, Callback callback, ResourceService.WelcomeAction welcomeAction) throws Exception
      Throws:
      Exception
    • redirectWelcome

      protected void redirectWelcome(Request request, Response response, Callback callback, String welcomeTarget) throws Exception

      Redirects to the given welcome target.

      Implementations should use HTTP redirect APIs to generate a redirect response whose location is the welcome target.

      Parameters:
      request - the request to redirect
      response - the response
      callback - the callback to complete
      welcomeTarget - the welcome target to redirect to
      Throws:
      Exception - if the redirection fails
    • serveWelcome

      protected void serveWelcome(Request request, Response response, Callback callback, String welcomeTarget) throws Exception

      Serves the given welcome target.

      Implementations should write the welcome target bytes over the network to the client.

      Parameters:
      request - the request
      response - the response
      callback - the callback to complete
      welcomeTarget - the welcome target to serve
      Throws:
      Exception - if serving the welcome target fails
    • rehandleWelcome

      protected void rehandleWelcome(Request request, Response response, Callback callback, String welcomeTarget) throws Exception

      Rehandles the given welcome target.

      Implementations should call Request.Handler.handle(Request, Response, Callback) on a Handler that may handle the welcome target differently from the original request.

      For example, a request for /ctx/ may be rewritten as /ctx/index.jsp and rehandled from the Server. In this example, the rehandling of /ctx/index.jsp may trigger a different code path so that the rewritten request is handled by a different Handler, in this example one that knows how to handle JSP resources.

      Parameters:
      request - the request
      response - the response
      callback - the callback to complete
      welcomeTarget - the welcome target to rehandle to
      Throws:
      Exception - if the rehandling fails
    • writeHttpContent

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

      protected void putHeaders(Response response, HttpContent content, long contentLength)
    • isAcceptRanges

      public boolean isAcceptRanges()
      Returns:
      If true, range requests and responses are supported
    • isDirAllowed

      public boolean isDirAllowed()
      Returns:
      If true, directory listings are returned if no welcome target is found. Else 403 Forbidden.
    • isEtags

      public boolean isEtags()
      Returns:
      True if ETag processing is done
    • getPrecompressedFormats

      public List<CompressedContentFormat> getPrecompressedFormats()
      Returns:
      Precompressed resources formats that can be used to serve compressed variant of resources.
    • getWelcomeMode

      public ResourceService.WelcomeMode getWelcomeMode()
    • getWelcomeFactory

      public ResourceService.WelcomeFactory getWelcomeFactory()
    • setAcceptRanges

      public void setAcceptRanges(boolean acceptRanges)
      Parameters:
      acceptRanges - If true, range requests and responses are supported
    • setCacheControl

      public void setCacheControl(String cacheControl)
      Set the cacheControl header to set on all static content..
      Parameters:
      cacheControl - the cacheControl header to set on all static content.
    • setDirAllowed

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

      public void setEtags(boolean etags)
      Parameters:
      etags - True if ETag processing is done
    • setGzipEquivalentFileExtensions

      public void setGzipEquivalentFileExtensions(List<String> gzipEquivalentFileExtensions)
      Set file extensions that signify that a file is gzip compressed. Eg ".svgz".
      Parameters:
      gzipEquivalentFileExtensions - file extensions that signify that a file is gzip compressed. Eg ".svgz"
    • setPrecompressedFormats

      public void setPrecompressedFormats(List<CompressedContentFormat> precompressedFormats)
      Parameters:
      precompressedFormats - 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.
    • setEncodingCacheSize

      public void setEncodingCacheSize(int encodingCacheSize)
    • getEncodingCacheSize

      public int getEncodingCacheSize()
    • setWelcomeMode

      public void setWelcomeMode(ResourceService.WelcomeMode welcomeMode)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setWelcomeFactory

      public void setWelcomeFactory(ResourceService.WelcomeFactory welcomeFactory)