@Override protected void onHttpContentParsed(final HttpContent content, final FilterChainContext ctx) { final HttpTransactionContext context = HttpTransactionContext.currentTransaction(content.getHttpHeader()); final AsyncHandler handler = context.getAsyncHandler(); if (handler != null && context.currentState != AsyncHandler.STATE.ABORT) { try { context.currentState = handler.onBodyPartReceived( new GrizzlyResponseBodyPart(content, ctx.getConnection())); } catch (Exception e) { handler.onThrowable(e); } } }
@Override public T onCompleted() throws Exception { try { return asyncHandler.onCompleted(); } finally { complete(); } } }
@Override public STATE onHeadersReceived(HttpResponseHeaders headers) throws Exception { return asyncHandler.onHeadersReceived(headers); }
private V getContent() throws ExecutionException { if (isCancelled()) throw new CancellationException(); ExecutionException e = exEx.get(); if (e != null) throw e; V update = content.get(); // No more retry currentRetry.set(maxRetry); if (!contentProcessed.getAndSet(true)) { try { update = asyncHandler.onCompleted(); } catch (Throwable ex) { if (!onThrowableCalled.getAndSet(true)) { try { try { asyncHandler.onThrowable(ex); } catch (Throwable t) { LOGGER.debug("asyncHandler.onThrowable", t); } throw new RuntimeException(ex); } finally { cancelTimeouts(); } } } content.compareAndSet(null, update); } return update; }
state = asyncHandler.onStatusReceived(status); if (state == AsyncHandler.STATE.CONTINUE) { state = asyncHandler.onHeadersReceived(new ResponseHeaders(uri, urlConnection, JDKAsyncHttpProvider.this)); System.arraycopy(bytes, 0, b, 0, read); leftBytes -= read; asyncHandler.onBodyPartReceived(new ResponseBodyPart(b, leftBytes > -1)); asyncHandler.onBodyPartReceived(new ResponseBodyPart("".getBytes(), true)); T t = asyncHandler.onCompleted(); future.content(t); future.done(); logger.error(t2.getMessage(), t2); asyncHandler.onThrowable(t); } finally { if (terminate) {
@Override public STATE onStatusReceived(HttpResponseStatus responseStatus) throws Exception { return asyncHandler.onStatusReceived(responseStatus); }
@Override public void onThrowable(Throwable t) { if (decoratedAsyncHandler != null) { decoratedAsyncHandler.onThrowable(t); } else { logger.debug("", t); } }
@Override public STATE onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception { return asyncHandler.onBodyPartReceived(bodyPart); }
(wsTimeout <= 0) ? IdleTimeoutFilter.FOREVER : wsTimeout, TimeUnit.MILLISECONDS); context.done(handler.onCompleted()); } else { httpHeader.setSkipRemainder(true); if (context.currentState != AsyncHandler.STATE.ABORT) { try { context.currentState = handler.onHeadersReceived(responseHeaders); } catch (Exception e) { httpHeader.setSkipRemainder(true);
final AsyncHandler handler = context.getAsyncHandler(); if (handler != null) { context.currentState = handler.onStatusReceived(responseStatus); if (context.isWSRequest && context.currentState == AsyncHandler.STATE.ABORT) { httpHeader.setSkipRemainder(true); try { context.done(handler.onCompleted()); } catch (Throwable e) { context.abort(e);
state = asyncHandler.onStatusReceived(status); if (state == AsyncHandler.STATE.CONTINUE) { state = asyncHandler.onHeadersReceived(new ResponseHeaders(uri, urlConnection, JDKAsyncHttpProvider.this)); System.arraycopy(bytes, 0, b, 0, read); leftBytes -= read; asyncHandler.onBodyPartReceived(new ResponseBodyPart(b, leftBytes > -1)); asyncHandler.onBodyPartReceived(new ResponseBodyPart("".getBytes(), true)); T t = asyncHandler.onCompleted(); future.content(t); future.done();
private boolean exitAfterHandlingStatus(Channel channel, NettyResponseFuture<?> future, HttpResponse response, AsyncHandler<?> handler, NettyResponseStatus status) throws IOException, Exception { if (!future.getAndSetStatusReceived(true) && handler.onStatusReceived(status) != STATE.CONTINUE) { finishUpdate(future, channel, HttpHeaders.isTransferEncodingChunked(response)); return true; } return false; }
@Override public void cancelled() { final AsyncHandler ah = asyncHandler; if (ah != null) { try { ah.onThrowable(new CancellationException()); } catch (Throwable ignore) { } } runListeners(); }
private boolean updateBodyAndInterrupt(NettyResponseFuture<?> future, AsyncHandler<?> handler, NettyResponseBodyPart bodyPart) throws Exception { boolean interrupt = handler.onBodyPartReceived(bodyPart) != STATE.CONTINUE; if (bodyPart.isUnderlyingConnectionToBeClosed()) future.setKeepAlive(false); return interrupt; }
: wsTimeout), TimeUnit.MILLISECONDS); context.result(handler.onCompleted()); } else { httpHeader.setSkipRemainder(true); if (context.currentState != AsyncHandler.STATE.ABORT) { try { context.currentState = handler.onHeadersReceived( responseHeaders); } catch (Exception e) {
private V getContent() throws ExecutionException { ExecutionException e = exEx.get(); if (e != null) throw e; V update = content.get(); // No more retry currentRetry.set(maxRetry); if (!contentProcessed.getAndSet(true)) { try { update = asyncHandler.onCompleted(); } catch (Throwable ex) { if (!onThrowableCalled.getAndSet(true)) { try { try { asyncHandler.onThrowable(ex); } catch (Throwable t) { LOGGER.debug("asyncHandler.onThrowable", t); } throw new RuntimeException(ex); } finally { cancelTimeouts(); } } } content.compareAndSet(null, update); } return update; }
final AsyncHandler handler = context.handler; if (handler != null) { context.currentState = handler.onStatusReceived(responseStatus); if (context.isWSRequest && context.currentState == AsyncHandler.STATE.ABORT) { httpHeader.setSkipRemainder(true); try { context.result(handler.onCompleted()); context.done(); } catch (Throwable e) {
state = asyncHandler.onStatusReceived(status); if (state == AsyncHandler.STATE.CONTINUE) { state = asyncHandler.onHeadersReceived(new ApacheResponseHeaders(method)); leftBytes -= read; asyncHandler.onBodyPartReceived(new ApacheResponseBodyPart(b, leftBytes > -1)); asyncHandler.onBodyPartReceived(new ApacheResponseBodyPart("".getBytes(), true)); return asyncHandler.onCompleted(); } catch (Throwable t) { RuntimeException ex = new RuntimeException();
@Override public AsyncHandler.STATE onStatusReceived(final HttpResponseStatus status) throws Exception { responseBuilder.accumulate(status); if (status.getStatusCode() == 200 || status.getStatusCode() == 206) { url = status.getUri().toUrl(); } else { return AsyncHandler.STATE.ABORT; } if (decoratedAsyncHandler != null) { return decoratedAsyncHandler.onStatusReceived(status); } return AsyncHandler.STATE.CONTINUE; }
@Override public void onThrowable(Throwable t) { try { asyncHandler.onThrowable(t); } finally { complete(); } }