Bug 264388 - Safari adds pragma header to Service Worker requests with active Service Worker
Summary: Safari adds pragma header to Service Worker requests with active Service Worker
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Service Workers (show other bugs)
Version: Safari 17
Hardware: Mac (Apple Silicon) macOS 14
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-11-08 00:34 PST by Daniel Schulz
Modified: 2023-11-16 01:24 PST (History)
3 users (show)

See Also:


Attachments
Demo to reproduce the issue (1.34 KB, application/zip)
2023-11-08 00:34 PST, Daniel Schulz
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Schulz 2023-11-08 00:34:50 PST
Created attachment 468512 [details]
Demo to reproduce the issue

Steps to Reproduce:
1) Start a server with the attached files: `index.html`, `script.js`, `sw.js`
2) open index.html, open Dev Tools network tab and console. Disable Cache in Dev Tools.
3) click button to fetch asset -> Asset is fetched normally
4) click button to register Service Worker, reload page to ensure Service Worker is active
5) click fetch button again. This should try to fetch the asset through the Service Worker
6) Fetch fails



Details to the steps to reproduce:

The server responding to the request needs to disallow the deprecated pragma header.
When fetching a request through a Service Worker, Safari adds a pragma header to the request. 
In order to check if the pragma header is allowed on the server, it sends a preflight request, which is then responded to negatively by our test server. 
This will let the fetch fail. The actual unexpected behaviour is in the difference in fetching with vs without the Service Worker. I would expect the fetch to behave the same regardless.
The fetch fails with the error: `Failed to load resource: Request header field Pragma is not allowed by Access-Control-Allow-Headers`, as seen in the Service Worker's Network Tab.


Expected Results:
Actual Results: The fetch fails with active Service Worker.


Observed Results:
Version: The fetch works with active Service Worker.


Tested Versions:
Notes: Safari 17/MacOS Sonoma, Safari TP/MacOS Sonoma
Comment 1 Radar WebKit Bug Importer 2023-11-15 00:35:21 PST
<rdar://problem/118442076>
Comment 2 youenn fablet 2023-11-15 07:28:46 PST
Pull request: https://github.com/WebKit/WebKit/pull/20538
Comment 3 EWS 2023-11-16 01:24:49 PST
Committed 270819@main (900625097b70): <https://commits.webkit.org/270819@main>

Reviewed commits have been landed. Closing PR #20538 and removing active labels.