Skip to content

feat: add non-breaking virtual-hosted-style support#38

Open
rhnvrm wants to merge 2 commits into
masterfrom
feat-virtual-hosted-style-nonbreaking
Open

feat: add non-breaking virtual-hosted-style support#38
rhnvrm wants to merge 2 commits into
masterfrom
feat-virtual-hosted-style-nonbreaking

Conversation

@rhnvrm
Copy link
Copy Markdown
Owner

@rhnvrm rhnvrm commented Apr 13, 2026

Summary

  • add SetUsePathStyle(bool) for explicit path-style vs virtual-hosted-style control
  • preserve legacy defaults by surface for non-breaking behavior
  • route runtime URLs, presigned URLs, multipart presigned URLs, and direct upload policy URLs through a shared resolver
  • add safe virtual-hosted fallback to path-style for dotted HTTPS buckets, localhost/IP endpoints, path-prefixed endpoints, and invalid DNS labels
  • include STS token support in CreateUploadPolicies() form fields and policy conditions
  • document the addressing behavior and add regression/coverage tests

Why

Issue #36 asks for real virtual-hosted-style support. PR #37 relaxed bucket validation, but it did not fully solve addressing resolution across runtime, presigned, and policy surfaces, and it risked breaking existing callers.

This PR keeps bucket-scoped APIs bucket-scoped, adds explicit client-level addressing control, and preserves existing behavior by default.

Compatibility

  • runtime requests keep legacy path-style behavior by default
  • presigned URLs keep their legacy defaults by default
  • direct CreateUploadPolicies() defaults keep their legacy action URL behavior by default
  • callers can explicitly opt into virtual-hosted style with SetUsePathStyle(false)
  • explicit virtual-hosted mode safely falls back to path-style when host-style is unsafe/incompatible

Tests

Ran focused regression/feature coverage for the changed addressing surfaces:

go test . -run '^(TestCustomEndpoint|TestGetURL|TestGeneratePresignedURL_LegacyCustomEndpointUsesPathStyle|TestGeneratePresignedUploadPartURL_LegacyCustomEndpointUsesPathStyle|TestCreateUploadPolicies_LegacyDefaultUploadURL|TestSetUsePathStyle_.*|TestGeneratePresignedURL_UsePathStyle.*|TestGeneratePresignedUploadPartURL_UsePathStyle.*|TestCreateUploadPolicies_.*)$'
go test . -run '^(TestS3_GeneratePresignedURL|TestS3_GeneratePresignedURL_Token|TestS3_GeneratePresignedURL_ExtraHeader|TestS3_GeneratePresignedURL_PUT|TestS3_GeneratePresignedURL_ResponseContentDisposition|TestS3_GeneratePresignedURL_URLEncoding|TestS3_GeneratePresignedURL_ObjectKeyEncoding)$'

Closes #36.
Supersedes #37.

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.

Support Virtual Hosted Style

1 participant