@@ -438,16 +438,13 @@ async function handleApplicationByteranges(req, filepath){
438438 const s_known_length_field_name_value = si ++ ;
439439 const s_known_length_field_value_length = si ++ ;
440440 const s_known_length_field_value_value = si ++ ;
441- const s_known_length_field_line = si ++ ;
442441 const s_known_length_content_length = si ++ ;
443442 const s_known_length_content_value = si ++ ;
444443 const s_indeterminate_length_field_line = si ++ ;
445444 const s_indeterminate_length_field_name_length = si ++ ;
446445 const s_indeterminate_length_field_value_length = si ++ ;
447446 const s_void = si ++ ;
448- const s_names = [ 's_framing_indicator' , 's_known_length_field_length' , 's_known_length_field_name_length' , 's_known_length_field_name_value' , 's_known_length_field_value_length' , 's_known_length_field_value_value' , 's_known_length_field_line' , 's_known_length_content_length' , 's_known_length_content_value' , 's_indeterminate_length_field_line' , 's_indeterminate_length_field_name_length' , 's_indeterminate_length_field_value_length' , 's_void' ] ;
449- var boundary_s = '' ;
450- var boundary = [ ] ;
447+ const s_names = [ 's_framing_indicator' , 's_known_length_field_length' , 's_known_length_field_name_length' , 's_known_length_field_name_value' , 's_known_length_field_value_length' , 's_known_length_field_value_value' , 's_known_length_content_length' , 's_known_length_content_value' , 's_indeterminate_length_field_line' , 's_indeterminate_length_field_name_length' , 's_indeterminate_length_field_value_length' , 's_void' ] ;
451448 var body_chunks = [ ] ;
452449 var body_chunks_maybe = [ ] ;
453450 function parse_int ( c ) {
@@ -479,6 +476,9 @@ async function handleApplicationByteranges(req, filepath){
479476 // console.log(s_names[state], c.toString(16), c<0x20 ? String.fromCharCode(0x2400+c) : String.fromCharCode(c), int_state);
480477 switch ( state ) {
481478 case s_framing_indicator :
479+ fields = [ ] ;
480+ field_name = "" ;
481+ field_value = "" ;
482482 if ( c === 8 ) {
483483 state = s_known_length_field_length ;
484484 } else if ( c === 10 ) {
@@ -545,7 +545,7 @@ async function handleApplicationByteranges(req, filepath){
545545 break ;
546546 case s_known_length_content_value :
547547 section_length -- ;
548- if ( section_length === 0 ) state = s_void ;
548+ if ( section_length === 0 ) state = s_framing_indicator ;
549549 write_body ( chunk , chunk_byte ) ;
550550 break ;
551551 case s_indeterminate_length_field_line :
@@ -577,4 +577,7 @@ async function handleApplicationByteranges(req, filepath){
577577 throw new Error ;
578578 }
579579 }
580+
581+ if ( fp ) fp . close ( ) ;
582+ if ( writeStream ) writeStream . close ( ) ;
580583}
0 commit comments