Loading
sig_v4: Normalize header values per AWS SigV4 specification (#393)
* sig_v4: Normalize header values per AWS SigV4 specification According to the AWS Signature Version 4 specification, canonical header values must be normalized by: 1. Trimming leading and trailing whitespace 2. Converting sequential spaces to a single space From AWS documentation: > Trim any leading or trailing spaces, and convert sequential spaces > in the value to a single space. Reference: https://docs.aws.amazon.com/IAM/latest/UserGuide/create-signed-request.html Without proper whitespace normalization, requests with header values containing multiple consecutive spaces or leading/trailing whitespace would fail signature validation with SignatureDoesNotMatch error. Test case reproduction: ```python metadata = { "My-header1": " a b c ", # Leading/trailing spaces "My-Header2": "\"a b c\"" # Quoted string } client.put_object(bucket, key, data, user_metadata=metadata) ``` Signed-off-by:Kefu Chai <tchaikov@gmail.com> * remove allocation --------- Signed-off-by:
Kefu Chai <tchaikov@gmail.com> Co-authored-by:
Nugine <nugine@foxmail.com>