public void ReadHeaderFrame() { int streamId = 1; var input = Unpooled.Buffer(); try { var headers = new DefaultHttp2Headers { Authority = (AsciiString)"foo", Method = (AsciiString)"get", Path = (AsciiString)"/", Scheme = (AsciiString)"https" }; Http2Flags flags = new Http2Flags().EndOfHeaders(true).EndOfStream(true); this.WriteHeaderFrame(input, streamId, headers, flags); this.frameReader.ReadFrame(this.ctx.Object, input, this.listener.Object); this.listener.Verify(x => x.OnHeadersRead(this.ctx.Object, 1, headers, 0, true)); } finally { input.Release(); } }
public void FailedWhenUnknownFrameInMiddleOfHeaderBlock() { int streamId = 1; var input = Unpooled.Buffer(); try { var headers = new DefaultHttp2Headers { Authority = (AsciiString)"foo", Method = (AsciiString)"get", Path = (AsciiString)"/", Scheme = (AsciiString)"https" }; Http2Flags flags = new Http2Flags().EndOfHeaders(false).EndOfStream(true); this.WriteHeaderFrame(input, streamId, headers, flags); Http2CodecUtil.WriteFrameHeader(input, 0, (Http2FrameTypes)0xff, new Http2Flags(), streamId); Assert.Throws <Http2Exception>(() => this.frameReader.ReadFrame(this.ctx.Object, input, this.listener.Object)); } finally { input.Release(); } }
private void WriteContinuationFrame(IByteBuffer output, int streamId, IHttp2Headers headers, Http2Flags flags) { IByteBuffer headerBlock = Unpooled.Buffer(); try { hpackEncoder.EncodeHeaders(streamId, headerBlock, headers, NeverSensitiveDetector.Instance); Http2CodecUtil.WriteFrameHeader(output, headerBlock.ReadableBytes, Http2FrameTypes.Continuation, flags, streamId); output.WriteBytes(headerBlock, headerBlock.ReadableBytes); } finally { headerBlock.Release(); } }
private void WriteHeaderFramePriorityPresent(IByteBuffer output, int streamId, IHttp2Headers headers, Http2Flags flags, int streamDependency, int weight) { IByteBuffer headerBlock = Unpooled.Buffer(); try { headerBlock.WriteInt(streamDependency); headerBlock.WriteByte(weight - 1); hpackEncoder.EncodeHeaders(streamId, headerBlock, headers, NeverSensitiveDetector.Instance); Http2CodecUtil.WriteFrameHeader(output, headerBlock.ReadableBytes, Http2FrameTypes.Headers, flags, streamId); output.WriteBytes(headerBlock, headerBlock.ReadableBytes); } finally { headerBlock.Release(); } }
public void OnUnknownFrame(IChannelHandlerContext ctx, Http2FrameTypes frameType, int streamId, Http2Flags flags, IByteBuffer payload) { }
public void WriteInboundFrame(Http2FrameTypes frameType, int streamId, Http2Flags flags, IByteBuffer payload) { _writer.WriteFrameAsync(_ctx, frameType, streamId, flags, payload, _ctx.NewPromise()).GetAwaiter().GetResult(); }
public void OnUnknownFrame(IChannelHandlerContext ctx, Http2FrameTypes frameType, int streamId, Http2Flags flags, IByteBuffer payload) { this.listener.OnUnknownFrame(ctx, frameType, streamId, flags, payload); this.messageLatch.SafeSignal(); }