Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Commit 429c04f

Browse files
committed
Known headers have known offsets
Also has "Faster output header handling" #528 in it :-/
1 parent 866fd82 commit 429c04f

File tree

9 files changed

+1922
-1404
lines changed

9 files changed

+1922
-1404
lines changed

src/Microsoft.AspNet.Server.Kestrel/Http/Frame.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -640,14 +640,13 @@ private Task CreateResponseHeader(
640640
{
641641
var begin = SocketOutput.ProducingStart();
642642
var end = begin;
643-
if (_keepAlive)
643+
if (_keepAlive && _responseHeaders.HasConnection)
644644
{
645-
foreach (var connectionValue in _responseHeaders.HeaderConnection)
645+
var connection = _responseHeaders.HeaderConnection.ToString();
646+
647+
if (connection.IndexOf("close", StringComparison.OrdinalIgnoreCase) != -1)
646648
{
647-
if (connectionValue.IndexOf("close", StringComparison.OrdinalIgnoreCase) != -1)
648-
{
649-
_keepAlive = false;
650-
}
649+
_keepAlive = false;
651650
}
652651
}
653652

@@ -834,6 +833,7 @@ private bool RequestUrlStartsWithPathBase(string requestUrl, out bool caseMatche
834833

835834
public static bool TakeMessageHeaders(SocketInput input, FrameRequestHeaders requestHeaders)
836835
{
836+
MemoryPoolIterator2 endName;
837837
var scan = input.ConsumingStart();
838838
var consumed = scan;
839839
try
@@ -843,8 +843,15 @@ public static bool TakeMessageHeaders(SocketInput input, FrameRequestHeaders req
843843
while (!scan.IsEnd)
844844
{
845845
var beginName = scan;
846-
scan.Seek(ref _vectorColons, ref _vectorCRs);
847-
var endName = scan;
846+
if (scan.Peek() == '\r' || scan.SeekCommonHeader())
847+
{
848+
endName = scan;
849+
}
850+
else
851+
{
852+
scan.Seek(ref _vectorColons, ref _vectorCRs);
853+
endName = scan;
854+
}
848855

849856
chFirst = scan.Take();
850857
var beginValue = scan;

0 commit comments

Comments
 (0)