@@ -545,7 +545,7 @@ private async Task ParseAsync(RebufferableBinaryReader reader, CancellationToken
545545 /// Parses a section of the stream that is known to be file data.
546546 /// </summary>
547547 /// <param name="parameters">
548- /// The header parameters of this file, expects "name" and "filename" to be valid keys .
548+ /// The header parameters of this file.
549549 /// </param>
550550 /// <param name="reader">
551551 /// The StreamReader to read the data from.
@@ -554,17 +554,17 @@ private void ParseFilePart(Dictionary<string, string> parameters, RebufferableBi
554554 {
555555 int partNumber = 0 ; // begins count parts of file from 0
556556
557- string name = parameters [ "name" ] ;
558- string filename = parameters [ "filename" ] ;
559-
557+ // Read the parameters
558+ parameters . TryGetValue ( "name" , out string name ) ;
559+ parameters . TryGetValue ( "filename" , out string filename ) ;
560560 parameters . TryGetValue ( "content-type" , out string contentType ) ;
561- if ( contentType == null ) contentType = "text/plain" ;
562-
563561 parameters . TryGetValue ( "content-disposition" , out string contentDisposition ) ;
562+
563+ // Default values if expected parameters are missing
564+ if ( contentType == null ) contentType = "text/plain" ;
564565 if ( contentDisposition == null ) contentDisposition = "form-data" ;
565566
566- // We want to create a stream and fill it with the data from the
567- // file.
567+ // We want to create a stream and fill it with the data from the file.
568568 var curBuffer = Utilities . ArrayPool . Rent ( BinaryBufferSize ) ;
569569 var prevBuffer = Utilities . ArrayPool . Rent ( BinaryBufferSize ) ;
570570 var fullBuffer = Utilities . ArrayPool . Rent ( BinaryBufferSize * 2 ) ;
@@ -705,13 +705,14 @@ private async Task ParseFilePartAsync(Dictionary<string, string> parameters, Reb
705705 {
706706 int partNumber = 0 ; // begins count parts of file from 0
707707
708- string name = parameters [ "name" ] ;
709- string filename = parameters [ "filename" ] ;
710-
708+ // Read the parameters
709+ parameters . TryGetValue ( "name" , out string name ) ;
710+ parameters . TryGetValue ( "filename" , out string filename ) ;
711711 parameters . TryGetValue ( "content-type" , out string contentType ) ;
712- if ( contentType == null ) contentType = "text/plain" ;
713-
714712 parameters . TryGetValue ( "content-disposition" , out string contentDisposition ) ;
713+
714+ // Default values if expected parameters are missing
715+ if ( contentType == null ) contentType = "text/plain" ;
715716 if ( contentDisposition == null ) contentDisposition = "form-data" ;
716717
717718 // We want to create a stream and fill it with the data from the
0 commit comments