Skip to content

Commit

Permalink
feat(gw): Ipfs-Gateway-Mode: path
Browse files Browse the repository at this point in the history
This is opt-in HTTP header that CLI tools like CURL
can send to disable browser-specific redirect to subdomain.

Context: https://curl.se/mail/lib-2023-10/0038.html
An IPIP and gateway conformance tests will follow.
  • Loading branch information
lidel committed Oct 20, 2023
1 parent 40fb162 commit 3c40238
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gateway/hostname.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ func NewHostnameHandler(c Config, backend IPFSBackend, next http.Handler) http.H
host = xHost
}

// Comply with user agents that explicitly requested plain path processing
// (used by CLI and non-browser tools to disable Host-based subdomain redirects etc)
if mode := r.Header.Get("Ipfs-Gateway-Mode"); mode == "path" {
next.ServeHTTP(w, withHostnameContext(r, host))
return
}

// HTTP Host & Path check: is this one of our "known gateways"?
if gw, ok := gateways.isKnownHostname(host); ok {
// This is a known gateway but request is not using
Expand Down

0 comments on commit 3c40238

Please sign in to comment.