org.glassfish.grizzly.http.server
Class HttpRequestProcessor

java.lang.Object
  extended by org.glassfish.grizzly.http.server.HttpRequestProcessor
Direct Known Subclasses:
HttpServiceChain, StaticResourcesService

public abstract class HttpRequestProcessor
extends Object

Base class to use when Request/Response/InputStream/OutputStream are needed to implement a customized HTTP container/extension to the HTTP module. The HttpRequestProcessor 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
HttpRequestProcessor()
          Create HttpService.
 
Method Summary
protected  void customizedErrorPage(Request req, Response res)
          Customize the error page.
 void destroy()
          Invoked when the HttpServer and may be overridden by custom implementations to perform implementation specific resource reclaimation tasks.
 void doService(Request request, Response response)
          Handles static resources if this service is configured to do so, otherwise invokes service(Request, Response).
 Charset getRequestURIEncoding()
          Get the request URI encoding used by this HttpService.
 boolean isAllowCustomStatusMessage()
          Returns true if custom status messages (reason phrases) are allowed for this response, or false otherwise.
 boolean isAllowEncodedSlash()
          Is HTTP URL request allowed to contains encoded slash.
protected  boolean sendAcknowledgment(Request request, Response response)
          The default implementation will acknowledge an Expect: 100-Continue with a response line with the status 100 followed by the final response to this request.
abstract  void service(Request request, Response response)
          This method should contain the logic for any HTTP extension to the Grizzly HTTP web server.
 void setAllowCustomStatusMessage(boolean allowCustomStatusMessage)
          Sets if the custom status messages (reason phrases) are allowed for this response.
 void setAllowEncodedSlash(boolean allowEncodedSlash)
          When true, URL that contains encoded slash will be allowed.
protected  void setDecodeUrl(boolean decodeURL)
          Should this class decode the URL
 void setRequestURIEncoding(Charset requestURIEncoding)
          Set the request URI encoding used by this HttpService.
 void setRequestURIEncoding(String requestURIEncoding)
          Set the request URI encoding used by this HttpService.
 void start()
          Called when the HttpRequestProcessor's container is started by invoking HttpServer.start().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpRequestProcessor

public HttpRequestProcessor()
Create HttpService.

Method Detail

doService

public final void doService(Request request,
                            Response response)
                     throws Exception
Handles static resources if this service is configured to do so, otherwise invokes service(Request, Response).

Parameters:
request - the Request
response - the Response
Throws:
Exception - if an error occurs serving a static resource or from the invocation of service(Request, Response)

service

public abstract void service(Request request,
                             Response response)
                      throws Exception
This method should contain the logic for any HTTP extension to the Grizzly HTTP web server.

Parameters:
request - The Request
response - The Response
Throws:
Exception

start

public void start()
Called when the HttpRequestProcessor's container is started by invoking HttpServer.start(). By default, it does nothing.


destroy

public void destroy()
Invoked when the HttpServer and may be overridden by custom implementations to perform implementation specific resource reclaimation tasks. By default, this method does nothing.


isAllowCustomStatusMessage

public boolean isAllowCustomStatusMessage()
Returns true if custom status messages (reason phrases) are allowed for this response, or false otherwise.

Returns:
true if custom status messages (reason phrases) are allowed for this response, or false otherwise.

setAllowCustomStatusMessage

public void setAllowCustomStatusMessage(boolean allowCustomStatusMessage)
Sets if the custom status messages (reason phrases) are allowed for this response.

Parameters:
allowCustomReasonPhrase - true if custom status messages (reason phrases) are allowed for this response, or false 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

public Charset getRequestURIEncoding()
Get the request URI encoding used by this HttpService.

Returns:
the request URI encoding used by this HttpService.

setRequestURIEncoding

public void setRequestURIEncoding(Charset requestURIEncoding)
Set the request URI encoding used by this HttpService.

Parameters:
requestURIEncoding - the request URI encoding used by this HttpService.

setRequestURIEncoding

public void setRequestURIEncoding(String requestURIEncoding)
Set the request URI encoding used by this HttpService.

Parameters:
requestURIEncoding - the request URI encoding used by this HttpService.

customizedErrorPage

protected void customizedErrorPage(Request req,
                                   Response res)
                            throws Exception
Customize the error page.

Parameters:
serverFilterConfig - the HttpServerFilter configuration.
req - The Request object
res - The Response object
Throws:
Exception

sendAcknowledgment

protected boolean sendAcknowledgment(Request request,
                                     Response response)
                              throws IOException
The default implementation will acknowledge an Expect: 100-Continue with a response line with the status 100 followed by the final response to this request.

Parameters:
request - the Request.
response - the Response.
Returns:
true if request processing should continue after acknowledgment of the expectation, otherwise return false.
Throws:
IOException - if an error occurs sending the acknowledgment.

setDecodeUrl

protected void setDecodeUrl(boolean decodeURL)
Should this class decode the URL



Copyright © 2010 Oracle Corpration. All Rights Reserved.