/** * Flush bytes or chars contained in the buffer. * * @throws IOException An underlying IOException occurred */ public void flush() throws IOException { if (response.getRequest().getUpgradeHandler() != null) { return; } doFlush(true); }
/** * Close the input buffer. * * @throws IOException An underlying IOException occurred */ public void close() throws IOException { if (request.getUpgradeHandler() != null && request.isEventMode()) { request.getEvent().close(); } else { closed = true; } }
public void setReadListener(ReadListener readListener) { if (this.readListener != null) { throw MESSAGES.readListenerAlreadySet(); } if (readListener == null) { throw MESSAGES.nullListener(); } if (!request.isEventMode()) { throw MESSAGES.cannotSetListenerWithoutUpgradeOrAsync(); } this.readListener = readListener; coyoteRequest.action(ActionCode.ACTION_EVENT_READ_BEGIN, (request.getUpgradeHandler() != null) ? readListener : null); }
public void setWriteListener(WriteListener writeListener) { if (this.writeListener != null) { throw MESSAGES.writeListenerAlreadySet(); } if (writeListener == null) { throw MESSAGES.nullListener(); } if (!response.getRequest().isEventMode()) { throw MESSAGES.cannotSetListenerWithoutUpgradeOrAsync(); } this.writeListener = writeListener; coyoteResponse.action(ActionCode.ACTION_EVENT_WRITE_BEGIN, (response.getRequest().getUpgradeHandler() != null) ? writeListener : null); }
private void writeBytes(byte b[], int off, int len) throws IOException { if (closed) return; if (response.getRequest().getUpgradeHandler() != null) { // If we really have something to write if (len > 0) { // real write to the adapter ByteChunk output = new ByteChunk(); output.setBytes(b, off, len); try { coyoteResponse.doWrite(output); } catch (IOException e) { // An IOException on a write is almost always due to // the remote client aborting the request. Wrap this // so that it can be handled better by the error dispatcher. throw new ClientAbortException(e); } } } else { bb.append(b, off, len); bytesWritten += len; // if called from within flush(), then immediately flush // remaining bytes if (doFlush) { bb.flushBuffer(); } } }
event = true; if (request.getUpgradeHandler() != null) { request.getUpgradeHandler().init(request.getEvent());
if (request.getUpgradeHandler() != null && request.isEventMode()) { request.getEvent().close(); return;
exception(request, response, e); if (end && (request.getUpgradeHandler() != null)) { try { request.getUpgradeHandler().destroy(); } catch (Throwable e) { container.getLogger().error(MESSAGES.upgradeHandlerDestroyError(getContainer().getName()), e);
if (request.getUpgradeHandler() != null) { if (request.getUpgradeHandler() != null) { request.clearInputStream(); response.clearOutputStream();