Skip to content

Commit 439456b

Browse files
author
Guy Bedford
committed
fixups
1 parent 803f4c2 commit 439456b

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

integration-tests/js-compute/fixtures/app/src/headers.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,31 @@ routes.set('/headers/from-response/set', async () => {
2626
backend: 'httpbin',
2727
cacheOverride: new CacheOverride('pass'),
2828
});
29-
response.headers.set('cuStom', 'test');
30-
return response;
29+
return new Response(response.body, {
30+
headers: {
31+
cuStom: 'test',
32+
},
33+
});
3134
});
3235

3336
routes.set('/headers/from-response/delete-invalid', async () => {
3437
const response = await fetch('https://httpbin.org/stream-bytes/11', {
3538
backend: 'httpbin',
3639
cacheOverride: new CacheOverride('pass'),
3740
});
38-
response.headers.delete('none');
39-
return response;
41+
const outResponse = new Response(response);
42+
outResponse.headers.delete('none');
43+
return outResponse;
4044
});
4145

4246
routes.set('/headers/from-response/set-delete', async () => {
4347
const response = await fetch('https://httpbin.org/stream-bytes/11', {
4448
backend: 'httpbin',
4549
cacheOverride: new CacheOverride('pass'),
4650
});
47-
response.headers.set('custom', 'test');
48-
response.headers.delete('access-control-allow-origin');
49-
return response;
51+
const outResponse = new Response(response);
52+
outResponse.headers.set('custom', 'test');
53+
outResponse.headers.set('another', 'test');
54+
outResponse.headers.delete('access-control-allow-origin');
55+
return outResponse;
5056
});

integration-tests/js-compute/fixtures/app/src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ async function app(event) {
9292
}
9393
}
9494
} finally {
95-
res.headers.set('fastly_service_version', FASTLY_SERVICE_VERSION);
95+
try {
96+
// this will fail if headers were same headers object from original upstream
97+
res.headers.set('fastly_service_version', FASTLY_SERVICE_VERSION);
98+
} catch {}
9699
}
97100

98101
return res;

integration-tests/js-compute/fixtures/app/tests.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,10 @@
15031503
"GET /headers/from-response/set-delete": {
15041504
"downstream_response": {
15051505
"status": 200,
1506-
"headers": [["cuStom", "test"]]
1506+
"headers": [
1507+
["cuStom", "test"],
1508+
["another", "test"]
1509+
]
15071510
}
15081511
},
15091512

0 commit comments

Comments
 (0)