org.xlightweb
Interface IHttpRequestHandler

Package class diagram package IHttpRequestHandler
All Known Implementing Classes:
CacheHandler, Context, FileServiceRequestHandler, HttpRequestHandler, RequestHandlerChain

public interface IHttpRequestHandler

call back interface which will be notified if a new requests is received. Example:

  class MyRequestHandler implements IHttpRequestHandler  {
  
     public void onRequest(IHttpExchange exchange) throws IOException {
        IHttpRequest request = exchange.getRequest();
        //...
        
        exchange.send(new HttpResponse(200, "text/plain", "OK"));
     }
  }
 


Field Summary
static int DEFAULT_EXECUTION_MODE
           
static int DEFAULT_INVOKE_ON_MODE
           
static int DEFAULT_SYNCHRONIZED_ON_MODE
           
 
Method Summary
 void onRequest(IHttpExchange exchange)
          call back method, which will be called if a request message (header) is received
 

Field Detail

DEFAULT_EXECUTION_MODE

static final int DEFAULT_EXECUTION_MODE
See Also:
Constant Field Values

DEFAULT_INVOKE_ON_MODE

static final int DEFAULT_INVOKE_ON_MODE
See Also:
Constant Field Values

DEFAULT_SYNCHRONIZED_ON_MODE

static final int DEFAULT_SYNCHRONIZED_ON_MODE
See Also:
Constant Field Values
Method Detail

onRequest

void onRequest(IHttpExchange exchange)
               throws IOException,
                      BadMessageException
call back method, which will be called if a request message (header) is received

Parameters:
exchange - the exchange contains the request from the client is used to send the response
Throws:
IOException - if an exception occurred. By throwing this exception an error http response message will be sent by xSocket, if one or more requests are unanswered. The underlying connection will be closed
BadMessageException - By throwing this exception an error http response message will be sent by xSocket, which contains the exception message. The underlying connection will be closed