File tree 2 files changed +17
-5
lines changed
2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 25
25
}
26
26
}
27
27
28
- const calibrator = new Calibrator ( ) ;
28
+ const calibrator_with_date = new Calibrator ( ) ;
29
+ const calibrator_with_custom_header = new Calibrator ( ) ;
29
30
30
- calibrator . beginRequest ( ) ;
31
+ calibrator_with_date . beginRequest ( ) ;
32
+ calibrator_with_custom_header . beginRequest ( ) ;
31
33
fetch ( "/endpoint" ) . then ( ( res ) => {
32
- calibrator . endRequest ( Date . parse ( res . headers . get ( "Date" ) ) ) ;
34
+ calibrator_with_date . endRequest ( Date . parse ( res . headers . get ( "Date" ) ) ) ;
35
+ calibrator_with_custom_header . endRequest (
36
+ + new Date ( + res . headers . get ( "Response-Start" ) ) ,
37
+ + new Date ( + res . headers . get ( "Response-End" ) )
38
+ ) ;
33
39
34
40
document . querySelector ( "pre" ) . innerText = JSON . stringify ( {
35
- difference_in_seconds : calibrator . clockDifference ( ) / 1000
41
+ difference_in_seconds_using_date : calibrator_with_date . clockDifference ( ) / 1000 ,
42
+ difference_in_seconds_using_custom_header : calibrator_with_custom_header . clockDifference ( ) / 1000
36
43
} , null , 2 ) ;
37
44
} ) ;
38
45
} ) ( ) ;
Original file line number Diff line number Diff line change @@ -3,12 +3,17 @@ const http = require("http");
3
3
const path = require ( "path" ) ;
4
4
5
5
http . createServer ( ( req , res ) => {
6
+ const response_start = Date . now ( ) ;
7
+
6
8
if ( req . url === "/" ) {
7
9
return sendHtml ( res ) ;
8
10
}
9
11
10
12
if ( req . url === "/endpoint" ) {
11
- res . writeHead ( 200 ) ;
13
+ res . writeHead ( 200 , {
14
+ "Response-Start" : response_start ,
15
+ "Response-End" : Date . now ( )
16
+ } ) ;
12
17
return res . end ( ) ;
13
18
}
14
19
You can’t perform that action at this time.
0 commit comments