@Test public void writeFrameZeroPayload() throws Exception { frameWriter.writeFrame(ctx, (byte) 0xf, 0, new Http2Flags(), Unpooled.EMPTY_BUFFER, promise); byte[] expectedFrameBytes = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0f, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }; expectedOutbound = Unpooled.wrappedBuffer(expectedFrameBytes); assertEquals(expectedOutbound, outbound); }
@Override public ChannelFuture writeFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags, ByteBuf payload, ChannelPromise promise) { SimpleChannelPromiseAggregator promiseAggregator = new SimpleChannelPromiseAggregator(promise, ctx.channel(), ctx.executor()); try { verifyStreamOrConnectionId(streamId, STREAM_ID); ByteBuf buf = ctx.alloc().buffer(FRAME_HEADER_LENGTH); writeFrameHeaderInternal(buf, payload.readableBytes(), frameType, flags, streamId); ctx.write(buf, promiseAggregator.newPromise()); } catch (Throwable t) { try { payload.release(); } finally { promiseAggregator.setFailure(t); promiseAggregator.doneAllocatingPromises(); } return promiseAggregator; } try { ctx.write(payload, promiseAggregator.newPromise()); } catch (Throwable t) { promiseAggregator.setFailure(t); } return promiseAggregator.doneAllocatingPromises(); }
DefaultHttp2FrameWriter implements Http2FrameWriter, Http2FrameSizePolicy, Configuration { @Override public ChannelFuture writeFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags, ByteBuf payload, ChannelPromise promise) { SimpleChannelPromiseAggregator promiseAggregator = new SimpleChannelPromiseAggregator(promise, ctx.channel(), ctx.executor()); try { verifyStreamOrConnectionId(streamId, STREAM_ID); ByteBuf buf = ctx.alloc().buffer(FRAME_HEADER_LENGTH); writeFrameHeaderInternal(buf, payload.readableBytes(), frameType, flags, streamId); ctx.write(buf, promiseAggregator.newPromise()); } catch (Throwable t) { try { payload.release(); } finally { promiseAggregator.setFailure(t); promiseAggregator.doneAllocatingPromises(); } return promiseAggregator; } try { ctx.write(payload, promiseAggregator.newPromise()); } catch (Throwable t) { promiseAggregator.setFailure(t); } return promiseAggregator.doneAllocatingPromises(); } }
DefaultHttp2FrameWriter implements Http2FrameWriter, Http2FrameSizePolicy, Configuration { @Override public ChannelFuture writeFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags, ByteBuf payload, ChannelPromise promise) { SimpleChannelPromiseAggregator promiseAggregator = new SimpleChannelPromiseAggregator(promise, ctx.channel(), ctx.executor()); try { verifyStreamOrConnectionId(streamId, STREAM_ID); ByteBuf buf = ctx.alloc().buffer(FRAME_HEADER_LENGTH); writeFrameHeaderInternal(buf, payload.readableBytes(), frameType, flags, streamId); ctx.write(buf, promiseAggregator.newPromise()); } catch (Throwable t) { try { payload.release(); } finally { promiseAggregator.setFailure(t); promiseAggregator.doneAllocatingPromises(); } return promiseAggregator; } try { ctx.write(payload, promiseAggregator.newPromise()); } catch (Throwable t) { promiseAggregator.setFailure(t); } return promiseAggregator.doneAllocatingPromises(); } DefaultHttp2FrameWriter();  DefaultHttp2FrameWriter(SensitivityDetector headersSensitivityDetector);  DefaultHttp2FrameWriter(SensitivityDetector headersSensitivityDetector, boolean ignoreMaxHeaderListSize);  DefaultHttp2FrameWriter(Http2HeadersEncoder headersEncoder); }
DefaultHttp2FrameWriter implements Http2FrameWriter, Http2FrameSizePolicy, Configuration { @Override public ChannelFuture writeFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags, ByteBuf payload, ChannelPromise promise) { SimpleChannelPromiseAggregator promiseAggregator = new SimpleChannelPromiseAggregator(promise, ctx.channel(), ctx.executor()); try { verifyStreamOrConnectionId(streamId, STREAM_ID); ByteBuf buf = ctx.alloc().buffer(FRAME_HEADER_LENGTH); writeFrameHeaderInternal(buf, payload.readableBytes(), frameType, flags, streamId); ctx.write(buf, promiseAggregator.newPromise()); } catch (Throwable t) { try { payload.release(); } finally { promiseAggregator.setFailure(t); promiseAggregator.doneAllocatingPromises(); } return promiseAggregator; } try { ctx.write(payload, promiseAggregator.newPromise()); } catch (Throwable t) { promiseAggregator.setFailure(t); } return promiseAggregator.doneAllocatingPromises(); } DefaultHttp2FrameWriter();  DefaultHttp2FrameWriter(SensitivityDetector headersSensitivityDetector);  DefaultHttp2FrameWriter(SensitivityDetector headersSensitivityDetector, boolean ignoreMaxHeaderListSize);  DefaultHttp2FrameWriter(Http2HeadersEncoder headersEncoder); @Override Configuration configuration(); @Override Http2HeadersEncoder.Configuration headersConfiguration(); @Override Http2FrameSizePolicy frameSizePolicy(); @Override void maxFrameSize(int max); @Override int maxFrameSize(); @Override void close(); @Override ChannelFuture writeData(ChannelHandlerContext ctx, int streamId, ByteBuf data,
            int padding, boolean endStream, ChannelPromise promise); @Override ChannelFuture writeHeaders(ChannelHandlerContext ctx, int streamId,
            Http2Headers headers, int padding, boolean endStream, ChannelPromise promise); @Override ChannelFuture writeHeaders(ChannelHandlerContext ctx, int streamId,
            Http2Headers headers, int streamDependency, short weight, boolean exclusive,
            int padding, boolean endStream, ChannelPromise promise); @Override ChannelFuture writePriority(ChannelHandlerContext ctx, int streamId,
            int streamDependency, short weight, boolean exclusive, ChannelPromise promise); @Override ChannelFuture writeRstStream(ChannelHandlerContext ctx, int streamId, long errorCode,
            ChannelPromise promise); @Override ChannelFuture writeSettings(ChannelHandlerContext ctx, Http2Settings settings,
            ChannelPromise promise); @Override ChannelFuture writeSettingsAck(ChannelHandlerContext ctx, ChannelPromise promise); @Override ChannelFuture writePing(ChannelHandlerContext ctx, boolean ack, long data, ChannelPromise promise); @Override ChannelFuture writePushPromise(ChannelHandlerContext ctx, int streamId,
            int promisedStreamId, Http2Headers headers, int padding, ChannelPromise promise); @Override ChannelFuture writeGoAway(ChannelHandlerContext ctx, int lastStreamId, long errorCode,
            ByteBuf debugData, ChannelPromise promise); @Override ChannelFuture writeWindowUpdate(ChannelHandlerContext ctx, int streamId,
            int windowSizeIncrement, ChannelPromise promise); @Override ChannelFuture writeFrame(ChannelHandlerContext ctx, byte frameType, int streamId,
            Http2Flags flags, ByteBuf payload, ChannelPromise promise); }
