blob: 6bd2b72137e5b4632fe6e144184fde3ff8a87eb2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
'use strict';
onfetch = function(e) {
var headers = {};
for (var header of e.request.headers) {
var key = header[0], value = header[1];
headers[key] = value;
}
var append_header_error = '';
try {
e.request.headers.append('Test-Header', 'TestValue');
} catch (error) {
append_header_error = error.name;
}
var request_construct_error = '';
try {
new Request(e.request, {method: 'GET'});
} catch (error) {
request_construct_error = error.name;
}
e.respondWith(new Response(JSON.stringify({
url: e.request.url,
method: e.request.method,
referrer: e.request.referrer,
headers: headers,
mode: e.request.mode,
credentials: e.request.credentials,
redirect: e.request.redirect,
append_header_error: append_header_error,
request_construct_error: request_construct_error
})));
};
|