Embed go exp package requirements to ensure we don't use arbitrary exp, move utilities to utils

This commit is contained in:
WeebDataHoarder
2025-04-06 02:02:54 +02:00
parent 105477c3ee
commit 7d436cbdb4
9 changed files with 7 additions and 6 deletions

19
utils/unix.go Normal file
View File

@@ -0,0 +1,19 @@
package utils
import "net/http"
// UnixRoundTripper https://github.com/oauth2-proxy/oauth2-proxy/blob/master/pkg/upstream/http.go#L124
type UnixRoundTripper struct {
Transport *http.Transport
}
// RoundTrip set bare minimum stuff
func (t UnixRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
req = req.Clone(req.Context())
if req.Host == "" {
req.Host = "localhost"
}
req.URL.Host = req.Host // proxy error: no Host in request URL
req.URL.Scheme = "http" // make http.Transport happy and avoid an infinite recursion
return t.Transport.RoundTrip(req)
}