Skip to content
This repository has been archived by the owner on Aug 14, 2018. It is now read-only.

Commit

Permalink
Merge pull request #27 from derek-burdick/master
Browse files Browse the repository at this point in the history
Can now guess region and service from elastic search service URL's
  • Loading branch information
mdwhatcott committed Jan 4, 2016
2 parents ccb7e73 + 483ac9d commit f78c76c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ func serviceAndRegion(host string) (service string, region string) {
service = parts[0]
region = parts[1]
}
} else if len(parts) == 5 {
service = parts[2]
region = parts[1]
} else {
// Either service.amazonaws.com or s3-region.amazonaws.com
if strings.HasPrefix(parts[0], "s3-") {
Expand Down
10 changes: 10 additions & 0 deletions sign4.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ func hashedCanonicalRequestV4(request *http.Request, meta *metadata) string {
var headersToSign string
for _, key := range sortedHeaderKeys {
value := strings.TrimSpace(request.Header.Get(key))
if key == "host" {
//AWS does not include port in signing request.
if strings.Contains(value, ":") {
split := strings.Split(value, ":")
port := split[1]
if port == "80" || port == "443" {
value = split[0]
}
}
}
headersToSign += key + ":" + value + "\n"
}
meta.signedHeaders = concat(";", sortedHeaderKeys...)
Expand Down

0 comments on commit f78c76c

Please sign in to comment.