Information response (1xx) processing

This commit is contained in:
Kirill Usov 2018-03-15 11:39:09 +03:00 committed by Oleg Kalnichevski
parent 669020ccac
commit b717fde289
9 changed files with 96 additions and 0 deletions

View File

@ -180,6 +180,10 @@ class AsyncCachingExec extends CachingExecBase implements AsyncExecChainHandler
return null; return null;
} }
@Override
public void handleInformationResponse(final HttpResponse response) throws HttpException, IOException {
}
@Override @Override
public void completed() { public void completed() {
command.run(); command.run();
@ -316,6 +320,16 @@ class AsyncCachingExec extends CachingExecBase implements AsyncExecChainHandler
return callback.handleResponse(backendResponse, entityDetails); return callback.handleResponse(backendResponse, entityDetails);
} }
@Override
public void handleInformationResponse(final HttpResponse response) throws HttpException, IOException {
final AsyncExecCallback callback = callbackRef.getAndSet(null);
if (callback != null) {
callback.handleInformationResponse(response);
} else {
asyncExecCallback.handleInformationResponse(response);
}
}
@Override @Override
public void completed() { public void completed() {
final AsyncExecCallback callback = callbackRef.getAndSet(null); final AsyncExecCallback callback = callbackRef.getAndSet(null);
@ -501,6 +515,11 @@ class AsyncCachingExec extends CachingExecBase implements AsyncExecChainHandler
return asyncExecCallback.handleResponse(backendResponse, entityDetails); return asyncExecCallback.handleResponse(backendResponse, entityDetails);
} }
@Override
public void handleInformationResponse(final HttpResponse response) throws HttpException, IOException {
asyncExecCallback.handleInformationResponse(response);
}
void triggerNewCacheEntryResponse(final HttpResponse backendResponse, final Date responseDate, final ByteArrayBuffer buffer) { void triggerNewCacheEntryResponse(final HttpResponse backendResponse, final Date responseDate, final ByteArrayBuffer buffer) {
final CancellableDependency operation = scope.cancellableDependency; final CancellableDependency operation = scope.cancellableDependency;
operation.setDependency(responseCache.createCacheEntry( operation.setDependency(responseCache.createCacheEntry(
@ -789,6 +808,16 @@ class AsyncCachingExec extends CachingExecBase implements AsyncExecChainHandler
return callback2.handleResponse(backendResponse2, entityDetails); return callback2.handleResponse(backendResponse2, entityDetails);
} }
@Override
public void handleInformationResponse(final HttpResponse response) throws HttpException, IOException {
final AsyncExecCallback callback2 = callbackRef.getAndSet(null);
if (callback2 != null) {
callback2.handleInformationResponse(response);
} else {
asyncExecCallback.handleInformationResponse(response);
}
}
@Override @Override
public void completed() { public void completed() {
final AsyncExecCallback callback2 = callbackRef.getAndSet(null); final AsyncExecCallback callback2 = callbackRef.getAndSet(null);
@ -821,6 +850,16 @@ class AsyncCachingExec extends CachingExecBase implements AsyncExecChainHandler
return callback1.handleResponse(backendResponse1, entityDetails); return callback1.handleResponse(backendResponse1, entityDetails);
} }
@Override
public void handleInformationResponse(final HttpResponse response) throws HttpException, IOException {
final AsyncExecCallback callback1 = callbackRef.getAndSet(null);
if (callback1 != null) {
callback1.handleInformationResponse(response);
} else {
asyncExecCallback.handleInformationResponse(response);
}
}
@Override @Override
public void completed() { public void completed() {
final AsyncExecCallback callback1 = callbackRef.getAndSet(null); final AsyncExecCallback callback1 = callbackRef.getAndSet(null);
@ -1028,6 +1067,16 @@ class AsyncCachingExec extends CachingExecBase implements AsyncExecChainHandler
return callback.handleResponse(backendResponse, entityDetails); return callback.handleResponse(backendResponse, entityDetails);
} }
@Override
public void handleInformationResponse(final HttpResponse response) throws HttpException, IOException {
final AsyncExecCallback callback = callbackRef.getAndSet(null);
if (callback != null) {
callback.handleInformationResponse(response);
} else {
asyncExecCallback.handleInformationResponse(response);
}
}
@Override @Override
public void completed() { public void completed() {
final AsyncExecCallback callback = callbackRef.getAndSet(null); final AsyncExecCallback callback = callbackRef.getAndSet(null);

View File

@ -130,6 +130,12 @@ class DefaultAsyncCacheRevalidator extends CacheRevalidatorBase {
return asyncExecCallback.handleResponse(response, entityDetails); return asyncExecCallback.handleResponse(response, entityDetails);
} }
@Override
public void handleInformationResponse(
final HttpResponse response) throws HttpException, IOException {
asyncExecCallback.handleInformationResponse(response);
}
@Override @Override
public void completed() { public void completed() {
final HttpResponse httpResponse = responseRef.getAndSet(null); final HttpResponse httpResponse = responseRef.getAndSet(null);

View File

@ -54,6 +54,13 @@ public interface AsyncExecCallback {
HttpResponse response, HttpResponse response,
EntityDetails entityDetails) throws HttpException, IOException; EntityDetails entityDetails) throws HttpException, IOException;
/**
* Triggered to signal receipt of an intermediate response message.
*
* @param response the intermediate response message.
*/
void handleInformationResponse(HttpResponse response) throws HttpException, IOException;
/** /**
* Triggered to signal completion of the message exchange. * Triggered to signal completion of the message exchange.
* <p> * <p>

View File

@ -255,6 +255,12 @@ public final class AsyncConnectExec implements AsyncExecChainHandler {
return asyncExecCallback.handleResponse(response, entityDetails); return asyncExecCallback.handleResponse(response, entityDetails);
} }
@Override
public void handleInformationResponse(
final HttpResponse response) throws HttpException, IOException {
asyncExecCallback.handleInformationResponse(response);
}
@Override @Override
public void completed() { public void completed() {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
@ -359,6 +365,10 @@ public final class AsyncConnectExec implements AsyncExecChainHandler {
return null; return null;
} }
@Override
public void handleInformationResponse(final HttpResponse response) throws HttpException, IOException {
}
@Override @Override
public void completed() { public void completed() {
if (!execRuntime.isEndpointConnected()) { if (!execRuntime.isEndpointConnected()) {

View File

@ -193,6 +193,12 @@ public final class AsyncProtocolExec implements AsyncExecChainHandler {
return asyncExecCallback.handleResponse(response, entityDetails); return asyncExecCallback.handleResponse(response, entityDetails);
} }
@Override
public void handleInformationResponse(
final HttpResponse response) throws HttpException, IOException {
asyncExecCallback.handleInformationResponse(response);
}
@Override @Override
public void completed() { public void completed() {
if (!execRuntime.isEndpointConnected()) { if (!execRuntime.isEndpointConnected()) {

View File

@ -192,6 +192,12 @@ public final class AsyncRedirectExec implements AsyncExecChainHandler {
return asyncExecCallback.handleResponse(response, entityDetails); return asyncExecCallback.handleResponse(response, entityDetails);
} }
@Override
public void handleInformationResponse(
final HttpResponse response) throws HttpException, IOException {
asyncExecCallback.handleInformationResponse(response);
}
@Override @Override
public void completed() { public void completed() {
if (state.redirectURI == null) { if (state.redirectURI == null) {

View File

@ -92,6 +92,11 @@ public final class AsyncRetryExec implements AsyncExecChainHandler {
return asyncExecCallback.handleResponse(response, entityDetails); return asyncExecCallback.handleResponse(response, entityDetails);
} }
@Override
public void handleInformationResponse(final HttpResponse response) throws HttpException, IOException {
asyncExecCallback.handleInformationResponse(response);
}
@Override @Override
public void completed() { public void completed() {
asyncExecCallback.completed(); asyncExecCallback.completed();

View File

@ -181,6 +181,7 @@ class HttpAsyncMainClientExec implements AsyncExecChainHandler {
public void consumeInformation( public void consumeInformation(
final HttpResponse response, final HttpResponse response,
final HttpContext context) throws HttpException, IOException { final HttpContext context) throws HttpException, IOException {
asyncExecCallback.handleInformationResponse(response);
} }
@Override @Override

View File

@ -263,6 +263,12 @@ abstract class InternalAbstractHttpAsyncClient extends AbstractHttpAsyncClientBa
return responseConsumer; return responseConsumer;
} }
@Override
public void handleInformationResponse(
final HttpResponse response) throws HttpException, IOException {
responseConsumer.informationResponse(response, context);
}
@Override @Override
public void completed() { public void completed() {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {