Skip to content

Commit 0489507

Browse files
committed
Move from x-file-type to x-backfill-from header
For now, we continue sending an x-file-type header as well in order to work properly with older service worker versions that use it.
1 parent a74af9a commit 0489507

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

packages/php-wasm/node/src/test/php-request-handler.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ describe.each(SupportedPHPVersions)(
150150
type: 'response',
151151
response: new PHPResponse(
152152
404,
153-
{ 'x-file-type': ['static'] },
153+
{ 'x-backfill-from': ['remote-host'] },
154154
new TextEncoder().encode('404 File not found')
155155
),
156156
};
@@ -164,7 +164,7 @@ describe.each(SupportedPHPVersions)(
164164
expect(response).toEqual({
165165
httpStatusCode: 404,
166166
headers: {
167-
'x-file-type': ['static'],
167+
'x-backfill-from': ['remote-host'],
168168
},
169169
bytes: expect.any(Uint8Array),
170170
errors: '',

packages/php-wasm/web-service-worker/src/initialize-service-worker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ async function defaultRequestHandler(event: FetchEvent) {
5353
const workerResponse = await convertFetchEventToPHPRequest(event);
5454
if (
5555
workerResponse.status === 404 &&
56-
workerResponse.headers.get('x-file-type') === 'static'
56+
workerResponse.headers.get('x-backfill-from') === 'remote-host'
5757
) {
5858
const request = await cloneRequest(event.request, {
5959
url,

packages/playground/remote/service-worker.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ initializeServiceWorker({
5555
const workerResponse = await convertFetchEventToPHPRequest(event);
5656
if (
5757
workerResponse.status === 404 &&
58-
workerResponse.headers.get('x-file-type') === 'static'
58+
workerResponse.headers.get('x-backfill-from') === 'remote-host'
5959
) {
6060
const { staticAssetsDirectory } = await getScopedWpDetails(
6161
scope!
6262
);
6363
if (!staticAssetsDirectory) {
6464
const plain404Response = workerResponse.clone();
65-
plain404Response.headers.delete('x-file-type');
65+
plain404Response.headers.delete('x-backfill-from');
6666
return plain404Response;
6767
}
6868

packages/playground/remote/src/lib/worker-thread.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,13 @@ try {
261261
type: 'response',
262262
response: new PHPResponse(
263263
404,
264-
{ 'x-file-type': ['static'] },
264+
{
265+
'x-backfill-from': ['remote-host'],
266+
// Include x-file-type header so remote asset
267+
// retrieval continues to work for clients
268+
// running a prior service worker version.
269+
'x-file-type': ['static'],
270+
},
265271
new TextEncoder().encode('404 File not found')
266272
),
267273
};

0 commit comments

Comments
 (0)