public abstract class ThreadedHttpRequestHandler extends ThreadedRequestHandler
HttpRequest
and
HttpResponse
classes. Users need to override the
handle(HttpRequest)
method in this class and the
HttpResponse.render(java.io.OutputStream)
method.Modifier and Type | Class and Description |
---|---|
static class |
ThreadedHttpRequestHandler.LazyContentChannel
A content channel which will return the header and create the proper channel the first time content data needs
to be written to it.
|
Modifier and Type | Field and Description |
---|---|
static String |
CONTENT_TYPE |
static String |
DATE |
protected Logger |
log
Logger for subclasses
|
private static String |
RENDERING_ERRORS |
metric
Constructor and Description |
---|
ThreadedHttpRequestHandler(Executor executor) |
ThreadedHttpRequestHandler(Executor executor,
com.yahoo.jdisc.Metric metric) |
ThreadedHttpRequestHandler(Executor executor,
com.yahoo.jdisc.Metric metric,
boolean allowAsyncResponse) |
Modifier and Type | Method and Description |
---|---|
protected void |
addDateHeader(HttpResponse httpResponse,
long startTime) |
private void |
addResponseHeaders(HttpResponse httpResponse,
long startTime) |
protected com.yahoo.jdisc.http.HttpRequest |
asHttpRequest(com.yahoo.jdisc.Request request) |
protected LoggingCompletionHandler |
createLoggingCompletionHandler(long startTime,
long renderStartTime,
HttpResponse response,
HttpRequest httpRequest,
ContentChannelOutputStream rendererWiring)
Override this to implement custom access logging.
|
abstract HttpResponse |
handle(HttpRequest request)
Override this to implement a synchronous style handler.
|
HttpResponse |
handle(HttpRequest request,
com.yahoo.jdisc.handler.ContentChannel channel)
Override this rather than handle(request) to be able to write to the channel before returning from this method.
|
void |
handleRequest(com.yahoo.jdisc.Request request,
com.yahoo.jdisc.handler.BufferedContentChannel requestContent,
com.yahoo.jdisc.handler.ResponseHandler responseHandler) |
private void |
render(HttpRequest request,
HttpResponse httpResponse,
ThreadedHttpRequestHandler.LazyContentChannel channel,
long startTime)
Render and return whether the channel was closed
|
getTimeout, handleRequest
currentState, destroy, refer, release, retainCount
public static final String CONTENT_TYPE
public static final String DATE
private static final String RENDERING_ERRORS
protected final Logger log
public ThreadedHttpRequestHandler(Executor executor)
@Inject public ThreadedHttpRequestHandler(Executor executor, com.yahoo.jdisc.Metric metric)
public ThreadedHttpRequestHandler(Executor executor, com.yahoo.jdisc.Metric metric, boolean allowAsyncResponse)
public abstract HttpResponse handle(HttpRequest request)
request
- incoming HTTP requestpublic HttpResponse handle(HttpRequest request, com.yahoo.jdisc.handler.ContentChannel channel)
public final void handleRequest(com.yahoo.jdisc.Request request, com.yahoo.jdisc.handler.BufferedContentChannel requestContent, com.yahoo.jdisc.handler.ResponseHandler responseHandler)
handleRequest
in class ThreadedRequestHandler
private void render(HttpRequest request, HttpResponse httpResponse, ThreadedHttpRequestHandler.LazyContentChannel channel, long startTime) throws IOException
IOException
private void addResponseHeaders(HttpResponse httpResponse, long startTime)
protected void addDateHeader(HttpResponse httpResponse, long startTime)
protected LoggingCompletionHandler createLoggingCompletionHandler(long startTime, long renderStartTime, HttpResponse response, HttpRequest httpRequest, ContentChannelOutputStream rendererWiring)
startTime
- execution startrenderStartTime
- start of output renderingresponse
- the response which the log entry regardshttpRequest
- the incoming HTTP requestrendererWiring
- the stream the rendered response is written to, used for
fetching length of rendered responseprotected com.yahoo.jdisc.http.HttpRequest asHttpRequest(com.yahoo.jdisc.Request request)
Copyright © 2017. All rights reserved.