HTTP/2: close the connection with PROTOCOL_ERROR when a PUSH_PROMISE frame is received.

This commit is contained in:
Cesar Blum Silveira 2017-09-21 09:38:20 -07:00 committed by Cesar Blum Silveira
parent 9687079723
commit e2af346733
2 changed files with 21 additions and 0 deletions

View File

@ -208,6 +208,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2
return ProcessRstStreamFrameAsync();
case Http2FrameType.SETTINGS:
return ProcessSettingsFrameAsync();
case Http2FrameType.PUSH_PROMISE:
throw new Http2ConnectionErrorException(Http2ErrorCode.PROTOCOL_ERROR);
case Http2FrameType.PING:
return ProcessPingFrameAsync();
case Http2FrameType.GOAWAY:

View File

@ -852,6 +852,16 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
await WaitForConnectionErrorAsync(expectedLastStreamId: 0, expectedErrorCode: Http2ErrorCode.FRAME_SIZE_ERROR, ignoreNonGoAwayFrames: false);
}
[Fact]
public async Task PUSH_PROMISE_Received_ConnectionError()
{
await InitializeConnectionAsync(_noopApplication);
await SendPushPromiseFrameAsync();
await WaitForConnectionErrorAsync(expectedLastStreamId: 0, expectedErrorCode: Http2ErrorCode.PROTOCOL_ERROR, ignoreNonGoAwayFrames: false);
}
[Fact]
public async Task PING_Received_Sends_ACK()
{
@ -1280,6 +1290,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
return SendAsync(frame.Raw);
}
private Task SendPushPromiseFrameAsync()
{
var frame = new Http2Frame();
frame.Length = 0;
frame.Type = Http2FrameType.PUSH_PROMISE;
frame.StreamId = 1;
return SendAsync(frame.Raw);
}
private async Task<bool> SendHeadersAsync(int streamId, Http2HeadersFrameFlags flags, IEnumerable<KeyValuePair<string, string>> headers)
{
var frame = new Http2Frame();