(r *http.Request)
| 257 | } |
| 258 | |
| 259 | func (s *Server) requestOrigin(r *http.Request) string { |
| 260 | scheme := s.effectiveScheme(r) |
| 261 | host := strings.TrimSpace(r.Host) |
| 262 | if s.peerIsTrustedProxy(r) { |
| 263 | if forwardedHost := strings.TrimSpace(strings.Split(r.Header.Get("X-Forwarded-Host"), ",")[0]); forwardedHost != "" { |
| 264 | host = forwardedHost |
| 265 | } |
| 266 | } |
| 267 | if host == "" { |
| 268 | return "" |
| 269 | } |
| 270 | return fmt.Sprintf("%s://%s", scheme, strings.ToLower(host)) |
| 271 | } |
| 272 | |
| 273 | func isLoopbackBind(bind string) bool { |
| 274 | host, _, err := net.SplitHostPort(bind) |
no test coverage detected