public abstract class HttpContext extends Object
HttpHandlerwhich is invoked to handle requests destined for that path on the associated HttpServer or HttpsServer.
HttpContext instances are created by the create methods in HttpServer and HttpsServer
A chain of
Filter objects can be added to a HttpContext. All exchanges processed by the
context can be pre- and post-processed by each Filter in the chain.
Constructors Modifier Constructor Description
Modifier and Type Method Description
()returns a mutable Map, which can be used to pass configuration and other data to Filter modules and to the context's exchange handler.
()Returns the currently set Authenticator for this context if one exists.
()returns this context's list of Filters.
()returns the handler for this context
()returns the path this context was created with
()returns the server this context was created with
Authenticator auth)(Sets the Authenticator for this HttpContext.
HttpHandler h)(Sets the handler for this context, if not already set.
getHandlerpublic abstract HttpHandler getHandler()returns the handler for this context
- the HttpHandler for this context
setHandlerpublic abstract void setHandler(HttpHandler h)Sets the handler for this context, if not already set.
getPathpublic abstract String getPath()returns the path this context was created with
- this context's path
getServerpublic abstract HttpServer getServer()returns the server this context was created with
- this context's server
getAttributesreturns a mutable Map, which can be used to pass configuration and other data to Filter modules and to the context's exchange handler.
Every attribute stored in this Map will be visible to every HttpExchange processed by this context
getFiltersreturns this context's list of Filters. This is the actual list used by the server when dispatching requests so modifications to this list immediately affect the the handling of exchanges.
setAuthenticatorSets the Authenticator for this HttpContext. Once an authenticator is establised on a context, all client requests must be authenticated, and the given object will be invoked to validate each request. Each call to this method replaces any previous value set.
auth- the authenticator to set. If
nullthen any previously set authenticator is removed, and client authentication will no longer be required.
- the previous Authenticator, if any set, or
getAuthenticatorpublic abstract Authenticator getAuthenticator()Returns the currently set Authenticator for this context if one exists.
- this HttpContext's Authenticator, or
nullif none is set.