private void shutdownInput() { _ishut=true; if (_oshut) close(); }
/** * @return <code>true</code> if there are bytes remaining to be read from the encoded input */ public boolean hasMore() { return getOutput().position()>0; }
public ByteArrayEndPoint(Scheduler timer, long idleTimeoutMs, ByteBuffer input, ByteBuffer output) { super(timer); if (BufferUtil.hasContent(input)) addInput(input); _out=output==null?BufferUtil.allocate(1024):output; setIdleTimeout(idleTimeoutMs); onOpen(); }
endPoint.setGrowOutput(true); AbstractHttpConnection connection = new BlockingHttpConnection(LocalConnector.this, endPoint, getServer()); endPoint.setConnection(connection); connectionOpened(connection); try while (endPoint.getIn().length() > 0 && endPoint.isOpen()) final Connection con = endPoint.getConnection(); final Connection next = con.handle(); if (next!=con) endPoint.setConnection(next); continue; _responsesBuffer = endPoint.getOut();
if (!isOpen()) throw new EofException("CLOSED"); if (isInputShutdown()) return -1; if (isEOF(in)) notIdle(); else if (filled<0) shutdownInput(); return filled;
/** * */ public void reset() { getFillInterest().onClose(); getWriteFlusher().onClose(); _ishut=false; _oshut=false; _closed=false; _inQ.clear(); BufferUtil.clear(_out); }
try(Locker.Lock lock = _locker.lock()) if (!isOpen()) throw new IOException("CLOSED"); if (isOutputShutdown()) throw new IOException("OSHUT"); notIdle(); _hasOutput.signalAll();
/** * @param out The out to set. */ public void setOutput(ByteBuffer out) { _out = out; getWriteFlusher().completeWrite(); }
@Override public int fill(ByteBuffer buffer) throws IOException { if (_closed) throw new EofException("CLOSED"); if (_in==null) shutdownInput(); if (_ishut) return -1; int filled=BufferUtil.flipPutFlip(_in,buffer); if (filled>0) notIdle(); return filled; }
/** * @return Returns the out. */ public String getOutputString() { return getOutputString(StandardCharsets.UTF_8); }
@Override public void run() { getFillInterest().fillable(); } };
/** * @return Returns the out. */ public String takeOutputString() { return takeOutputString(StandardCharsets.UTF_8); }
/** * @param charset the charset to encode the output as * @return Returns the out. */ public String takeOutputString(Charset charset) { ByteBuffer buffer=takeOutput(); return BufferUtil.toString(buffer,charset); }
notIdle(); return flushed;
public ByteArrayEndPoint(Scheduler timer, long idleTimeoutMs, ByteBuffer input, ByteBuffer output) { super(timer,NOIP,NOIP); if (BufferUtil.hasContent(input)) addInput(input); _out=output==null?BufferUtil.allocate(1024):output; setIdleTimeout(idleTimeoutMs); }
/** Wait for some output * @param time Time to wait * @param unit Units for time to wait * @return The buffer of output * @throws InterruptedException if interrupted */ public ByteBuffer waitForOutput(long time,TimeUnit unit) throws InterruptedException { ByteBuffer b; try(Locker.Lock lock = _locker.lock()) { while (BufferUtil.isEmpty(_out) && !isOutputShutdown()) { if (!_hasOutput.await(time,unit)) return null; } b=_out; _out=BufferUtil.allocate(b.capacity()); } getWriteFlusher().completeWrite(); return b; }
public ByteArrayEndPoint(Scheduler timer, long idleTimeoutMs, ByteBuffer input, ByteBuffer output) { super(timer,NOIP,NOIP); _in=input==null?BufferUtil.EMPTY_BUFFER:input; _out=output==null?BufferUtil.allocate(1024):output; setIdleTimeout(idleTimeoutMs); }
endPoint.setGrowOutput(true); AbstractHttpConnection connection = new BlockingHttpConnection(LocalConnector.this, endPoint, getServer()); endPoint.setConnection(connection); connectionOpened(connection); try while (endPoint.getIn().length() > 0 && endPoint.isOpen()) final Connection con = endPoint.getConnection(); final Connection next = con.handle(); if (next!=con) endPoint.setConnection(next); continue; _responsesBuffer = endPoint.getOut();
if (!isOpen()) throw new EofException("CLOSED"); if (isInputShutdown()) return -1; if (isEOF(in)) notIdle(); else if (filled<0) shutdownInput(); return filled;