Class ResourceRequest

All Implemented Interfaces:
Future<ResourceResult>, Associator, Eligible
Direct Known Subclasses:
ConletResourceRequest, PageResourceRequest

public class ResourceRequest extends Event<ResourceResult>
An event that signals the request for a resource by the browser.

This event is effectively a “transformed” Request.In.Get. It simplifies handling of such an event by web console components, because they can simply set a result of type ResourceResult and thus need no knowledge about generating all the events required to properly respond to a Request.In.Get.

The complete sequence of events is shown in the diagram.

Resource Response Sequence

Of course, due to internal buffering, the “Response Header” data and the “Response body” data may collapse in a single message that is sent to the browser (in case of a small resource).

If a value is provided by ifModifiedSince(), and the resource has not changed since the given instant, a resource provider may set ResourceNotModified as result. This information will be forwarded to the browser. For a result of type ResourceByUrl, the check for modification will be made automatically, using information derived from the URL.

Handlers of ResourceRequest events use usually only the information provided by resourceUri(). The other items are needed by the handler of the ResourceRequestCompleted event (the web console) to generate the response for the Request.In.Get.

If none of the provided ResourceResult type matches the requirements of the resource provider, it can set ResourceProvided as result. This signals that it genertes the response itself.

Extended Resource Response Sequence

  • Constructor Details

    • ResourceRequest

      public ResourceRequest(URI resourceUri, Instant ifModifiedSince, org.jdrupes.httpcodec.protocols.http.HttpRequest httpRequest, IOSubchannel httpChannel, Session session, RenderSupport renderSupport)
      Creates a new request, including the associated ResourceRequestCompleted event.
      Parameters:
      resourceUri - the requested resource
      httpRequest - the original HTTP request
      httpChannel - the channel that the HTTP request was received on
      renderSupport - the render support
  • Method Details

    • resourceUri

      public URI resourceUri()
      Returns:
      the resourceUri
    • ifModifiedSince

      If not null, this value may be used to decide if the resource must be refreshed.
      Returns:
      the instant
    • httpRequest

      public org.jdrupes.httpcodec.protocols.http.HttpRequest httpRequest()
      Returns the “raw” request as provided by the HTTP decoder.
      Returns:
      the request
    • httpChannel

      Returns:
      the httpChannel
    • renderSupport

      Returns the render support.
      Returns:
      the render support
    • session

      public Session session()
      Returns the (browser) session.
      Returns:
      the session