Skip to content

Commit d47181e

Browse files
fix(rest): handle empty body in AWS SigV4 signing
1 parent 1b69a25 commit d47181e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pyiceberg/catalog/rest/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,14 @@ def add_headers(self, request: PreparedRequest, **kwargs: Any) -> None: # pylin
560560
params = dict(parse.parse_qsl(query))
561561

562562
# remove the connection header as it will be updated after signing
563-
del request.headers["connection"]
563+
if "connection" in request.headers:
564+
del request.headers["connection"]
565+
# For empty bodies, explicitly set the content hash header to the SHA256 of an empty string
566+
body = request.body
567+
if body in (None, b"", ""):
568+
request.headers["x-amz-content-sha256"] = (
569+
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
570+
)
564571

565572
aws_request = AWSRequest(
566573
method=request.method, url=url, params=params, data=request.body, headers=dict(request.headers)

0 commit comments

Comments
 (0)