DefaultHttp2FrameWriter implements Http2FrameWriter, Http2FrameSizePolicy, Configuration { @Override public ChannelFuture writeFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags, ByteBuf payload, ChannelPromise promise) { SimpleChannelPromiseAggregator promiseAggregator = new SimpleChannelPromiseAggregator(promise, ctx.channel(), ctx.executor()); try { verifyStreamOrConnectionId(streamId, STREAM_ID); ByteBuf buf = ctx.alloc().buffer(FRAME_HEADER_LENGTH); writeFrameHeaderInternal(buf, payload.readableBytes(), frameType, flags, streamId); ctx.write(buf, promiseAggregator.newPromise()); } catch (Throwable t) { try { payload.release(); } finally { promiseAggregator.setFailure(t); promiseAggregator.doneAllocatingPromises(); } return promiseAggregator; } try { ctx.write(payload, promiseAggregator.newPromise()); } catch (Throwable t) { promiseAggregator.setFailure(t); } return promiseAggregator.doneAllocatingPromises(); } DefaultHttp2FrameWriter();  DefaultHttp2FrameWriter(SensitivityDetector headersSensitivityDetector);  DefaultHttp2FrameWriter(SensitivityDetector headersSensitivityDetector, boolean ignoreMaxHeaderListSize);  DefaultHttp2FrameWriter(Http2HeadersEncoder headersEncoder); @Override Configuration configuration(); @Override Http2HeadersEncoder.Configuration headersConfiguration(); @Override Http2FrameSizePolicy frameSizePolicy(); @Override void maxFrameSize(int max); @Override int maxFrameSize(); @Override void close(); @Override ChannelFuture writeData(ChannelHandlerContext ctx, int streamId, ByteBuf data,
            int padding, boolean endStream, ChannelPromise promise); @Override ChannelFuture writeHeaders(ChannelHandlerContext ctx, int streamId,
            Http2Headers headers, int padding, boolean endStream, ChannelPromise promise); @Override ChannelFuture writeHeaders(ChannelHandlerContext ctx, int streamId,
            Http2Headers headers, int streamDependency, short weight, boolean exclusive,
            int padding, boolean endStream, ChannelPromise promise); @Override ChannelFuture writePriority(ChannelHandlerContext ctx, int streamId,
            int streamDependency, short weight, boolean exclusive, ChannelPromise promise); @Override ChannelFuture writeRstStream(ChannelHandlerContext ctx, int streamId, long errorCode,
            ChannelPromise promise); @Override ChannelFuture writeSettings(ChannelHandlerContext ctx, Http2Settings settings,
            ChannelPromise promise); @Override ChannelFuture writeSettingsAck(ChannelHandlerContext ctx, ChannelPromise promise); @Override ChannelFuture writePing(ChannelHandlerContext ctx, boolean ack, long data, ChannelPromise promise); @Override ChannelFuture writePushPromise(ChannelHandlerContext ctx, int streamId,
            int promisedStreamId, Http2Headers headers, int padding, ChannelPromise promise); @Override ChannelFuture writeGoAway(ChannelHandlerContext ctx, int lastStreamId, long errorCode,
            ByteBuf debugData, ChannelPromise promise); @Override ChannelFuture writeWindowUpdate(ChannelHandlerContext ctx, int streamId,
            int windowSizeIncrement, ChannelPromise promise); @Override ChannelFuture writeFrame(ChannelHandlerContext ctx, byte frameType, int streamId,
            Http2Flags flags, ByteBuf payload, ChannelPromise promise);  }