File tree Expand file tree Collapse file tree 1 file changed +9
-13
lines changed
src/Servers/Kestrel/Core/src/Internal/Http2 Expand file tree Collapse file tree 1 file changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -357,29 +357,25 @@ private async Task<bool> TryReadPrefaceAsync()
357
357
return false ;
358
358
}
359
359
360
- private bool ParsePreface ( ReadOnlySequence < byte > readableBuffer , out SequencePosition consumed , out SequencePosition examined )
360
+ private bool ParsePreface ( in ReadOnlySequence < byte > buffer , out SequencePosition consumed , out SequencePosition examined )
361
361
{
362
- consumed = readableBuffer . Start ;
363
- examined = readableBuffer . End ;
362
+ consumed = buffer . Start ;
363
+ examined = buffer . End ;
364
364
365
- if ( readableBuffer . Length < ClientPreface . Length )
365
+ if ( buffer . Length < ClientPreface . Length )
366
366
{
367
367
return false ;
368
368
}
369
369
370
- var span = readableBuffer . IsSingleSegment
371
- ? readableBuffer . First . Span
372
- : readableBuffer . ToSpan ( ) ;
370
+ var preface = buffer . Slice ( 0 , ClientPreface . Length ) ;
371
+ var span = preface . ToSpan ( ) ;
373
372
374
- for ( var i = 0 ; i < ClientPreface . Length ; i ++ )
373
+ if ( ! span . SequenceEqual ( ClientPreface ) )
375
374
{
376
- if ( ClientPreface [ i ] != span [ i ] )
377
- {
378
- throw new Http2ConnectionErrorException ( CoreStrings . Http2ErrorInvalidPreface , Http2ErrorCode . PROTOCOL_ERROR ) ;
379
- }
375
+ throw new Http2ConnectionErrorException ( CoreStrings . Http2ErrorInvalidPreface , Http2ErrorCode . PROTOCOL_ERROR ) ;
380
376
}
381
377
382
- consumed = examined = readableBuffer . GetPosition ( ClientPreface . Length ) ;
378
+ consumed = examined = preface . End ;
383
379
return true ;
384
380
}
385
381
You can’t perform that action at this time.
0 commit comments