MCPcopy Index your code
hub / github.com/ZenNotes/zennotes / requestOrigin

Method requestOrigin

apps/server/internal/httpserver/security.go:259–271  ·  view source on GitHub ↗
(r *http.Request)

Source from the content-addressed store, hash-verified

257}
258
259func (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
273func isLoopbackBind(bind string) bool {
274 host, _, err := net.SplitHostPort(bind)

Callers 1

isAllowedOriginMethod · 0.95

Calls 2

effectiveSchemeMethod · 0.95
peerIsTrustedProxyMethod · 0.95

Tested by

no test coverage detected