@@ -6,15 +6,11 @@ import {
6
6
import { Entry , Header } from "../../typing/har" ;
7
7
import { WaterfallEntry } from "../../typing/waterfall" ;
8
8
9
- /** get experimental feature (usually WebPageTest) */
10
- let getExp = ( harEntry : Entry , name : string ) : string => {
11
- return harEntry [ name ] || harEntry [ "_" + name ] || harEntry . request [ name ] || harEntry . request [ "_" + name ] || "" ;
9
+ const byteSizeProperty = ( title : string , input : string | number ) : KvTuple => {
10
+ return [ title , parseAndFormat ( input , parsePositive , formatBytes ) ] ;
12
11
} ;
13
-
14
- /** get experimental feature and format it as byte */
15
- let getExpAsByte = ( harEntry : Entry , name : string ) : string => {
16
- let resp = parseInt ( getExp ( harEntry , name ) , 10 ) ;
17
- return ( isNaN ( resp ) || resp <= 0 ) ? "" : formatBytes ( resp ) ;
12
+ const countProperty = ( title : string , input : string | number ) : KvTuple => {
13
+ return [ title , parseAndFormat ( input , parsePositive ) ] ;
18
14
} ;
19
15
20
16
function parseGeneralDetails ( entry : WaterfallEntry , requestID : number ) : KvTuple [ ] {
@@ -28,7 +24,7 @@ function parseGeneralDetails(entry: WaterfallEntry, requestID: number): KvTuple[
28
24
[ "Server IPAddress" , harEntry . serverIPAddress ] ,
29
25
[ "Connection" , harEntry . connection ] ,
30
26
[ "Browser Priority" , harEntry . _priority || harEntry . _initialPriority ] ,
31
- [ "Was pushed" , harEntry . _was_pushed ] ,
27
+ [ "Was pushed" , parseAndFormat ( harEntry . _was_pushed , parsePositive , ( ) => "yes" ) ] ,
32
28
[ "Initiator (Loaded by)" , harEntry . _initiator ] ,
33
29
[ "Initiator Line" , harEntry . _initiator_line ] ,
34
30
[ "Host" , getHeader ( harEntry . request . headers , "Host" ) ] ,
@@ -37,16 +33,16 @@ function parseGeneralDetails(entry: WaterfallEntry, requestID: number): KvTuple[
37
33
[ "Expires" , harEntry . _expires ] ,
38
34
[ "Cache Time" , parseAndFormat ( harEntry . _cache_time , parsePositive ) ] ,
39
35
[ "CDN Provider" , harEntry . _cdn_provider ] ,
40
- [ "ObjectSize" , parseAndFormat ( harEntry . _objectSize , parsePositive , formatBytes ) ] ,
41
- [ "Bytes In (downloaded)" , getExpAsByte ( harEntry , "bytesIn" ) ] ,
42
- [ "Bytes Out (uploaded)" , getExpAsByte ( harEntry , "bytesOut" ) ] ,
43
- [ "JPEG Scan Count" , parseAndFormat ( harEntry . _jpeg_scan_count , parsePositive ) ] ,
44
- [ "Gzip Total" , getExpAsByte ( harEntry , "gzip_total" ) ] ,
45
- [ "Gzip Save" , getExpAsByte ( harEntry , "gzip_save" ) ] ,
46
- [ "Minify Total" , getExpAsByte ( harEntry , "minify_total" ) ] ,
47
- [ "Minify Save" , getExpAsByte ( harEntry , "minify_save" ) ] ,
48
- [ "Image Total" , getExpAsByte ( harEntry , "image_total" ) ] ,
49
- [ "Image Save" , getExpAsByte ( harEntry , "image_save" ) ] ,
36
+ byteSizeProperty ( "ObjectSize" , harEntry . _objectSize ) ,
37
+ byteSizeProperty ( "Bytes In (downloaded)" , harEntry . _bytesIn ) ,
38
+ byteSizeProperty ( "Bytes Out (uploaded)" , harEntry . _bytesOut ) ,
39
+ byteSizeProperty ( "JPEG Scan Count" , harEntry . _jpeg_scan_count ) ,
40
+ byteSizeProperty ( "Gzip Total" , harEntry . _gzip_total ) ,
41
+ byteSizeProperty ( "Gzip Save" , harEntry . _gzip_save ) ,
42
+ byteSizeProperty ( "Minify Total" , harEntry . _minify_total ) ,
43
+ byteSizeProperty ( "Minify Save" , harEntry . _minify_save ) ,
44
+ byteSizeProperty ( "Image Total" , harEntry . _image_total ) ,
45
+ byteSizeProperty ( "Image Save" , harEntry . _image_save ) ,
50
46
] ;
51
47
}
52
48
@@ -58,9 +54,9 @@ function parseRequestDetails(harEntry: Entry): KvTuple[] {
58
54
return [
59
55
[ "Method" , request . method ] ,
60
56
[ "HTTP Version" , request . httpVersion ] ,
61
- [ "Bytes Out (uploaded)" , getExpAsByte ( harEntry , "bytesOut" ) ] ,
62
- [ "Headers Size" , parseAndFormat ( request . headersSize , parseNonNegative , formatBytes ) ] ,
63
- [ "Body Size" , parseAndFormat ( request . bodySize , parseNonNegative , formatBytes ) ] ,
57
+ byteSizeProperty ( "Bytes Out (uploaded)" , harEntry . _bytesOut ) ,
58
+ byteSizeProperty ( "Headers Size" , request . headersSize ) ,
59
+ byteSizeProperty ( "Body Size" , request . bodySize ) ,
64
60
[ "Comment" , request . comment ] ,
65
61
stringHeader ( "User-Agent" ) ,
66
62
stringHeader ( "Host" ) ,
@@ -72,8 +68,8 @@ function parseRequestDetails(harEntry: Entry): KvTuple[] {
72
68
stringHeader ( "If-Modified-Since" ) ,
73
69
stringHeader ( "If-Range" ) ,
74
70
stringHeader ( "If-Unmodified-Since" ) ,
75
- [ "Querystring parameters count" , parseAndFormat ( request . queryString . length , parsePositive ) ] ,
76
- [ "Cookies count" , request . cookies . length ] ,
71
+ countProperty ( "Querystring parameters count" , request . queryString . length ) ,
72
+ countProperty ( "Cookies count" , request . cookies . length ) ,
77
73
] ;
78
74
}
79
75
@@ -98,18 +94,18 @@ function parseResponseDetails(harEntry: Entry): KvTuple[] {
98
94
return [
99
95
[ "Status" , response . status + " " + response . statusText ] ,
100
96
[ "HTTP Version" , response . httpVersion ] ,
101
- [ "Bytes In (downloaded)" , getExpAsByte ( harEntry , "bytesIn" ) ] ,
102
- [ "Headers Size" , parseAndFormat ( response . headersSize , parseNonNegative , formatBytes ) ] ,
103
- [ "Body Size" , parseAndFormat ( response . bodySize , parseNonNegative , formatBytes ) ] ,
97
+ byteSizeProperty ( "Bytes In (downloaded)" , harEntry . _bytesIn ) ,
98
+ byteSizeProperty ( "Headers Size" , response . headersSize ) ,
99
+ byteSizeProperty ( "Body Size" , response . bodySize ) ,
104
100
[ "Content-Type" , contentType ] ,
105
101
stringHeader ( "Cache-Control" ) ,
106
102
stringHeader ( "Content-Encoding" ) ,
107
103
dateHeader ( "Expires" ) ,
108
104
dateHeader ( "Last-Modified" ) ,
109
105
stringHeader ( "Pragma" ) ,
110
- [ "Content-Length" , parseAndFormat ( contentLength , parseNonNegative , formatBytes ) ] ,
106
+ byteSizeProperty ( "Content-Length" , contentLength ) ,
111
107
[ "Content Size" , ( contentLength !== content . size . toString ( ) ? formatBytes ( content . size ) : "" ) ] ,
112
- [ "Content Compression" , parseAndFormat ( content . compression , parsePositive , formatBytes ) ] ,
108
+ byteSizeProperty ( "Content Compression" , content . compression ) ,
113
109
stringHeader ( "Connection" ) ,
114
110
stringHeader ( "ETag" ) ,
115
111
stringHeader ( "Accept-Patch" ) ,
@@ -146,7 +142,7 @@ function parseTimings(entry: WaterfallEntry): KvTuple[] {
146
142
}
147
143
148
144
/** Key/Value pair in array `["key", "value"]` */
149
- export type KvTuple = [ string , string | number ] ;
145
+ export type KvTuple = [ string , string ] ;
150
146
151
147
/**
152
148
* Data to show in overlay tabs
0 commit comments