Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ProcessServerControlStreamAsync()

async Task System.Net.Http.Http3Connection.ProcessServerControlStreamAsync ( QuicStream stream,
System::Net::ArrayBuffer buffer )
inlineprivate

Definition at line 422 of file Http3Connection.cs.

423 {
424 using (buffer)
425 {
428 (http3FrameType, settingsPayloadLength2) = await ReadFrameEnvelopeAsync().ConfigureAwait(continueOnCapturedContext: false);
429 if (!http3FrameType.HasValue)
430 {
431 throw new Http3ConnectionException(Http3ErrorCode.ClosedCriticalStream);
432 }
433 if (http3FrameType != Http3FrameType.Settings)
434 {
435 throw new Http3ConnectionException(Http3ErrorCode.MissingSettings);
436 }
438 while (true)
439 {
440 (http3FrameType, settingsPayloadLength2) = await ReadFrameEnvelopeAsync().ConfigureAwait(continueOnCapturedContext: false);
441 if (!http3FrameType.HasValue)
442 {
443 break;
444 }
445 Http3FrameType valueOrDefault = http3FrameType.GetValueOrDefault();
446 if ((ulong)valueOrDefault <= 13uL)
447 {
448 switch (valueOrDefault)
449 {
450 case Http3FrameType.GoAway:
452 continue;
453 case Http3FrameType.Settings:
454 throw new Http3ConnectionException(Http3ErrorCode.UnexpectedFrame);
455 case Http3FrameType.Data:
456 case Http3FrameType.Headers:
457 case Http3FrameType.ReservedHttp2Priority:
458 case Http3FrameType.ReservedHttp2Ping:
459 case Http3FrameType.ReservedHttp2WindowUpdate:
460 case Http3FrameType.ReservedHttp2Continuation:
461 case Http3FrameType.MaxPushId:
462 throw new Http3ConnectionException(Http3ErrorCode.UnexpectedFrame);
463 case Http3FrameType.CancelPush:
464 case Http3FrameType.PushPromise:
465 throw new Http3ConnectionException(Http3ErrorCode.IdError);
466 }
467 }
468 await SkipUnknownPayloadAsync(http3FrameType.GetValueOrDefault(), settingsPayloadLength2).ConfigureAwait(continueOnCapturedContext: false);
469 }
470 bool shuttingDown;
471 lock (SyncObj)
472 {
474 }
475 if (!shuttingDown)
476 {
477 throw new Http3ConnectionException(Http3ErrorCode.ClosedCriticalStream);
478 }
479 }
481 {
482 long value;
483 int bytesRead;
484 while (!VariableLengthIntegerHelper.TryRead(buffer.ActiveSpan, out value, out bytesRead))
485 {
486 buffer.EnsureAvailableSpace(8);
487 bytesRead = await stream.ReadAsync(buffer.AvailableMemory, CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
488 if (bytesRead == 0)
489 {
490 throw new Http3ConnectionException(Http3ErrorCode.FrameError);
491 }
492 buffer.Commit(bytesRead);
493 }
494 buffer.Discard(bytesRead);
496 {
497 throw new Http3ConnectionException(Http3ErrorCode.FrameError);
498 }
500 }
502 {
503 while (settingsPayloadLength != 0L)
504 {
505 long a;
506 long b;
507 int bytesRead2;
508 while (!Http3Frame.TryReadIntegerPair(buffer.ActiveSpan, out a, out b, out bytesRead2))
509 {
510 buffer.EnsureAvailableSpace(16);
511 bytesRead2 = await stream.ReadAsync(buffer.AvailableMemory, CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
512 if (bytesRead2 == 0)
513 {
514 throw new Http3ConnectionException(Http3ErrorCode.FrameError);
515 }
516 buffer.Commit(bytesRead2);
517 }
519 if (settingsPayloadLength < 0)
520 {
521 throw new Http3ConnectionException(Http3ErrorCode.FrameError);
522 }
523 buffer.Discard(bytesRead2);
524 switch ((Http3SettingType)a)
525 {
526 case Http3SettingType.MaxHeaderListSize:
527 _maximumHeadersLength = (int)Math.Min(b, 2147483647L);
528 break;
529 case Http3SettingType.ReservedHttp2EnablePush:
530 case Http3SettingType.ReservedHttp2MaxConcurrentStreams:
531 case Http3SettingType.ReservedHttp2InitialWindowSize:
532 case Http3SettingType.ReservedHttp2MaxFrameSize:
533 throw new Http3ConnectionException(Http3ErrorCode.SettingsError);
534 }
535 }
536 }
537 async ValueTask<(Http3FrameType? frameType, long payloadLength)> ReadFrameEnvelopeAsync()
538 {
539 long a2;
540 long b2;
541 int bytesRead3;
542 while (!Http3Frame.TryReadIntegerPair(buffer.ActiveSpan, out a2, out b2, out bytesRead3))
543 {
544 buffer.EnsureAvailableSpace(16);
545 bytesRead3 = await stream.ReadAsync(buffer.AvailableMemory, CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
546 if (bytesRead3 == 0)
547 {
548 if (buffer.ActiveLength == 0)
549 {
550 return (null, 0L);
551 }
552 throw new Http3ConnectionException(Http3ErrorCode.FrameError);
553 }
554 buffer.Commit(bytesRead3);
555 }
556 buffer.Discard(bytesRead3);
557 return ((Http3FrameType)a2, b2);
558 }
559 async ValueTask SkipUnknownPayloadAsync(Http3FrameType frameType, long payloadLength)
560 {
561 while (payloadLength != 0L)
562 {
563 if (buffer.ActiveLength == 0)
564 {
565 int num = await stream.ReadAsync(buffer.AvailableMemory, CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
566 if (num == 0)
567 {
568 throw new Http3ConnectionException(Http3ErrorCode.FrameError);
569 }
570 buffer.Commit(num);
571 }
572 long num2 = Math.Min(payloadLength, buffer.ActiveLength);
573 buffer.Discard((int)num2);
575 }
576 }
577 }
void OnServerGoAway(long lastProcessedStreamId)

References System.Net.Http.Http3Connection._maximumHeadersLength, System.buffer, System.L, System.Math.Min(), System.Threading.CancellationToken.None, System.Net.Http.Http3Connection.OnServerGoAway(), System.Net.Http.Http3Connection.ShuttingDown, System.stream, System.Net.Http.Http3Connection.SyncObj, System.Net.Http.VariableLengthIntegerHelper.TryRead(), System.Net.Http.Http3Frame.TryReadIntegerPair(), and System.value.

Referenced by System.Net.Http.Http3Connection.ProcessServerStreamAsync().