private void complete() { reset(new ResetFrame(streamId, error), getCallback()); } }
private void complete() { reset(new ResetFrame(streamId, error), getCallback()); } }
private boolean onReset(int error) { ResetFrame frame = new ResetFrame(getStreamId(), error); reset(); notifyReset(frame); return true; }
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(); }
if (maxCount >= 0 && remoteCount - remoteClosing >= maxCount) reset(new ResetFrame(streamId, ErrorCode.REFUSED_STREAM_ERROR.code), Callback.NOOP); return null;
@Override public Stream.Listener onPush(Stream stream, PushPromiseFrame frame) { HttpExchange exchange = getHttpExchange(); if (exchange == null) return null; HttpRequest request = exchange.getRequest(); MetaData.Request metaData = (MetaData.Request)frame.getMetaData(); HttpRequest pushRequest = (HttpRequest)getHttpDestination().getHttpClient().newRequest(metaData.getURIString()); // TODO: copy PUSH_PROMISE headers into pushRequest. BiFunction<Request, Request, Response.CompleteListener> pushListener = request.getPushListener(); if (pushListener != null) { Response.CompleteListener listener = pushListener.apply(request, pushRequest); if (listener != null) { HttpChannelOverHTTP2 pushChannel = getHttpChannel().getHttpConnection().acquireHttpChannel(); List<Response.ResponseListener> listeners = Collections.singletonList(listener); HttpExchange pushExchange = new HttpExchange(getHttpDestination(), pushRequest, listeners); pushChannel.associate(pushExchange); pushChannel.setStream(stream); // TODO: idle timeout ? pushExchange.requestComplete(null); pushExchange.terminateRequest(); return pushChannel.getStreamListener(); } } stream.reset(new ResetFrame(stream.getId(), ErrorCode.REFUSED_STREAM_ERROR.code), Callback.NOOP); return null; }
if (maxCount >= 0 && remoteCount - remoteClosing >= maxCount) reset(new ResetFrame(streamId, ErrorCode.REFUSED_STREAM_ERROR.code), Callback.NOOP); return null;
reset(new ResetFrame(streamId, ErrorCode.PROTOCOL_ERROR.code), Callback.NOOP); if (sumOverflows(streamSendWindow, windowDelta)) reset(new ResetFrame(streamId, ErrorCode.FLOW_CONTROL_ERROR.code), Callback.NOOP);
reset(new ResetFrame(streamId, ErrorCode.PROTOCOL_ERROR.code), Callback.NOOP); if (sumOverflows(streamSendWindow, windowDelta)) reset(new ResetFrame(streamId, ErrorCode.FLOW_CONTROL_ERROR.code), Callback.NOOP);
boolean closed = local ? isLocalStreamClosed(streamId) : isRemoteStreamClosed(streamId); if (closed) reset(new ResetFrame(streamId, ErrorCode.STREAM_CLOSED_ERROR.code), callback); else onConnectionFailure(ErrorCode.PROTOCOL_ERROR.code, "unexpected_data_frame", callback);
boolean closed = local ? isLocalStreamClosed(streamId) : isRemoteStreamClosed(streamId); if (closed) reset(new ResetFrame(streamId, ErrorCode.STREAM_CLOSED_ERROR.code), callback); else onConnectionFailure(ErrorCode.PROTOCOL_ERROR.code, "unexpected_data_frame", callback);