diff --git a/pyiceberg/catalog/rest/__init__.py b/pyiceberg/catalog/rest/__init__.py index 3b77fd47f0..dfe8af009a 100644 --- a/pyiceberg/catalog/rest/__init__.py +++ b/pyiceberg/catalog/rest/__init__.py @@ -422,7 +422,12 @@ def add_headers(self, request: PreparedRequest, **kwargs: Any) -> None: # pylin params = dict(parse.parse_qsl(query)) # remove the connection header as it will be updated after signing - del request.headers["connection"] + if "connection" in request.headers: + del request.headers["connection"] + # For empty bodies, explicitly set the content hash header to the SHA256 of an empty string + body = request.body + if body in (None, b"", ""): + request.headers["x-amz-content-sha256"] = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" aws_request = AWSRequest( method=request.method, url=url, params=params, data=request.body, headers=dict(request.headers)