Repository navigation
Store an S3 object's Content-Type and x-amz-meta-* headers with its key - #189
Merged
Merged
Conversation
An S3 PUT keeps Content-Type, Content-Disposition, Content-Encoding, Content-Language, Cache-Control, Expires and x-amz-meta-*, and GET and HEAD return them. They go in the key's BIND record, now layout version 2, so they survive restarts, index rebuilds and compaction. User metadata over 2 KB is refused with MetadataTooLarge. Without a Content-Type the type is guessed from the extension, now ignoring case and knowing more types. Fixes #163
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #163
Content-Type,Content-Disposition,Content-Encoding,Content-Language,Cache-Control,Expiresandx-amz-meta-*. GET, ranged GET and HEAD return them. Aresponse-*parameter still overrides the header it names. An overwrite replaces the metadata.BINDrecord, so they commit with the key and survive restarts, index rebuilds and journal compaction.BINDis now layout version 2: aftername, a count and that many key and value strings (on-disk format §5.6). A version 1BINDstill reads, as a name with no metadata.INDEX_VERSIONgoes to 3, so an existing store rebuilds its index from the journal once, on first open.x-amz-meta-*names and values can add up to 2 KB, or the PUT getsMetadataTooLarge. A header value that isn't ASCII getsInvalidArgument. Both are checked before the body is stored.Content-Type, the type is guessed from the extension as before, now ignoring case and knowing more types (.svg,.csv,.mp4,.wasm,.gzand others). I kept the table instead of addingmime_guess, since most clients send a type.S3View::put_object_ifbecomesput_object_with, which takes aPutOptionswith the conditions and the metadata.Compatibility: a build from before this refuses a store that holds a version 2
BIND. It fails closed, like theKEYrecord from #186.Tests: HTTP tests cover the stored headers on HEAD, GET and ranged GET, overrides, overwrite, the extension guess, the 2 KB limit (data log unchanged on refusal) and non-ASCII values. Lifecycle tests cover a restart and a lost index, and metadata that can't be stored. The journal compaction tests now bind with metadata, so they check it survives compaction and rebuilds. Ten mutants each fail a test: decode, compaction or the index dropping metadata, the PUT keeping no headers, GET and HEAD sending none, the stored type ignored, no size limit, any name stored, non-ASCII stored, and case-sensitive extensions. I ran the issue's boto3 repro against
serve-s3:image/jpegand{'owner': 'qa'}come back.While doing this I found #188: after journal compaction, a rebuilt index can hold dedup entries the live index dropped. It was already on main, and it's separate from this change.
Docs: CHANGELOG, on-disk-format §5.6 and §7, QUICKSTART_S3.