OLD | NEW |
1 function dumpUserAgent() | 1 function dumpUserAgent() |
2 { | 2 { |
3 fetch('http://127.0.0.1:8000/inspector/resources/echo-headers.php') | 3 fetch('http://127.0.0.1:8000/resources/echo-headers.php') |
4 .then(function(response) { | 4 .then(function(response) { |
5 return response.text(); | 5 return response.text(); |
6 }).then(function(body) { | 6 }).then(function(body) { |
7 var userAgentLine = /HTTP_USER_AGENT:.*/.exec(body)[0]; | 7 var userAgentLine = /HTTP_USER_AGENT:.*/.exec(body)[0]; |
8 console.log(userAgentLine); | 8 console.log(userAgentLine); |
9 }).catch(function(err) { | 9 }).catch(function(err) { |
10 console.log('fetch failed: ' + err.message); | 10 console.log('fetch failed: ' + err.message); |
11 }); | 11 }); |
12 } | 12 } |
13 | 13 |
14 self.onmessage = function(event) { | 14 self.onmessage = function(event) { |
15 dumpUserAgent(); | 15 dumpUserAgent(); |
16 }; | 16 }; |
OLD | NEW |