Top Inners Constructors Methods
org.eclipse.jetty.server.handler

public Class DelayedHandler

extends Wrapper
Class Inheritance
Imports
java.nio.charset.Charset, .StandardCharsets, java.util.Objects, java.util.concurrent.CompletableFuture, java.util.concurrent.atomic.AtomicReference, org.eclipse.jetty.http.HttpField, .HttpHeader, .HttpHeaderValue, .HttpStatus, .MimeTypes, org.eclipse.jetty.io.Content, org.eclipse.jetty.server.FormFields, .Handler, .Request, .Response, org.eclipse.jetty.util.Callback, .Fields, .StringUtil

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected abstract static class
protected static class
protected static class

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public boolean
handle(Request
the HTTP request to handle
request
,
Response
the HTTP response to handle
response
,
Callback
the callback to complete when the handling is complete
callback
)

Overrides org.eclipse.jetty.server.Handler.Wrapper.handle.

Implements org.eclipse.jetty.server.Request.Handler.handle.

Invoked to handle the passed HTTP request and response.

protected DelayedHandler.DelayedProcess
newDelayedProcess(boolean contentExpected, String contentType, MimeTypes.Type mimeType, Handler handler, Request request, Response response, Callback callback)

Inherited from org.eclipse.jetty.server.Handler.Wrapper:
getHandlergetInvocationTypesetHandler

Constructor Detail

DelayedHandlerback to summary
public DelayedHandler()
DelayedHandlerback to summary
public DelayedHandler(Handler handler)

Method Detail

handleback to summary
public boolean handle(Request request, Response response, Callback callback) throws Exception

Overrides org.eclipse.jetty.server.Handler.Wrapper.handle.

Implements org.eclipse.jetty.server.Request.Handler.handle.

Doc from org.eclipse.jetty.server.Request.Handler.handle.

Invoked to handle the passed HTTP request and response.

The request is accepted by returning true, then handling must be concluded by completing the passed callback. The handling may be asynchronous, i.e. this method may return true and complete the given callback later, possibly from a different thread. If this method returns false, then the callback must not be invoked and any mutation on the response reversed.

Exceptions thrown by this method may be subsequently handled by an error Request.Handler, if present, otherwise a default HTTP 500 error is generated and the callback completed while writing the error response.

The simplest implementation is:

public boolean handle(Request request, Response response, Callback callback)
{
    callback.succeeded();
    return true;
}

A HelloWorld implementation is:

public boolean handle(Request request, Response response, Callback callback)
{
    response.write(true, ByteBuffer.wrap("Hello World\n".getBytes(StandardCharsets.UTF_8)), callback);
    return true;
}
Parameters
request:Request

the HTTP request to handle

response:Response

the HTTP response to handle

callback:Callback

the callback to complete when the handling is complete

Returns:boolean

True if and only if the request will be handled, a response generated and the callback eventually called. This may occur within the scope of the call to this method, or asynchronously some time later. If false is returned, then this method must not generate a response, nor complete the callback.

Annotations
@Override
Exceptions
Exception:
if there is a failure during the handling. Catchers cannot assume that the callback will be called and thus should attempt to complete the request as if a false had been returned.
newDelayedProcessback to summary
protected DelayedHandler.DelayedProcess newDelayedProcess(boolean contentExpected, String contentType, MimeTypes.Type mimeType, Handler handler, Request request, Response response, Callback callback)
org.eclipse.jetty.server.handler back to summary

protected abstract Class DelayedHandler.DelayedProcess

extends Object
Class Inheritance
  • java.lang.Object
  • org.eclipse.jetty.server.handler.DelayedHandler.DelayedProcess
Known Direct Subclasses
org.eclipse.jetty.server.handler.DelayedHandler.UntilContentDelayedProcess, org.eclipse.jetty.server.handler.DelayedHandler.UntilFormDelayedProcess

Field Summary

Modifier and TypeField and Description
private final Callback
private final Handler
private final Request
private final Response

Constructor Summary

AccessConstructor and Description
protected
DelayedProcess(Handler handler, Request request, Response response, Callback callback)

Method Summary

Modifier and TypeMethod and Description
protected abstract void
protected Callback
protected Handler
protected Request
protected Response
protected void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_callbackback to summary
private final Callback _callback
_handlerback to summary
private final Handler _handler
_requestback to summary
private final Request _request
_responseback to summary
private final Response _response

Constructor Detail

