downloads.download receives a 403 error while direct navigation works
Categories
(WebExtensions :: General, defect)
Tracking
(Not tracked)
People
(Reporter: dotproto, Unassigned, NeedInfo)
Details
Attachments
(1 file)
8.10 KB,
application/zip
|
Details |
OS: macOS 15.0.1 (24A348)
Firefox version: 133.0a1 (2024-10-15) (aarch64)
Chrome version: 129.0.6668.100 (Official Build) (arm64)
This issue was originally raised on Discourse: https://discourse.mozilla.org/t/downloading-items-from-direct-download-links-with-browser-downloads-download/136438
A developer posted regarding an issue they encountered when migrating their extension from Chrome to Firefox. In Firefox they observed an issue where the download failed when they "pass items that uses a direct download link through the downloads api."
Reproduction steps
- Load the attached extension. On installation a new tab will open.
- Click the "Navigate to the file" button. Observe that Firefox will download a webp image file.
- Click the "Basic download() call" button.
Expected behavior
The download should complete successfully.
Observed behavior
The request will fail. If you open the Downloads window (Cmd+J) you will see that the download failed. If you click the "download() with HTTP errors" button, a file will download, but the file will contain an HTML document that reports a 403 error occurred.
Additional details
If you open the Browser Toolbox and switch to the Network tab before performing this test, you will see that the requests issued by the "Navigate to the file" and "Basic download()" are notably different. I've included redacted versions of the HAR files for these requests as "download.har.json" and "navigation.har.json" in the attached ZIP. See the linked Discourse thread for additional discussion.
Reporter | ||
Comment 1•1 month ago
|
||
This bug report appears to be related to but different from bug 1254327, "browser.downloads.download() doesn't handle redirects". When the browser sends an HTTP request in response to a download() call, the server responds with a 403. By contrast, a normal navigation causes the server to respond with a 303 and the browser fetch the redirect URL. It appears that the HTTP server is changing how it responds based on the shape of the request it receives as opposed to Firefox not handling a redirect as expected.
Updated•29 days ago
|
Description
•