Skip to content

Expose b2_get_download_authorization response header overrides#576

Open
Montana wants to merge 1 commit into
Backblaze:masterfrom
Montana:patch-1
Open

Expose b2_get_download_authorization response header overrides#576
Montana wants to merge 1 commit into
Backblaze:masterfrom
Montana:patch-1

Conversation

@Montana
Copy link
Copy Markdown

@Montana Montana commented May 25, 2026

Add keyword-only parameters for the optional b2ContentDisposition, b2ContentLanguage, b2Expires, b2CacheControl, b2ContentEncoding, and b2ContentType fields accepted by b2_get_download_authorization.

The fields are omitted from the request unless explicitly provided, preserving existing behavior.

Fixes #539.

Add keyword-only parameters for the optional b2ContentDisposition, b2ContentLanguage, b2Expires, b2CacheControl, b2ContentEncoding, and b2ContentType fields accepted by b2_get_download_authorization.

The fields are omitted from the request unless explicitly provided, preserving existing behavior.

Fixes Backblaze#539.
@ppolewicz
Copy link
Copy Markdown
Collaborator

Thanks for putting this together @Montana - exposing the response-header overrides on get_download_authorization is a genuinely useful addition and the request-construction logic looks correct. A few things need to be addressed before this can be merged:

1. The simulator wasn't updated. This change touches the abstract AbstractRawApi.get_download_authorization signature and the B2RawHTTPApi implementation, but RawSimulator implements the same interface and still has the old signature. As it stands, any code (including the test suite) that exercises this method against the simulator with the new parameters will raise a TypeError. The simulator needs to accept and honor the same keyword-only params so the emulated behavior stays in sync with the real API. This way users of the sdk will be able to test their code without touching the cloud and without swimming in a sea of mocks.

2. No tests. We need coverage for the new behavior: that each field is forwarded when provided, that it's omitted from the request when left as None (the existing-behavior guarantee you mention in the description), and a round-trip through the simulator.

3. No changelog entry or documentation. Please add a changelog entry and document the new parameters where the method is described, so users can actually discover them. I think this should include the description of the behavior change, so that the users of the sdk don't have to go through the documentation of the API and through RFCs which define the expected client behavior.

4. Parameter naming. The b2_content_disposition / b2_content_language / b2_expires / etc. names are direct snake_case transliterations of the raw JSON keys, b2_ prefix and all. The b2ContentDisposition form belongs in the wire payload (where you've correctly used it), but the Python-facing parameters should follow the SDK's conventions and drop the redundant prefix — content_disposition, content_language, expires, cache_control, content_encoding, content_type. The fact that they're B2 parameters is already established by the method and the package.

One broader note: raw_api is the lowest layer, so even once the above is fixed, callers won't see these options until they're threaded through the public-facing methods (e.g. Bucket.get_download_authorization).

Happy to review again once these are in.

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.

b2_get_download_authorization extra parameters

2 participants