@Override public void flush(ChannelHandlerContext ctx) { try { // Trigger pending writes in the remote flow controller. encoder.flowController().writePendingBytes(); ctx.flush(); } catch (Http2Exception e) { onError(ctx, true, e); } catch (Throwable cause) { onError(ctx, true, connectionError(INTERNAL_ERROR, cause, "Error flushing")); } }
private void _writeData(Http2Stream stream, ByteBuf chunk, boolean end, ChannelPromise promise) { encoder().writeData(chctx, stream.id(), chunk, 0, end, promise); Http2RemoteFlowController controller = encoder().flowController(); if (!controller.isWritable(stream) || end) { try { encoder().flowController().writePendingBytes(); } catch (Http2Exception e) { onError(chctx, true, e); } } chctx.channel().flush(); }
private void writeErrorResponse(ChannelHandlerContext ctx, int streamId, HttpResponseStatus status) throws Http2Exception { final byte[] content = status.toString().getBytes(StandardCharsets.UTF_8); writer.writeHeaders( ctx, streamId, new DefaultHttp2Headers(false) .status(status.codeAsText()) .set(HttpHeaderNames.CONTENT_TYPE, MediaType.PLAIN_TEXT_UTF_8.toString()) .setInt(HttpHeaderNames.CONTENT_LENGTH, content.length), 0, false, ctx.voidPromise()); writer.writeData(ctx, streamId, Unpooled.wrappedBuffer(content), 0, true, ctx.voidPromise()); final Http2Stream stream = writer.connection().stream(streamId); if (stream != null && writer.flowController().hasFlowControlled(stream)) { // Ensure to flush the error response if it's flow-controlled so that it is sent // before an RST_STREAM frame. writer.flowController().writePendingBytes(); } }
private void _writeData(Http2Stream stream, ByteBuf chunk, boolean end, ChannelPromise promise) { encoder().writeData(chctx, stream.id(), chunk, 0, end, promise); Http2RemoteFlowController controller = encoder().flowController(); if (!controller.isWritable(stream) || end) { try { encoder().flowController().writePendingBytes(); } catch (Http2Exception e) { onError(chctx, true, e); } } chctx.channel().flush(); }
@Override public void flush(ChannelHandlerContext ctx) { try { // Trigger pending writes in the remote flow controller. encoder.flowController().writePendingBytes(); ctx.flush(); } catch (Http2Exception e) { onError(ctx, true, e); } catch (Throwable cause) { onError(ctx, true, connectionError(INTERNAL_ERROR, cause, "Error flushing")); } }
@Override public void flush(ChannelHandlerContext ctx) { try { // Trigger pending writes in the remote flow controller. encoder.flowController().writePendingBytes(); ctx.flush(); } catch (Http2Exception e) { onError(ctx, true, e); } catch (Throwable cause) { onError(ctx, true, connectionError(INTERNAL_ERROR, cause, "Error flushing")); } }
/** * Sends {@link org.wso2.transport.http.netty.message.Http2Reset} frame with `NO_ERROR` error code. * * @param ctx the channel handler context * @param encoder the HTTP2 connection encoder * @param streamId id of the stream need to be send RST_FRAME * @throws Http2Exception if a protocol-related error occurred */ public static void sendRstFrame(ChannelHandlerContext ctx, Http2ConnectionEncoder encoder, int streamId) throws Http2Exception { encoder.writeRstStream(ctx, streamId, Http2Error.NO_ERROR.code(), ctx.newPromise()); encoder.flowController().writePendingBytes(); ctx.flush(); }
/** * Writes HTTP2 headers to outbound response. * * @param ctx the channel handler context * @param encoder the HTTP2 connection encoder * @param outboundRespStatusFuture the future of outbound response write operation * @param streamId the id of the stream * @param http2Headers the Http2Headers received over a HTTP/2 stream * @param endStream is this the end of stream * @throws Http2Exception throws if a protocol-related error occurred */ public static void writeHttp2Headers(ChannelHandlerContext ctx, Http2ConnectionEncoder encoder, HttpResponseFuture outboundRespStatusFuture, int streamId, Http2Headers http2Headers, boolean endStream) throws Http2Exception { ChannelFuture channelFuture = encoder.writeHeaders( ctx, streamId, http2Headers, 0, endStream, ctx.newPromise()); encoder.flowController().writePendingBytes(); ctx.flush(); Util.addResponseWriteFailureListener(outboundRespStatusFuture, channelFuture); }
private void writeData(HttpContent httpContent, int streamId, boolean endStream) throws Http2Exception { contentLength += httpContent.content().readableBytes(); validatePromisedStreamState(originalStreamId, streamId, conn, inboundRequestMsg); ChannelFuture channelFuture = encoder.writeData( ctx, streamId, httpContent.content(), 0, endStream, ctx.newPromise()); encoder.flowController().writePendingBytes(); ctx.flush(); if (endStream) { Util.checkForResponseWriteStatus(inboundRequestMsg, outboundRespStatusFuture, channelFuture); } else { Util.addResponseWriteFailureListener(outboundRespStatusFuture, channelFuture); } }
encoder.flowController().writePendingBytes(); ctx.flush(); Util.checkForResponseWriteStatus(inboundRequestMsg, outboundRespStatusFuture, channelFuture);
encoder.flowController().writePendingBytes(); ctx.flush();
encoder.flowController().writePendingBytes(); ctx.flush(); if (!trailers.isEmpty()) {