Skip to content

Commit 85b4f65

Browse files
authored
SignV4: trim leading/trailing spaces in header value (#1578)
Signed-off-by: Bala.FA <bala@minio.io>
1 parent e85d171 commit 85b4f65

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

api/src/main/java/io/minio/Signer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,14 @@ private void setCanonicalHeaders(Set<String> ignored_headers) {
134134
// https://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html
135135
// * Header having multiple values should be converted to comma separated values.
136136
// * Multi-spaced value of header should be trimmed to single spaced value.
137+
// * Trim leading/trailing spaces in header value (As OkHttp trims leading/trailing spaces
138+
// automatically, this is added for completion).
137139
this.canonicalHeaders.put(
138140
signedHeader,
139141
headers.values(name).stream()
140142
.map(
141143
value -> {
142-
return value.replaceAll("( +)", " ");
144+
return value.replaceAll("( +)", " ").trim();
143145
})
144146
.collect(Collectors.joining(",")));
145147
}

0 commit comments

Comments
 (0)