Skip to content

fix(router): emit Content-Length on intercepted GetObject responses#49

Open
pszafarczyk wants to merge 1 commit into
Intrinsec:mainfrom
pszafarczyk:content-length
Open

fix(router): emit Content-Length on intercepted GetObject responses#49
pszafarczyk wants to merge 1 commit into
Intrinsec:mainfrom
pszafarczyk:content-length

Conversation

@pszafarczyk

Copy link
Copy Markdown

Intercepted GetObject responses streamed the decrypted body without a Content-Length header, so Go's server fell back to chunked transfer encoding. s3cmd 2.4.0 reads content-length unconditionally and downloaded an empty file as a result.

The full plaintext is already buffered before any bytes are written, so set Content-Length from len(plaintext) before WriteHeader. The upstream length describes the ciphertext (+28 bytes GCM overhead, or arbitrary for legacy objects) and can't be reused, mirroring the existing omission of x-amz-checksum-* headers.

Intercepted GetObject responses streamed the decrypted body without a
Content-Length header, so Go's server fell back to chunked transfer
encoding. s3cmd 2.4.0 reads content-length unconditionally and downloaded
an empty file as a result.

The full plaintext is already buffered before any bytes are written, so
set Content-Length from len(plaintext) before WriteHeader. The upstream
length describes the ciphertext (+28 bytes GCM overhead, or arbitrary for
legacy objects) and can't be reused, mirroring the existing omission of
x-amz-checksum-* headers.
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