Skip to content

Add HTTP range support for file downloads - #578

Merged
AndreyVMarkelov merged 1 commit into
mainfrom
support_range_download
Aug 4, 2026
Merged

Add HTTP range support for file downloads#578
AndreyVMarkelov merged 1 commit into
mainfrom
support_range_download

Conversation

@AndreyVMarkelov

Copy link
Copy Markdown
Contributor

Summary

Add first-class HTTP Range support for file downloads.

This change adds an optional extra_headers parameter to files_download and files_download_to_file, allowing callers to pass request-specific HTTP headers such as Range.

It also adds a public build_range_headers helper for constructing valid HTTP Range headers.

Example

from dropbox import Dropbox, build_range_headers

dbx = Dropbox(oauth2_access_token=ACCESS_TOKEN)

metadata, response = dbx.files_download(
    "/large-file.bin",
    extra_headers=build_range_headers((0, 1023)),
)

Changes

  • add extra_headers to files_download
  • add extra_headers to files_download_to_file
  • forward request-specific headers through the transport layer
  • add format_byte_range and build_range_headers
  • export build_range_headers from the top-level dropbox package
  • add a Dropbox-specific Python client generator backend
  • add unit tests for Range formatting, header forwarding, and SDK-managed header precedence

Backward compatibility

The new arguments are optional and are appended to the existing method signatures.

Existing calls continue to work unchanged:

dbx.files_download("/file.txt")
dbx.files_download("/file.txt", rev="...")
dbx.files_download_to_file("local.txt", "/remote.txt")

SDK-managed headers such as Authorization, Content-Type, and Dropbox-API-Arg continue to take precedence over conflicting values supplied through extra_headers.

Fixes #79.

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.43590% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 65.20%. Comparing base (8d013bd) to head (6f32a0d).

Files with missing lines Patch % Lines
dropbox/dropbox_client.py 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #578      +/-   ##
==========================================
+ Coverage   65.18%   65.20%   +0.01%     
==========================================
  Files          34       35       +1     
  Lines       66330    66363      +33     
  Branches     4716     4729      +13     
==========================================
+ Hits        43239    43271      +32     
  Misses      22930    22930              
- Partials      161      162       +1     
Flag Coverage Δ
integration 65.02% <28.20%> (-0.03%) ⬇️
unit 64.86% <92.30%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@AndreyVMarkelov
AndreyVMarkelov force-pushed the support_range_download branch from 36ceea0 to a27836c Compare August 4, 2026 22:51
@AndreyVMarkelov
AndreyVMarkelov force-pushed the support_range_download branch from a27836c to 6f32a0d Compare August 4, 2026 22:56
@AndreyVMarkelov
AndreyVMarkelov merged commit 74dab18 into main Aug 4, 2026
35 checks passed
@AndreyVMarkelov
AndreyVMarkelov deleted the support_range_download branch August 4, 2026 23:28
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.

file download HTTP Range request

2 participants