Open Bug 1924835 Opened 1 month ago Updated 29 days ago

downloads.download receives a 403 error while direct navigation works

Categories

(WebExtensions :: General, defect)

Firefox 133
defect

Tracking

(Not tracked)

People

(Reporter: dotproto, Unassigned, NeedInfo)

Details

Attachments

(1 file)

Attached file download-bug.zip

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

  1. Load the attached extension. On installation a new tab will open.
  2. Click the "Navigate to the file" button. Observe that Firefox will download a webp image file.
  3. 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.

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.

Flags: needinfo?(rob)
Summary: downloads.download recieves a 403 error while direct navigation works → downloads.download receives a 403 error while direct navigation works
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: