Package com.yahoo.container.jdisc
Class ThreadedHttpRequestHandler
java.lang.Object
com.yahoo.jdisc.AbstractResource
com.yahoo.jdisc.handler.AbstractRequestHandler
com.yahoo.container.jdisc.ThreadedRequestHandler
com.yahoo.container.jdisc.ThreadedHttpRequestHandler
- All Implemented Interfaces:
HttpRequestHandler,com.yahoo.jdisc.handler.RequestHandler,com.yahoo.jdisc.SharedResource
- Direct Known Subclasses:
AccessLogRequestHandler,FilterBackingRequestHandler,HttpHandlerBase,LoggingRequestHandler,LogHandler,RestApiRequestHandler,VipStatusHandler
public abstract class ThreadedHttpRequestHandler
extends ThreadedRequestHandler
implements HttpRequestHandler
A simple HTTP request handler, using the
HttpRequest and
HttpResponse classes. Users need to override the
handle(HttpRequest) method in this class and the
HttpResponse.render(java.io.OutputStream) method.- Author:
- hmusum, Steinar Knutsen, bratseth
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classA content channel which will return the header and create the proper channel the first time content data needs to be written to it.Nested classes/interfaces inherited from interface com.yahoo.jdisc.SharedResource
com.yahoo.jdisc.SharedResource.Debug -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected final LoggerLogger for subclassesFields inherited from class com.yahoo.container.jdisc.ThreadedRequestHandler
metric, metricUtilFields inherited from interface com.yahoo.jdisc.SharedResource
DEBUG, SYSTEM_PROPERTY_NAME_DEBUG -
Constructor Summary
ConstructorsConstructorDescriptionThreadedHttpRequestHandler(ContainerThreadPool pool, com.yahoo.jdisc.Metric metric) ThreadedHttpRequestHandler(Executor executor) ThreadedHttpRequestHandler(Executor executor, com.yahoo.jdisc.Metric metric) ThreadedHttpRequestHandler(Executor executor, com.yahoo.jdisc.Metric metric, boolean allowAsyncResponse) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddDateHeader(HttpResponse httpResponse, long startTime) protected HttpRequestasHttpRequest(com.yahoo.jdisc.Request request) protected LoggingCompletionHandlercreateLoggingCompletionHandler(long startTime, long renderStartTime, HttpResponse response, HttpRequest httpRequest, ContentChannelOutputStream rendererWiring) Override this to implement custom access logging.abstract HttpResponsehandle(HttpRequest request) Override this to implement a synchronous style handler.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.final voidhandleRequest(com.yahoo.jdisc.Request request, com.yahoo.jdisc.handler.BufferedContentChannel requestContent, com.yahoo.jdisc.handler.ResponseHandler responseHandler) Methods inherited from class com.yahoo.container.jdisc.ThreadedRequestHandler
executor, getRequestType, getTimeout, handleRequest, writeErrorResponseOnOverloadMethods inherited from class com.yahoo.jdisc.handler.AbstractRequestHandler
handleTimeoutMethods inherited from class com.yahoo.jdisc.AbstractResource
currentState, destroy, refer, refer, release, retainCountMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.yahoo.container.jdisc.HttpRequestHandler
requestHandlerSpecMethods inherited from interface com.yahoo.jdisc.handler.RequestHandler
handleRequest, handleTimeoutMethods inherited from interface com.yahoo.jdisc.SharedResource
refer, refer, release
-
Field Details
-
CONTENT_TYPE
- See Also:
-
log
Logger for subclasses
-
-
Constructor Details
-
ThreadedHttpRequestHandler
-
ThreadedHttpRequestHandler
-
ThreadedHttpRequestHandler
-
ThreadedHttpRequestHandler
-
ThreadedHttpRequestHandler
public ThreadedHttpRequestHandler(Executor executor, com.yahoo.jdisc.Metric metric, boolean allowAsyncResponse)
-
-
Method Details
-
handle
Override this to implement a synchronous style handler.- Parameters:
request- incoming HTTP request- Returns:
- a valid HTTP response for presentation to the user
-
handle
Override this rather than handle(request) to be able to write to the channel before returning from this method. This default implementation calls handle(request) -
handleRequest
public final void handleRequest(com.yahoo.jdisc.Request request, com.yahoo.jdisc.handler.BufferedContentChannel requestContent, com.yahoo.jdisc.handler.ResponseHandler responseHandler) - Specified by:
handleRequestin classThreadedRequestHandler
-
addDateHeader
-
createLoggingCompletionHandler
protected LoggingCompletionHandler createLoggingCompletionHandler(long startTime, long renderStartTime, HttpResponse response, HttpRequest httpRequest, ContentChannelOutputStream rendererWiring) Override this to implement custom access logging.- Parameters:
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 response
-
asHttpRequest
-
testContext
-