plusplusjiajia commented on code in PR #3120:
URL: https://github.com/apache/iceberg-python/pull/3120#discussion_r2969334835


##########
pyiceberg/catalog/rest/__init__.py:
##########
@@ -686,6 +688,12 @@ def _init_sigv4(self, session: Session) -> None:
         from requests import PreparedRequest
         from requests.adapters import HTTPAdapter
 
+        class _IcebergSigV4Auth(SigV4Auth):
+            def canonical_request(self, request: Any) -> str:
+                cr = super().canonical_request(request)
+                # Replace the last line (body_checksum) with hex-encoded 
payload hash.
+                return cr.rsplit("\n", 1)[0] + "\n" + self.payload(request)

Review Comment:
   > using `rsplit` feels fragile, can we reuse the same logic from 
`canonical_request` but just replace the last part with `self.payload(request)`
   
   Good point! Updated to reuse the logic from botocore's 
[implement](https://github.com/boto/botocore/blob/develop/botocore/auth.py)  
instead of using rsplit. The override now explicitly builds the canonical 
request and always uses self.payload(request) (hex-encoded) for the body 
checksum, regardless of the x-amz-content-sha256 header value.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to