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; }
private boolean exitAfterHandlingHeaders(Channel channel, NettyResponseFuture<?> future, HttpResponse response, AsyncHandler<?> handler, NettyResponseHeaders responseHeaders) throws IOException, Exception { if (!response.headers().isEmpty() && handler.onHeadersReceived(responseHeaders) != STATE.CONTINUE) { finishUpdate(future, channel, HttpHeaders.isTransferEncodingChunked(response)); return true; } return false; }
private boolean exitAfterHandlingBody(Channel channel, NettyResponseFuture<?> future, HttpResponse response, AsyncHandler<?> handler) throws Exception { if (!response.isChunked()) { // no chunks expected, exiting if (response.getContent().readableBytes() > 0) // FIXME no need to notify an empty bodypart? updateBodyAndInterrupt(future, handler, new NettyResponseBodyPart(response, null, true)); finishUpdate(future, channel, false); return true; } return false; }
logger.debug("Abort failed", abortException); } finally { finishUpdate(future, channel, false);
private void handleChunk(HttpChunk chunk,// final Channel channel,// final NettyResponseFuture<?> future,// AsyncHandler<?> handler) throws IOException, Exception { boolean last = chunk.isLast(); // we don't notify updateBodyAndInterrupt with the last chunk as it's empty if (last || updateBodyAndInterrupt(future, handler, new NettyResponseBodyPart(null, chunk, last))) { // only possible if last is true if (chunk instanceof HttpChunkTrailer) { HttpChunkTrailer chunkTrailer = (HttpChunkTrailer) chunk; if (!chunkTrailer.trailingHeaders().isEmpty()) { NettyResponseHeaders responseHeaders = new NettyResponseHeaders(future.getHttpHeaders(), chunkTrailer.trailingHeaders()); handler.onHeadersReceived(responseHeaders); } } finishUpdate(future, channel, !chunk.isLast()); } }
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; }
private boolean exitAfterHandlingHeaders(Channel channel, NettyResponseFuture<?> future, HttpResponse response, AsyncHandler<?> handler, NettyResponseHeaders responseHeaders) throws IOException, Exception { if (!response.headers().isEmpty() && handler.onHeadersReceived(responseHeaders) != STATE.CONTINUE) { finishUpdate(future, channel, HttpHeaders.isTransferEncodingChunked(response)); return true; } return false; }
private boolean exitAfterHandlingBody(Channel channel, NettyResponseFuture<?> future, HttpResponse response, AsyncHandler<?> handler) throws Exception { if (!response.isChunked()) { // no chunks expected, exiting if (response.getContent().readableBytes() > 0) // FIXME no need to notify an empty bodypart? updateBodyAndInterrupt(future, handler, new NettyResponseBodyPart(response, null, true)); finishUpdate(future, channel, false); return true; } return false; }
@Override public void handle(final Channel channel, final NettyResponseFuture<?> future, final Object e) throws Exception { future.touch(); // The connect timeout occurred. if (future.isDone()) { channelManager.closeChannel(channel); return; } AsyncHandler<?> handler = future.getAsyncHandler(); try { if (e instanceof HttpResponse && handleHttpResponse((HttpResponse) e, channel, future, handler)) return; if (e instanceof HttpChunk) handleChunk((HttpChunk) e, channel, future, handler); } catch (Exception t) { if (hasIOExceptionFilters// && t instanceof IOException// && requestSender.applyIoExceptionFiltersAndReplayRequest(future, IOException.class.cast(t), channel)) { return; } try { requestSender.abort(future, t); } catch (Exception abortException) { logger.debug("Abort failed", abortException); } finally { finishUpdate(future, channel, false); } throw t; } }
private void handleChunk(HttpChunk chunk,// final Channel channel,// final NettyResponseFuture<?> future,// AsyncHandler<?> handler) throws IOException, Exception { boolean last = chunk.isLast(); // we don't notify updateBodyAndInterrupt with the last chunk as it's empty if (last || updateBodyAndInterrupt(future, handler, new NettyResponseBodyPart(null, chunk, last))) { // only possible if last is true if (chunk instanceof HttpChunkTrailer) { HttpChunkTrailer chunkTrailer = (HttpChunkTrailer) chunk; if (!chunkTrailer.trailingHeaders().isEmpty()) { NettyResponseHeaders responseHeaders = new NettyResponseHeaders(future.getHttpHeaders(), chunkTrailer.trailingHeaders()); handler.onHeadersReceived(responseHeaders); } } finishUpdate(future, channel, !chunk.isLast()); } }