File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -699,6 +699,7 @@ function parseHarRequest(
699
699
timingEvents,
700
700
tags : [ ] ,
701
701
matchedRuleId : false ,
702
+ httpVersion : parseHttpVersion ( request . httpVersion , request . headers ) ,
702
703
protocol : request . url . split ( ':' ) [ 0 ] ,
703
704
method : request . method ,
704
705
url : request . url ,
@@ -717,6 +718,27 @@ function parseHarRequest(
717
718
}
718
719
}
719
720
721
+ function parseHttpVersion (
722
+ versionString : string | undefined ,
723
+ headers : HarFormat . Header [ ]
724
+ ) {
725
+ if ( ! versionString ) {
726
+ // Make a best guess:
727
+ if ( headers . some ( ( { name } ) => name . startsWith ( ':' ) ) ) {
728
+ return '2.0' ;
729
+ } else {
730
+ return '1.1' ;
731
+ }
732
+ }
733
+
734
+ const regexMatch = / ^ ( H T T P \/ ) ? ( [ \d \. ] + ) $ / i. exec ( versionString ) ;
735
+ if ( regexMatch ) {
736
+ return regexMatch [ 2 ] ;
737
+ }
738
+
739
+ throw TypeError ( `Invalid HTTP version: ${ versionString } ` ) ;
740
+ }
741
+
720
742
function parseHarRequestContents ( data : RequestContentData ) : Buffer {
721
743
if ( data . encoding && Buffer . isEncoding ( data . encoding ) ) {
722
744
return Buffer . from ( data . text , data . encoding ) ;
You can’t perform that action at this time.
0 commit comments