@Override protected void onCompleteSuccess() { super.onCompleteSuccess(); if (_complete) closed(); } }
@Override protected void onCompleteSuccess() { super.onCompleteSuccess(); if (_complete) closed(); }
private void abort(Throwable failure) { closed(); _channel.abort(failure); }
@Override public void succeeded() { closed(); callback.succeeded(); }
private void abort(Throwable failure) { closed(); _channel.abort(failure); }
@Override public void succeeded() { closed(); super.succeeded(); }
@Override public void succeeded() { closed(); super.succeeded(); }
@Override public void succeeded() { super.failed(x); _response.getHttpOutput().closed(); }
@Override public void succeeded() { super.failed(x); _response.getHttpOutput().closed(); }
@Override protected Action process() throws Exception { // Only return if EOF has previously been read and thus // a write done with EOF=true if (_eof) { _in.close(); closed(); _channel.getByteBufferPool().release(_buffer); return Action.SUCCEEDED; } // Read from stream until buffer full or EOF _buffer.clear(); while (_buffer.hasRemaining() && !_eof) _eof = (_in.read(_buffer)) < 0; // write what we have _buffer.flip(); write(_buffer,_eof,this); return Action.SCHEDULED; }
@Override protected Action process() throws Exception { // Only return if EOF has previously been read and thus // a write done with EOF=true if (_eof) { // Handle EOF _in.close(); closed(); _channel.getByteBufferPool().release(_buffer); return Action.SUCCEEDED; } // Read until buffer full or EOF int len=0; while (len<_buffer.capacity() && !_eof) { int r=_in.read(_buffer.array(),_buffer.arrayOffset()+len,_buffer.capacity()-len); if (r<0) _eof=true; else len+=r; } // write what we have _buffer.position(0); _buffer.limit(len); write(_buffer,_eof,this); return Action.SCHEDULED; }
@Override protected void onCompleteSuccess() { while (true) { OutputState last = _state.get(); switch (last) { case PENDING: if (!_state.compareAndSet(OutputState.PENDING, OutputState.ASYNC)) continue; break; case UNREADY: if (!_state.compareAndSet(OutputState.UNREADY, OutputState.READY)) continue; if (_last) closed(); if (_channel.getState().onWritePossible()) _channel.execute(_channel); break; case CLOSED: break; default: throw new IllegalStateException(); } break; } }
closed(); _channel.getByteBufferPool().release(_buffer); return Action.SUCCEEDED;
closed(); _channel.getByteBufferPool().release(_buffer); return Action.SUCCEEDED;
/** * Blocking send of whole content. * * @param content The whole content to send * @throws IOException if the send fails */ public void sendContent(ByteBuffer content) throws IOException { if (LOG.isDebugEnabled()) LOG.debug("sendContent({})", BufferUtil.toDetailString(content)); _written += content.remaining(); write(content, true); closed(); }
/** * Blocking send of whole content. * * @param content The whole content to send * @throws IOException if the send fails */ public void sendContent(ByteBuffer content) throws IOException { if (LOG.isDebugEnabled()) LOG.debug("sendContent({})",BufferUtil.toDetailString(content)); write(content, true); closed(); }
@Override protected Action process() throws Exception { // Only return if EOF has previously been read and thus // a write done with EOF=true if (_eof) { if (LOG.isDebugEnabled()) LOG.debug("EOF of {}", this); _in.close(); closed(); _channel.getByteBufferPool().release(_buffer); return Action.SUCCEEDED; } // Read from stream until buffer full or EOF BufferUtil.clearToFill(_buffer); while (_buffer.hasRemaining() && !_eof) _eof = (_in.read(_buffer)) < 0; // write what we have BufferUtil.flipToFlush(_buffer, 0); _written += _buffer.remaining(); write(_buffer, _eof, this); return Action.SCHEDULED; }
@Override protected Action process() throws Exception { // Only return if EOF has previously been read and thus // a write done with EOF=true if (_eof) { if (LOG.isDebugEnabled()) LOG.debug("EOF of {}",this); _in.close(); closed(); _channel.getByteBufferPool().release(_buffer); return Action.SUCCEEDED; } // Read from stream until buffer full or EOF BufferUtil.clearToFill(_buffer); while (_buffer.hasRemaining() && !_eof) _eof = (_in.read(_buffer)) < 0; // write what we have BufferUtil.flipToFlush(_buffer, 0); write(_buffer,_eof,this); return Action.SCHEDULED; }
@Override public void close() { if (!isClosed()) { try { if (BufferUtil.hasContent(_aggregate)) _channel.write(_aggregate, !_channel.getResponse().isIncluding()); else _channel.write(BufferUtil.EMPTY_BUFFER, !_channel.getResponse().isIncluding()); } catch(IOException e) { _channel.getEndPoint().shutdownOutput(); LOG.ignore(e); } } closed(); }
@Override public void close() { if (!isClosed()) { try { if (BufferUtil.hasContent(_aggregate)) _channel.write(_aggregate, !_channel.getResponse().isIncluding()); else _channel.write(BufferUtil.EMPTY_BUFFER, !_channel.getResponse().isIncluding()); } catch(IOException e) { _channel.getEndPoint().shutdownOutput(); LOG.ignore(e); } } closed(); }