private void complete() { reset(new ResetFrame(streamId, error), getCallback()); } }
@Override public int generate(ByteBufferPool.Lease lease, Frame frame) { ResetFrame resetFrame = (ResetFrame)frame; return generateReset(lease, resetFrame.getStreamId(), resetFrame.getError()); }
@Override public void onReset(Stream stream, ResetFrame frame) { HttpExchange exchange = getHttpExchange(); if (exchange == null) return; int error = frame.getError(); exchange.getRequest().abort(new IOException(ErrorCode.toString(error, "reset_code_" + error))); }
protected void reset(ResetFrame frame, Callback callback) { control(getStream(frame.getStreamId()), callback, frame); }
@Override public void onReset(Stream stream, ResetFrame frame, Callback callback) { getConnection().onStreamFailure((IStream)stream, new EofException("Reset " + ErrorCode.toString(frame.getError(), null)), callback); }
protected void reset(ResetFrame frame, Callback callback) { control(getStream(frame.getStreamId()), callback, frame); }
private void complete() { reset(new ResetFrame(streamId, error), getCallback()); } }
@Override public int generate(ByteBufferPool.Lease lease, Frame frame) { ResetFrame resetFrame = (ResetFrame)frame; return generateReset(lease, resetFrame.getStreamId(), resetFrame.getError()); }
@Override public void onReset(ResetFrame frame) { if (LOG.isDebugEnabled()) LOG.debug("Received {}", frame); int streamId = frame.getStreamId(); IStream stream = getStream(streamId); if (stream != null) { stream.process(frame, new OnResetCallback()); } else { if (isRemoteStreamClosed(streamId)) notifyReset(this, frame); else onConnectionFailure(ErrorCode.PROTOCOL_ERROR.code, "unexpected_rst_stream_frame"); } }
private boolean onReset(int error) { ResetFrame frame = new ResetFrame(getStreamId(), error); reset(); notifyReset(frame); return true; }
@Override public void onReset(ResetFrame frame) { if (LOG.isDebugEnabled()) LOG.debug("Received {}", frame); int streamId = frame.getStreamId(); IStream stream = getStream(streamId); if (stream != null) { stream.process(frame, new OnResetCallback()); } else { if (isRemoteStreamClosed(streamId)) notifyReset(this, frame); else onConnectionFailure(ErrorCode.PROTOCOL_ERROR.code, "unexpected_rst_stream_frame"); } }
private boolean onReset(int error) { ResetFrame frame = new ResetFrame(getStreamId(), error); reset(); notifyReset(frame); return true; }
@Override public void abort(Throwable failure) { IStream stream = this.stream; if (LOG.isDebugEnabled()) LOG.debug("HTTP2 Response #{}/{} aborted", stream == null ? -1 : stream.getId(), stream == null ? -1 : Integer.toHexString(stream.getSession().hashCode())); if (stream != null) stream.reset(new ResetFrame(stream.getId(), ErrorCode.INTERNAL_ERROR.code), Callback.NOOP); }
@Override public void close() { IStream stream = getStream(); if (LOG.isDebugEnabled()) LOG.debug("HTTP2 Request #{}/{} rejected", stream.getId(), Integer.toHexString(stream.getSession().hashCode())); stream.reset(new ResetFrame(stream.getId(), ErrorCode.ENHANCE_YOUR_CALM_ERROR.code), Callback.NOOP); // Consume the existing queued data frames to // avoid stalling the session flow control. consumeInput(); } }
@Override protected void onIdleExpired(TimeoutException timeout) { if (LOG.isDebugEnabled()) LOG.debug("Idle timeout {}ms expired on {}", getIdleTimeout(), this); // Notify the application. if (notifyIdleTimeout(this, timeout)) { // Tell the other peer that we timed out. reset(new ResetFrame(getId(), ErrorCode.CANCEL_STREAM_ERROR.code), Callback.NOOP); } }
@Override protected void onIdleExpired(TimeoutException timeout) { if (LOG.isDebugEnabled()) LOG.debug("Idle timeout {}ms expired on {}", getIdleTimeout(), this); // Notify the application. if (notifyIdleTimeout(this, timeout)) { // Tell the other peer that we timed out. reset(new ResetFrame(getId(), ErrorCode.CANCEL_STREAM_ERROR.code), Callback.NOOP); } }
reset(new ResetFrame(streamId, ErrorCode.STREAM_CLOSED_ERROR.code), Callback.NOOP); callback.failed(new EOFException("stream_closed")); return; if (frame.isEndStream() && dataLength != 0) reset(new ResetFrame(streamId, ErrorCode.PROTOCOL_ERROR.code), Callback.NOOP); callback.failed(new IOException("invalid_data_length")); return;
reset(new ResetFrame(streamId, ErrorCode.STREAM_CLOSED_ERROR.code), Callback.NOOP); callback.failed(new EOFException("stream_closed")); return; if (frame.isEndStream() && dataLength != 0) reset(new ResetFrame(streamId, ErrorCode.PROTOCOL_ERROR.code), Callback.NOOP); callback.failed(new IOException("invalid_data_length")); return;
@Override public void exchangeTerminated(HttpExchange exchange, Result result) { super.exchangeTerminated(exchange, result); if (result.isSucceeded()) { release(); } else { Stream stream = getStream(); if (stream != null) stream.reset(new ResetFrame(stream.getId(), ErrorCode.CANCEL_STREAM_ERROR.code), new ReleaseCallback()); else release(); } }
@Override public void onCompleted() { // If the stream is not closed, it is still reading the request content. // Send a reset to the other end so that it stops sending data. if (!stream.isClosed()) { if (LOG.isDebugEnabled()) LOG.debug("HTTP2 Response #{}: unconsumed request content, resetting stream", stream.getId()); stream.reset(new ResetFrame(stream.getId(), ErrorCode.CANCEL_STREAM_ERROR.code), Callback.NOOP); } // Consume the existing queued data frames to // avoid stalling the session flow control. HttpChannelOverHTTP2 channel = (HttpChannelOverHTTP2)stream.getAttachment(); if (channel != null) channel.consumeInput(); }