@@ -96,8 +96,8 @@ func NewRequestSigner(signingKeyPemStr string) (*RequestSigner, error) {
96
96
// <URL>
97
97
// <BODY>
98
98
// where:
99
- // <HEADER.k> is the ','-joined concatenation of all header values of `signedHeaders[k]`; all
100
- // other headers in the request are ignored,
99
+ // <HEADER.k> is the ','-joined concatenation of all header values of `signedHeaders[k]`; empty
100
+ // values such as '' and all other headers in the request are ignored,
101
101
// <URL> is the string "<PATH>(?<QUERY>)(#FRAGMENT)", where "?<QUERY>" and "#<FRAGMENT>" are
102
102
// ommitted if the associated components are absent from the request URL,
103
103
// <BODY> is the body of the Request (may be `nil`; e.g. for GET requests).
@@ -109,7 +109,8 @@ func mapRequestToHashInput(req *http.Request) (string, error) {
109
109
110
110
// Add signed headers.
111
111
for _ , hdr := range signedHeaders {
112
- if hdrValues := req .Header [hdr ]; len (hdrValues ) > 0 {
112
+ hdrValues := removeEmpty (req .Header [hdr ])
113
+ if len (hdrValues ) > 0 {
113
114
entries = append (entries , strings .Join (hdrValues , "," ))
114
115
}
115
116
}
@@ -189,3 +190,13 @@ func (signer RequestSigner) Sign(req *http.Request) error {
189
190
func (signer RequestSigner ) PublicKey () (string , string ) {
190
191
return signer .publicKeyID , signer .publicKeyStr
191
192
}
193
+
194
+ func removeEmpty (s []string ) []string {
195
+ r := []string {}
196
+ for _ , str := range s {
197
+ if len (str ) > 0 {
198
+ r = append (r , str )
199
+ }
200
+ }
201
+ return r
202
+ }
0 commit comments