@Override public HttpFuture sendChunk(ByteBuffer buf, boolean lastChunk) { ChannelFuture future = null; if (buf != null) { if (log.isDebugEnabled()) { log.debug("sendChunk: Sending HTTP chunk {}", buf); } DefaultHttpContent chunk = new DefaultHttpContent(NettyServer.copyBuffer(buf)); future = channel.write(chunk); } if (lastChunk) { future = sendLastChunk(); } channel.flush(); if (lastChunk && !keepAlive) { shutDown(); } if (future == null) { DefaultChannelPromise doneFuture = new DefaultChannelPromise(channel); doneFuture.setSuccess(); future = doneFuture; } return new NettyHttpFuture(future); }
@Override public HttpFuture send(boolean lastChunk) { calculateKeepAlive(lastChunk); if (log.isDebugEnabled()) { log.debug("send: sending HTTP response {}", response); } ChannelFuture future = channel.write(response); if (data != null) { if (log.isDebugEnabled()) { log.debug("send: Sending HTTP chunk with data {}", data); } DefaultHttpContent chunk = new DefaultHttpContent(NettyServer.copyBuffer(data)); future = channel.write(chunk); } if (lastChunk) { future = sendLastChunk(); } channel.flush(); if (lastChunk && !keepAlive) { shutDown(); } return new NettyHttpFuture(future); }