Skip to content

Commit

Permalink
Rename IHttpHeadersHandler to IHttpStreamHeadersHandler (#62750)
Browse files Browse the repository at this point in the history
Co-authored-by: James Newton-King <[email protected]>
  • Loading branch information
github-actions[bot] and JamesNK authored Dec 14, 2021
1 parent 81ed7cf commit dfbae37
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ internal HPackDecoder(int maxDynamicTableSize, int maxHeadersLength, DynamicTabl
_headerValueOctets = new byte[DefaultStringOctetsSize];
}

public void Decode(in ReadOnlySequence<byte> data, bool endHeaders, IHttpHeadersHandler handler)
public void Decode(in ReadOnlySequence<byte> data, bool endHeaders, IHttpStreamHeadersHandler handler)
{
foreach (ReadOnlyMemory<byte> segment in data)
{
Expand All @@ -128,13 +128,13 @@ public void Decode(in ReadOnlySequence<byte> data, bool endHeaders, IHttpHeaders
CheckIncompleteHeaderBlock(endHeaders);
}

public void Decode(ReadOnlySpan<byte> data, bool endHeaders, IHttpHeadersHandler handler)
public void Decode(ReadOnlySpan<byte> data, bool endHeaders, IHttpStreamHeadersHandler handler)
{
DecodeInternal(data, handler);
CheckIncompleteHeaderBlock(endHeaders);
}

private void DecodeInternal(ReadOnlySpan<byte> data, IHttpHeadersHandler handler)
private void DecodeInternal(ReadOnlySpan<byte> data, IHttpStreamHeadersHandler handler)
{
int currentIndex = 0;

Expand Down Expand Up @@ -206,7 +206,7 @@ private void ParseDynamicTableSizeUpdate(ReadOnlySpan<byte> data, ref int curren
}
}

private void ParseHeaderValueLength(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void ParseHeaderValueLength(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
if (currentIndex < data.Length)
{
Expand Down Expand Up @@ -236,7 +236,7 @@ private void ParseHeaderValueLength(ReadOnlySpan<byte> data, ref int currentInde
}
}

private void ParseHeaderNameLengthContinue(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void ParseHeaderNameLengthContinue(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
if (TryDecodeInteger(data, ref currentIndex, out int intResult))
{
Expand All @@ -249,7 +249,7 @@ private void ParseHeaderNameLengthContinue(ReadOnlySpan<byte> data, ref int curr
}
}

private void ParseHeaderValueLengthContinue(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void ParseHeaderValueLengthContinue(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
if (TryDecodeInteger(data, ref currentIndex, out int intResult))
{
Expand All @@ -261,15 +261,15 @@ private void ParseHeaderValueLengthContinue(ReadOnlySpan<byte> data, ref int cur
}
}

private void ParseHeaderFieldIndex(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void ParseHeaderFieldIndex(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
if (TryDecodeInteger(data, ref currentIndex, out int intResult))
{
OnIndexedHeaderField(intResult, handler);
}
}

private void ParseHeaderNameIndex(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void ParseHeaderNameIndex(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
if (TryDecodeInteger(data, ref currentIndex, out int intResult))
{
Expand All @@ -278,7 +278,7 @@ private void ParseHeaderNameIndex(ReadOnlySpan<byte> data, ref int currentIndex,
}
}

private void ParseHeaderNameLength(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void ParseHeaderNameLength(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
if (currentIndex < data.Length)
{
Expand All @@ -304,7 +304,7 @@ private void ParseHeaderNameLength(ReadOnlySpan<byte> data, ref int currentIndex
}
}

private void Parse(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void Parse(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
if (currentIndex < data.Length)
{
Expand Down Expand Up @@ -388,7 +388,7 @@ private void Parse(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHa
}
}

private void ParseLiteralHeaderField(ReadOnlySpan<byte> data, ref int currentIndex, byte b, byte mask, byte indexPrefix, bool index, IHttpHeadersHandler handler)
private void ParseLiteralHeaderField(ReadOnlySpan<byte> data, ref int currentIndex, byte b, byte mask, byte indexPrefix, bool index, IHttpStreamHeadersHandler handler)
{
_headersObserved = true;

Expand All @@ -415,7 +415,7 @@ private void ParseLiteralHeaderField(ReadOnlySpan<byte> data, ref int currentInd
}
}

private void ParseHeaderName(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void ParseHeaderName(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
// Read remaining chars, up to the length of the current data
int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex);
Expand Down Expand Up @@ -452,7 +452,7 @@ private void ParseHeaderName(ReadOnlySpan<byte> data, ref int currentIndex, IHtt
}
}

private void ParseHeaderValue(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void ParseHeaderValue(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
// Read remaining chars, up to the length of the current data
int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex);
Expand Down Expand Up @@ -496,7 +496,7 @@ private void CheckIncompleteHeaderBlock(bool endHeaders)
}
}

private void ProcessHeaderValue(ReadOnlySpan<byte> data, IHttpHeadersHandler handler)
private void ProcessHeaderValue(ReadOnlySpan<byte> data, IHttpStreamHeadersHandler handler)
{
ReadOnlySpan<byte> headerValueSpan = _headerValueRange == null
? _headerValueOctets.AsSpan(0, _headerValueLength)
Expand Down Expand Up @@ -539,7 +539,7 @@ public void CompleteDecode()
}
}

private void OnIndexedHeaderField(int index, IHttpHeadersHandler handler)
private void OnIndexedHeaderField(int index, IHttpStreamHeadersHandler handler)
{
if (index <= H2StaticTable.Count)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public void Reset()
_state = State.RequiredInsertCount;
}

public void Decode(in ReadOnlySequence<byte> data, bool endHeaders, IHttpHeadersHandler handler)
public void Decode(in ReadOnlySequence<byte> data, bool endHeaders, IHttpStreamHeadersHandler handler)
{
foreach (ReadOnlyMemory<byte> segment in data)
{
Expand All @@ -172,13 +172,13 @@ public void Decode(in ReadOnlySequence<byte> data, bool endHeaders, IHttpHeaders
CheckIncompleteHeaderBlock(endHeaders);
}

public void Decode(ReadOnlySpan<byte> data, bool endHeaders, IHttpHeadersHandler handler)
public void Decode(ReadOnlySpan<byte> data, bool endHeaders, IHttpStreamHeadersHandler handler)
{
DecodeInternal(data, handler);
CheckIncompleteHeaderBlock(endHeaders);
}

private void DecodeInternal(ReadOnlySpan<byte> data, IHttpHeadersHandler handler)
private void DecodeInternal(ReadOnlySpan<byte> data, IHttpStreamHeadersHandler handler)
{
int currentIndex = 0;

Expand Down Expand Up @@ -253,23 +253,23 @@ private void DecodeInternal(ReadOnlySpan<byte> data, IHttpHeadersHandler handler
}
}

private void ParseHeaderNameIndexPostBase(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void ParseHeaderNameIndexPostBase(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
if (TryDecodeInteger(data, ref currentIndex, out int intResult))
{
OnIndexedHeaderNamePostBase(intResult);
}
}

private void ParsePostBaseIndex(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void ParsePostBaseIndex(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
if (TryDecodeInteger(data, ref currentIndex, out int intResult))
{
OnPostBaseIndex(intResult, handler);
}
}

private void ParseHeaderNameLength(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void ParseHeaderNameLength(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
if (TryDecodeInteger(data, ref currentIndex, out int intResult))
{
Expand All @@ -282,7 +282,7 @@ private void ParseHeaderNameLength(ReadOnlySpan<byte> data, ref int currentIndex
}
}

private void ParseHeaderName(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void ParseHeaderName(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
// Read remaining chars, up to the length of the current data
int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex);
Expand Down Expand Up @@ -320,15 +320,15 @@ private void ParseHeaderName(ReadOnlySpan<byte> data, ref int currentIndex, IHtt
}
}

private void ParseHeaderFieldIndex(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void ParseHeaderFieldIndex(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
if (TryDecodeInteger(data, ref currentIndex, out int intResult))
{
OnIndexedHeaderField(intResult, handler);
}
}

private void ParseHeaderNameIndex(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void ParseHeaderNameIndex(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
if (TryDecodeInteger(data, ref currentIndex, out int intResult))
{
Expand All @@ -337,7 +337,7 @@ private void ParseHeaderNameIndex(ReadOnlySpan<byte> data, ref int currentIndex,
}
}

private void ParseHeaderValueLength(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void ParseHeaderValueLength(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
if (currentIndex < data.Length)
{
Expand Down Expand Up @@ -367,7 +367,7 @@ private void ParseHeaderValueLength(ReadOnlySpan<byte> data, ref int currentInde
}
}

private void ParseHeaderValue(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void ParseHeaderValue(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
// Read remaining chars, up to the length of the current data
int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex);
Expand Down Expand Up @@ -404,7 +404,7 @@ private void ParseHeaderValue(ReadOnlySpan<byte> data, ref int currentIndex, IHt
}
}

private void ParseHeaderValueLengthContinue(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void ParseHeaderValueLengthContinue(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
if (TryDecodeInteger(data, ref currentIndex, out int intResult))
{
Expand All @@ -421,7 +421,7 @@ private void ParseHeaderValueLengthContinue(ReadOnlySpan<byte> data, ref int cur
}
}

private void ParseCompressedHeaders(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void ParseCompressedHeaders(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
if (currentIndex < data.Length)
{
Expand Down Expand Up @@ -520,7 +520,7 @@ private void ParseCompressedHeaders(ReadOnlySpan<byte> data, ref int currentInde
}
}

private void ParseRequiredInsertCountContinue(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void ParseRequiredInsertCountContinue(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
if (TryDecodeInteger(data, ref currentIndex, out int intResult))
{
Expand All @@ -529,7 +529,7 @@ private void ParseRequiredInsertCountContinue(ReadOnlySpan<byte> data, ref int c
}
}

private void ParseBase(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void ParseBase(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
if (currentIndex < data.Length)
{
Expand All @@ -549,7 +549,7 @@ private void ParseBase(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeade
}
}

private void ParseBaseContinue(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void ParseBaseContinue(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
if (TryDecodeInteger(data, ref currentIndex, out int intResult))
{
Expand All @@ -558,7 +558,7 @@ private void ParseBaseContinue(ReadOnlySpan<byte> data, ref int currentIndex, IH
}
}

private void ParseRequiredInsertCount(ReadOnlySpan<byte> data, ref int currentIndex, IHttpHeadersHandler handler)
private void ParseRequiredInsertCount(ReadOnlySpan<byte> data, ref int currentIndex, IHttpStreamHeadersHandler handler)
{
if (currentIndex < data.Length)
{
Expand Down Expand Up @@ -588,7 +588,7 @@ private void CheckIncompleteHeaderBlock(bool endHeaders)
}
}

private void ProcessHeaderValue(ReadOnlySpan<byte> data, IHttpHeadersHandler handler)
private void ProcessHeaderValue(ReadOnlySpan<byte> data, IHttpStreamHeadersHandler handler)
{
ReadOnlySpan<byte> headerValueSpan = _headerValueRange == null
? _headerValueOctets.AsSpan(0, _headerValueLength)
Expand Down Expand Up @@ -718,7 +718,7 @@ private void OnIndexedHeaderNamePostBase(int index)
// _state = State.HeaderValueLength;
}

private void OnPostBaseIndex(int intResult, IHttpHeadersHandler handler)
private void OnPostBaseIndex(int intResult, IHttpStreamHeadersHandler handler)
{
ThrowDynamicTableNotSupported();
// TODO
Expand All @@ -743,7 +743,7 @@ private void OnRequiredInsertCount(int requiredInsertCount)
_state = State.Base;
}

private void OnIndexedHeaderField(int index, IHttpHeadersHandler handler)
private void OnIndexedHeaderField(int index, IHttpStreamHeadersHandler handler)
{
handler.OnStaticIndexedHeader(index);
_state = State.CompressedHeaders;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace System.Net.Http
{
internal interface IHttpStreamHeadersHandler
{
void OnStaticIndexedHeader(int index);
void OnStaticIndexedHeader(int index, ReadOnlySpan<byte> value);
void OnHeader(ReadOnlySpan<byte> name, ReadOnlySpan<byte> value);
void OnHeadersComplete(bool endStream);
void OnDynamicIndexedHeader(int? index, ReadOnlySpan<byte> name, ReadOnlySpan<byte> value);
}
}
4 changes: 2 additions & 2 deletions src/libraries/Common/tests/Common.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
Link="Common\System\Net\HttpKnownHeaderNames.cs" />
<Compile Include="$(CommonPath)System\Net\HttpKnownHeaderNames.TryGetHeaderName.cs"
Link="Common\System\Net\HttpKnownHeaderNames.TryGetHeaderName.cs" />
<Compile Include="$(CommonPath)System\Net\Http\aspnetcore\IHttpHeadersHandler.cs"
Link="Common\System\Net\Http\aspnetcore\IHttpHeadersHandler.cs" />
<Compile Include="$(CommonPath)System\Net\Http\aspnetcore\IHttpStreamHeadersHandler.cs"
Link="Common\System\Net\Http\aspnetcore\IHttpStreamHeadersHandler.cs" />
<Compile Include="$(CommonPath)System\Net\Http\aspnetcore\Http2\Hpack\DynamicTable.cs"
Link="Common\System\Net\Http\aspnetcore\Http2\Hpack\DynamicTable.cs" />
<Compile Include="$(CommonPath)System\Net\Http\aspnetcore\Http2\Hpack\HeaderField.cs"
Expand Down
Loading

0 comments on commit dfbae37

Please sign in to comment.