Skip to content

Send default User-Agent and accept headers in save_large_file - #362

Open
pawank925 wants to merge 1 commit into
openzim:mainfrom
pawank925:issue-360-save-large-file-headers
Open

pawank925 wants to merge 1 commit into
openzim:mainfrom
pawank925:issue-360-save-large-file-headers

Conversation

@pawank925

@pawank925 pawank925 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

changes

save_large_file only exposed a user_agent parameter, so callers could not set any other header, and unlike stream_file it did not send the Wikimedia-compliant default User-Agent when downloading from upload.wikimedia.org.

This adds a headers parameter for arbitrary HTTP headers and reuses the existing is_wikimedia_upload_url / has_user_agent_header helpers, so save_large_file behaves like stream_file:

  • the provided headers are sent with every request (including resumed ones, alongside the Range header);
  • user_agent, when set, still wins over a User-Agent entry in headers;
  • for upload.wikimedia.org, the default Wikimedia-compliant User-Agent is sent unless a User-Agent is already set through user_agent or headers.

Added unit tests covering arbitrary headers, the Wikimedia default, and precedence between user_agent and a User-Agent header; the full download test module passes (49 passed, 16 skipped, slow tests excluded). ruff and black are clean.

CHANGELOG.md updated.

Closes #360

@pawank925
pawank925 marked this pull request as draft October 22, 2026 17:11
save_large_file only accepted a user_agent parameter, so callers could
not set other headers, and unlike stream_file it did not send the
Wikimedia-compliant default User-Agent for upload.wikimedia.org. Accept
arbitrary headers, merge them with the existing user_agent, and fall back
to the default User-Agent for Wikimedia upload URLs when none is set.

Closes openzim#360
@pawank925
pawank925 force-pushed the issue-360-save-large-file-headers branch from be0cc45 to 6b90e66 Compare October 22, 2026 17:12
@pawank925
pawank925 marked this pull request as ready for review October 22, 2026 17:13
@codecov

codecov Bot commented Oct 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (9a25ed3) to head (6b90e66).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #362   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           42        42           
  Lines         2855      2863    +8     
  Branches       428       430    +2     
=========================================
+ Hits          2855      2863    +8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pawank925

pawank925 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

@benoit74 sorry for not asking assignment before the pr

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

save_large_file should use default user-agent and accept arbitrary headers

1 participant