getHostAddr returns host header if available, otherwise returns host from URL
(req *http.Request)
| 43 | |
| 44 | // getHostAddr returns host header if available, otherwise returns host from URL |
| 45 | func getHostAddr(req *http.Request) string { |
| 46 | host := req.Header.Get("host") |
| 47 | if host != "" && req.Host != host { |
| 48 | return host |
| 49 | } |
| 50 | if req.Host != "" { |
| 51 | return req.Host |
| 52 | } |
| 53 | return req.URL.Host |
| 54 | } |
| 55 | |
| 56 | // Trim leading and trailing spaces and replace sequential spaces with one space, following Trimall() |
| 57 | // in http://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html |
no test coverage detected