From 06bfd26facaf011835359e707e99c019b57f1e81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Tue, 14 Jul 2026 16:45:15 +0200 Subject: [PATCH] Allow using apt proxy as the address If the request is without a scheme and path starts with "/", then it is a setup where the proxy is the apt server url. --- internal/proxy/transport.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/internal/proxy/transport.go b/internal/proxy/transport.go index 9bb4b01..73dd3ac 100644 --- a/internal/proxy/transport.go +++ b/internal/proxy/transport.go @@ -17,6 +17,8 @@ package proxy import ( "fmt" "net/http" + "net/url" + "strings" "time" httpkit "github.com/soulteary/http-kit" @@ -57,6 +59,21 @@ func NewRetryableTransport(baseTransport http.RoundTripper) *RetryableTransport func (rt *RetryableTransport) RoundTrip(req *http.Request) (*http.Response, error) { ctx := req.Context() + // Add http:// + if req.URL.Scheme == "" { + httpURL, err := url.Parse("http://" + strings.Replace(req.URL.Path, "/", "", 1)) + if err != nil { + return nil, err + } + httpReq, err := http.NewRequestWithContext(ctx, req.Method, httpURL.String(), nil) + if err != nil { + return nil, err + } + httpReq.Header = req.Header.Clone() + httpReq.Header.Set("Host", httpReq.Host) + req = httpReq + } + // Start tracing span spanCtx, span := tracing.StartSpan(ctx, "proxy.upstream.request") defer span.End()