Skip to content

Add response-header overrides to BucketObject.generate_url#339

Merged
nuwang merged 1 commit into
mainfrom
generate-url-response-headers
Jul 10, 2026
Merged

Add response-header overrides to BucketObject.generate_url#339
nuwang merged 1 commit into
mainfrom
generate-url-response-headers

Conversation

@nuwang

@nuwang nuwang commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

BucketObject.generate_url gains optional content_disposition / content_type parameters that ask the backing store to serve the object with those response headers on GET. Downstream consumers (e.g. Galaxy's object store) hand out presigned download URLs and need to force a filename and MIME type on the response.

The signature is uniform across the interface and all four providers; each provider honors the hint where its backend supports response-header overrides:

Provider Mechanism Honors
AWS ResponseContentDisposition/ResponseContentType presigned params both
Azure content_disposition/content_type on the blob SAS (rscd/rsct) both
GCP response-content-disposition/response-content-type signed query params both
OpenStack tempurl filename/inline query params, appended after signing (the tempurl signature covers only method, path and expiry) filename portion of the disposition only; content type cannot be overridden

Both parameters are ignored for writable URLs (response-serving hints only make sense for reads).

Tests

  • test_generate_url_with_response_headers: asserts the overrides appear in the presigned query string under the mock provider (signing is client-side, so no network needed), and against live providers fetches the URL and asserts the served Content-Disposition/Content-Type headers (with the documented OpenStack content-type exemption).
  • test_generate_url_writable_ignores_response_headers: writable URLs carry none of the override markers on any provider.

Verification

  • tox -e py3.13-mock: full suite green (94+ tests)
  • tox -e mypy: clean — the strict interface bar itself enforces that every provider conforms to the new signature
  • tox -e lint: clean

Live provider envs (py3.13-{aws,azure,gcp,openstack}) should run via the safe-to-test label flow to exercise the header assertions against real backends.

generate_url gains optional content_disposition/content_type parameters
that ask the backing store to serve the object with those response
headers on GET — needed by consumers (e.g. Galaxy) that hand out
presigned download URLs with a forced filename and MIME type.

The signature is uniform across all four providers:
- AWS: ResponseContentDisposition/ResponseContentType presigned params
- Azure: content_disposition/content_type on the blob SAS
- GCP: response-content-disposition/response-content-type signed query
  parameters
- OpenStack Swift: the filename portion of the disposition is honored
  via the tempurl filename/inline query parameters (appended after
  signing — the tempurl signature covers only method, path and expiry);
  the content type cannot be overridden

Both parameters are ignored for writable URLs.
@nuwang nuwang force-pushed the generate-url-response-headers branch from 8254883 to 56b82d8 Compare July 10, 2026 15:49
@nuwang nuwang merged commit f06765d into main Jul 10, 2026
4 checks passed
@nuwang nuwang deleted the generate-url-response-headers branch July 10, 2026 15:49
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.

1 participant