fix(s3): return ETag header for directory marker PutObject requests (#8688)

* fix(s3): return ETag header for directory marker PutObject requests

The PutObject handler has a special path for keys ending with "/" (directory
markers) that creates the entry via mkdir. This path never computed or set
the ETag response header, unlike the regular PutObject path. AWS S3 always
returns an ETag header, even for empty-body puts.

Compute the MD5 of the content (empty or otherwise), store it in the entry
attributes and extended attributes, and set the ETag response header.

Fixes #8682

* fix: handle io.ReadAll error and chunked encoding for directory markers

Address review feedback:
- Handle error from io.ReadAll instead of silently discarding it
- Change condition from ContentLength > 0 to ContentLength != 0 to
  correctly handle chunked transfer encoding (ContentLength == -1)

* fix hanging tests
This commit is contained in:
Chris Lu
2026-03-18 17:26:33 -07:00
committed by GitHub
parent 1f1eac4f08
commit c197206897
2 changed files with 31 additions and 4 deletions

View File

@@ -333,10 +333,13 @@ func TestRollover(t *testing.T) {
logExitFunc = func(e error) {
err = e
}
Info("x") // Be sure we have a file (also triggers createLogDirs via sync.Once).
// Set MaxSize after the first Info call so that createLogDirs (which
// overwrites MaxSize from the flag default) has already executed.
defer func(previous uint64) { MaxSize = previous }(MaxSize)
MaxSize = 512
Info("x") // Be sure we have a file.
info, ok := logging.file[infoLog].(*syncBuffer)
if !ok {
t.Fatal("info wasn't created")