public class HttpService extends Object
HttpProcessor
to generate mandatory protocol
headers for all outgoing messages and apply common, cross-cutting message
transformations to all incoming and outgoing messages, whereas individual
HttpRequestHandler
s are expected to take care of application specific
content generation and processing.
HttpRequestHandler
to resolve matching request
handler for a particular request URI of an incoming HTTP request.
HttpExpectationVerifier
to ensure that
incoming requests meet server's expectations.Constructor and Description |
---|
HttpService(HttpProcessor proc,
ConnectionReuseStrategy connStrategy,
HttpResponseFactory responseFactory)
|
HttpService(HttpProcessor processor,
ConnectionReuseStrategy connStrategy,
HttpResponseFactory responseFactory,
HttpRequestHandlerResolver handlerResolver,
HttpExpectationVerifier expectationVerifier,
HttpParams params)
Create a new HTTP service.
|
HttpService(HttpProcessor processor,
ConnectionReuseStrategy connStrategy,
HttpResponseFactory responseFactory,
HttpRequestHandlerResolver handlerResolver,
HttpParams params)
Create a new HTTP service.
|
Modifier and Type | Method and Description |
---|---|
protected void |
doService(HttpRequest request,
HttpResponse response,
HttpContext context)
The default implementation of this method attempts to resolve an
HttpRequestHandler for the request URI of the given request
and, if found, executes its
HttpRequestHandler.handle(HttpRequest, HttpResponse, HttpContext)
method. |
HttpParams |
getParams() |
protected void |
handleException(HttpException ex,
HttpResponse response)
Handles the given exception and generates an HTTP response to be sent
back to the client to inform about the exceptional condition encountered
in the course of the request processing.
|
void |
handleRequest(HttpServerConnection conn,
HttpContext context)
Handles receives one HTTP request over the given connection within the
given execution context and sends a response back to the client.
|
void |
setConnReuseStrategy(ConnectionReuseStrategy connStrategy)
Deprecated.
set
ConnectionReuseStrategy using constructor |
void |
setExpectationVerifier(HttpExpectationVerifier expectationVerifier)
Deprecated.
set
HttpExpectationVerifier using constructor |
void |
setHandlerResolver(HttpRequestHandlerResolver handlerResolver)
Deprecated.
set
HttpRequestHandlerResolver using constructor |
void |
setHttpProcessor(HttpProcessor processor)
Deprecated.
set
HttpProcessor using constructor |
void |
setParams(HttpParams params)
Deprecated.
set
HttpResponseFactory using constructor |
void |
setResponseFactory(HttpResponseFactory responseFactory)
Deprecated.
set
HttpResponseFactory using constructor |
public HttpService(HttpProcessor processor, ConnectionReuseStrategy connStrategy, HttpResponseFactory responseFactory, HttpRequestHandlerResolver handlerResolver, HttpExpectationVerifier expectationVerifier, HttpParams params)
processor
- the processor to use on requests and responsesconnStrategy
- the connection reuse strategyresponseFactory
- the response factoryhandlerResolver
- the handler resolver. May be null.expectationVerifier
- the expectation verifier. May be null.params
- the HTTP parameterspublic HttpService(HttpProcessor processor, ConnectionReuseStrategy connStrategy, HttpResponseFactory responseFactory, HttpRequestHandlerResolver handlerResolver, HttpParams params)
processor
- the processor to use on requests and responsesconnStrategy
- the connection reuse strategyresponseFactory
- the response factoryhandlerResolver
- the handler resolver. May be null.params
- the HTTP parameterspublic HttpService(HttpProcessor proc, ConnectionReuseStrategy connStrategy, HttpResponseFactory responseFactory)
HttpService(HttpProcessor,
ConnectionReuseStrategy, HttpResponseFactory, HttpRequestHandlerResolver, HttpParams)
proc
- the processor to use on requests and responsesconnStrategy
- the connection reuse strategyresponseFactory
- the response factorypublic void setHttpProcessor(HttpProcessor processor)
HttpProcessor
using constructorpublic void setConnReuseStrategy(ConnectionReuseStrategy connStrategy)
ConnectionReuseStrategy
using constructorpublic void setResponseFactory(HttpResponseFactory responseFactory)
HttpResponseFactory
using constructorpublic void setParams(HttpParams params)
HttpResponseFactory
using constructorpublic void setHandlerResolver(HttpRequestHandlerResolver handlerResolver)
HttpRequestHandlerResolver
using constructorpublic void setExpectationVerifier(HttpExpectationVerifier expectationVerifier)
HttpExpectationVerifier
using constructorpublic HttpParams getParams()
public void handleRequest(HttpServerConnection conn, HttpContext context) throws IOException, HttpException
conn
- the active connection to the clientcontext
- the actual execution context.IOException
- in case of an I/O error.HttpException
- in case of HTTP protocol violation or a processing
problem.protected void handleException(HttpException ex, HttpResponse response)
ex
- the exception.response
- the HTTP response.protected void doService(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException
HttpRequestHandler
for the request URI of the given request
and, if found, executes its
HttpRequestHandler.handle(HttpRequest, HttpResponse, HttpContext)
method.
Super-classes can override this method in order to provide a custom implementation of the request processing logic.
request
- the HTTP request.response
- the HTTP response.context
- the execution context.IOException
- in case of an I/O error.HttpException
- in case of HTTP protocol violation or a processing
problem.Copyright © 2005-2012 The Apache Software Foundation. All Rights Reserved.