Class HttpHandler
java.lang.Object
org.glassfish.grizzly.http.server.HttpHandler
- Direct Known Subclasses:
HttpHandlerChain,StaticHttpHandlerBase
Base class to use when Request/Response/InputStream/OutputStream
are needed to implement a customized HTTP container/extension to the
HTTP module.
The
HttpHandler provides developers
with a simple and consistent mechanism for extending the functionality of the
HTTP WebServer and for bridging existing HTTP based technology like
JRuby-on-Rail, Servlet, Bayeux Protocol or any HTTP based protocol.- Author:
- Jeanfrancois Arcand
-
Constructor Summary
ConstructorsConstructorDescriptionCreate HttpHandler.HttpHandler(String name) Create HttpHandler with the specific name. -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Invoked when theHttpServerand may be overridden by custom implementations to perform implementation specific resource reclaimation tasks.protected ErrorPageGeneratorgetErrorPageGenerator(Request request) Returns theErrorPageGenerator, that might be used (if an error occurs) duringRequestprocessing.getName()Get the HttpHandler name.Get the request URI encoding used by this HttpHandler.protected Stringprotected SessionManagergetSessionManager(Request request) booleanReturnstrueif custom status messages (reason phrases) are allowed for this response, orfalse otherwise.booleanIs HTTP URL request allowed to contains encoded slash.protected booleansendAcknowledgment(Request request, Response response) The default implementation will acknowledge anExpect: 100-Continuewith a response line with the status 100 followed by the final response to this request.abstract voidThis method should contain the logic for any HTTP extension to the Grizzly HTTP web server.voidsetAllowCustomStatusMessage(boolean allowCustomStatusMessage) Sets if the custom status messages (reason phrases) are allowed for this response.voidsetAllowEncodedSlash(boolean allowEncodedSlash) When true, URL that contains encoded slash will be allowed.protected voidsetDecodeUrl(boolean decodeURL) Should this class decode the URLprotected voidsetDispatcherHelper(DispatcherHelper dispatcherHelper) voidsetRequestURIEncoding(String requestURIEncoding) Set the request URI encoding used by this HttpHandler.voidsetRequestURIEncoding(Charset requestURIEncoding) Set the request URI encoding used by this HttpHandler.voidstart()Called when theHttpHandler's container is started by invokingHttpServer.start().protected static voidupdatePaths(Request request, MappingData mappingData) Utility method to updateRequestpath values.
-
Constructor Details
-
HttpHandler
public HttpHandler()Create HttpHandler. -
HttpHandler
Create HttpHandler with the specific name.- Parameters:
name-
-
-
Method Details
-
getName
Get the HttpHandler name.- Returns:
- the HttpHandler name.
-
service
This method should contain the logic for any HTTP extension to the Grizzly HTTP web server. -
start
public void start()Called when theHttpHandler's container is started by invokingHttpServer.start(). By default, it does nothing. -
destroy
public void destroy()Invoked when theHttpServerand may be overridden by custom implementations to perform implementation specific resource reclaimation tasks. By default, this method does nothing. -
isAllowCustomStatusMessage
public boolean isAllowCustomStatusMessage()Returnstrueif custom status messages (reason phrases) are allowed for this response, orfalse otherwise.- Returns:
trueif custom status messages (reason phrases) are allowed for this response, orfalse otherwise.
-
setAllowCustomStatusMessage
public void setAllowCustomStatusMessage(boolean allowCustomStatusMessage) Sets if the custom status messages (reason phrases) are allowed for this response.- Parameters:
allowCustomStatusMessage-trueif custom status messages (reason phrases) are allowed for this response, orfalse otherwise.
-
isAllowEncodedSlash
public boolean isAllowEncodedSlash()Is HTTP URL request allowed to contains encoded slash.- Returns:
- Is HTTP URL request allowed to contains encoded slash.
-
setAllowEncodedSlash
public void setAllowEncodedSlash(boolean allowEncodedSlash) When true, URL that contains encoded slash will be allowed. When false, the URL will be rejected and considered as an invalid one.- Parameters:
allowEncodedSlash- true
-
getRequestURIEncoding
Get the request URI encoding used by this HttpHandler.- Returns:
- the request URI encoding used by this HttpHandler.
-
setRequestURIEncoding
Set the request URI encoding used by this HttpHandler.- Parameters:
requestURIEncoding- the request URI encoding used by this HttpHandler.
-
setRequestURIEncoding
Set the request URI encoding used by this HttpHandler.- Parameters:
requestURIEncoding- the request URI encoding used by this HttpHandler.
-
getRequestExecutorProvider
- Returns:
- the
RequestExecutorProviderresponsible for executing user's code inservice(org.glassfish.grizzly.http.server.Request, org.glassfish.grizzly.http.server.Response)and notifyingReadHandler,WriteHandlerregistered by the user.
-
getErrorPageGenerator
Returns theErrorPageGenerator, that might be used (if an error occurs) duringRequestprocessing.- Parameters:
request-Request- Returns:
- the
ErrorPageGenerator, that might be used (if an error occurs) duringRequestprocessing
-
getSessionCookieName
- Returns:
- session cookie name, if not set default JSESSIONID name will be used
-
getSessionManager
- Parameters:
request-Request- Returns:
- the
SessionManagerto be used. null value impliesDefaultSessionManager
-
sendAcknowledgment
The default implementation will acknowledge anExpect: 100-Continuewith a response line with the status 100 followed by the final response to this request.- Parameters:
request- theRequest.response- theResponse.- Returns:
trueif request processing should continue after acknowledgment of the expectation, otherwise returnfalse.- Throws:
IOException- if an error occurs sending the acknowledgment.
-
setDecodeUrl
protected void setDecodeUrl(boolean decodeURL) Should this class decode the URL -
updatePaths
Utility method to updateRequestpath values.- Parameters:
request-mappingData-
-
setDispatcherHelper
-