DelayedProcessback to summary
protected DelayedProcess(Handler handler, Request request, Response response, Callback callback)

Method Detail

delayback to summary
protected abstract void delay() throws Exception
getCallbackback to summary
protected Callback getCallback()
getHandlerback to summary
protected Handler getHandler()
getRequestback to summary
protected Request getRequest()
getResponseback to summary
protected Response getResponse()
processback to summary
protected void process()
org.eclipse.jetty.server.handler back to summary

protected Class DelayedHandler.UntilContentDelayedProcess

extends DelayedProcess
Class Inheritance

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Constructor Summary

AccessConstructor and Description
public
UntilContentDelayedProcess(Handler handler, Request request, Response response, Callback callback)

Method Summary

Modifier and TypeMethod and Description
protected void
public void
Inherited from org.eclipse.jetty.server.handler.DelayedHandler.DelayedProcess:
getCallbackgetHandlergetRequestgetResponseprocess

Constructor Detail

UntilContentDelayedProcessback to summary
public UntilContentDelayedProcess(Handler handler, Request request, Response response, Callback callback)

Method Detail

delayback to summary
protected void delay()

Implements abstract org.eclipse.jetty.server.handler.DelayedHandler.DelayedProcess.delay.

Annotations
@Override
onContentback to summary
public void onContent()
org.eclipse.jetty.server.handler back to summary

private Class DelayedHandler.UntilContentDelayedProcess.RewindChunkRequest

extends Wrapper
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final AtomicReference<Content.Chunk>

Constructor Summary

AccessConstructor and Description
public

Field Detail

_chunkback to summary
private final AtomicReference<Content.Chunk> _chunk

Constructor Detail

RewindChunkRequestback to summary
public RewindChunkRequest(Request wrapped, Content.Chunk chunk)

Method Detail

readback to summary
public Content.Chunk read()

Overrides org.eclipse.jetty.server.Request.Wrapper.read.

Implements org.eclipse.jetty.server.Request.read.

Doc from org.eclipse.jetty.server.Request.read.

Reads a chunk of content.

See how to use this method idiomatically.

The returned chunk could be:

  • null, to signal that there isn't a chunk of content available
  • an Chunk instance with non null Chunk#getFailure(), to signal that there was a failure trying to produce a chunk of content, or that the content production has been failed externally
  • a Chunk instance, containing the chunk of content.

Once a read returns an Chunk instance with non-null Chunk#getFailure() then if the failure is last further reads will continue to return the same failure chunk instance, otherwise further read() operations may return different non-failure chunks.

Once a read returns a last chunk, further reads will continue to return a last chunk (although the instance may be different).

The content reader code must ultimately arrange for a call to Chunk#release() on the returned Chunk.

Additionally, prior to the ultimate call to Chunk#release(), the reader code may make additional calls to Chunk#retain(), that must ultimately be matched by a correspondent number of calls to Chunk#release().

Concurrent reads from different threads are not recommended, as they are inherently in a race condition.

Reads performed outside the invocation context of a demand callback are allowed. However, reads performed with a pending demand are inherently in a race condition (the thread that reads with the thread that invokes the demand callback).

In addition, the returned Content.Chunk may be a Trailers instance, in case of request content trailers.

Returns:Content.Chunk

Doc from org.eclipse.jetty.io.Content.Source.read.

a chunk of content, possibly a failure instance, or null

Annotations
@Override
org.eclipse.jetty.server.handler back to summary

protected Class DelayedHandler.UntilFormDelayedProcess

extends DelayedProcess
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Charset

Constructor Summary

AccessConstructor and Description
public
UntilFormDelayedProcess(Handler handler, Request wrapped, Response response, Callback callback, String contentType)

Method Summary

Modifier and TypeMethod and Description
protected void
private void
private void
Inherited from org.eclipse.jetty.server.handler.DelayedHandler.DelayedProcess:
getCallbackgetHandlergetRequestgetResponseprocess

Field Detail

_charsetback to summary
private final Charset _charset

Constructor Detail

UntilFormDelayedProcessback to summary
public UntilFormDelayedProcess(Handler handler, Request wrapped, Response response, Callback callback, String contentType)

Method Detail

delayback to summary
protected void delay()

Implements abstract org.eclipse.jetty.server.handler.DelayedHandler.DelayedProcess.delay.

Annotations
@Override
executeProcessback to summary
private void executeProcess(Fields fields, Throwable x)
processback to summary
private void process(Fields fields, Throwable x)