Merged branch 'jetty-9.4.x' into 'jetty-10.0.x'.

This commit is contained in:
Simone Bordet 2019-11-18 10:33:16 +01:00
commit 27e5755b34
2 changed files with 101 additions and 93 deletions

View File

@ -551,45 +551,46 @@ public interface Request
*/
public interface Listener extends QueuedListener, BeginListener, HeadersListener, CommitListener, ContentListener, SuccessListener, FailureListener
{
@Override
public default void onQueued(Request request)
{
}
@Override
public default void onBegin(Request request)
{
}
@Override
public default void onHeaders(Request request)
{
}
@Override
public default void onCommit(Request request)
{
}
@Override
public default void onContent(Request request, ByteBuffer content)
{
}
@Override
public default void onSuccess(Request request)
{
}
@Override
public default void onFailure(Request request, Throwable failure)
{
}
/**
* An empty implementation of {@link Listener}
*/
public static class Adapter implements Listener
{
@Override
public void onQueued(Request request)
{
}
@Override
public void onBegin(Request request)
{
}
@Override
public void onHeaders(Request request)
{
}
@Override
public void onCommit(Request request)
{
}
@Override
public void onContent(Request request, ByteBuffer content)
{
}
@Override
public void onSuccess(Request request)
{
}
@Override
public void onFailure(Request request, Throwable failure)
{
}
}
}
}

View File

@ -260,70 +260,77 @@ public interface Response
*/
public interface Listener extends BeginListener, HeaderListener, HeadersListener, ContentListener, AsyncContentListener, DemandedContentListener, SuccessListener, FailureListener, CompleteListener
{
@Override
public default void onBegin(Response response)
{
}
@Override
public default boolean onHeader(Response response, HttpField field)
{
return true;
}
@Override
public default void onHeaders(Response response)
{
}
@Override
public default void onBeforeContent(Response response, LongConsumer demand)
{
demand.accept(1);
}
@Override
public default void onContent(Response response, ByteBuffer content)
{
}
@Override
public default void onContent(Response response, ByteBuffer content, Callback callback)
{
try
{
onContent(response, content);
callback.succeeded();
}
catch (Throwable x)
{
callback.failed(x);
}
}
@Override
public default void onContent(Response response, LongConsumer demand, ByteBuffer content, Callback callback)
{
onContent(response, content, Callback.from(() ->
{
callback.succeeded();
demand.accept(1);
}, callback::failed));
}
@Override
public default void onSuccess(Response response)
{
}
@Override
public default void onFailure(Response response, Throwable failure)
{
}
@Override
public default void onComplete(Result result)
{
}
/**
* An empty implementation of {@link Listener}
*/
public static class Adapter implements Listener
{
@Override
public void onBegin(Response response)
{
}
@Override
public boolean onHeader(Response response, HttpField field)
{
return true;
}
@Override
public void onHeaders(Response response)
{
}
@Override
public void onContent(Response response, ByteBuffer content)
{
}
@Override
public void onContent(Response response, ByteBuffer content, Callback callback)
{
try
{
onContent(response, content);
callback.succeeded();
}
catch (Throwable x)
{
callback.failed(x);
}
}
@Override
public void onContent(Response response, LongConsumer demand, ByteBuffer content, Callback callback)
{
onContent(response, content, Callback.from(() ->
{
callback.succeeded();
demand.accept(1);
}, callback::failed));
}
@Override
public void onSuccess(Response response)
{
}
@Override
public void onFailure(Response response, Throwable failure)
{
}
@Override
public void onComplete(Result result)
{
}
}
}
}