mirror of
1
Fork 0

[bugfix] Set the `Host` header within the signing transport (#2799)

This commit is contained in:
kim 2024-04-02 13:28:36 +01:00 committed by GitHub
parent d61d5c8a6a
commit e664d0918b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 3 additions and 9 deletions

View File

@ -37,6 +37,9 @@ type signingtransport struct {
}
func (t *signingtransport) RoundTrip(r *http.Request) (*http.Response, error) {
// Ensure updated host always set.
r.Header.Set("Host", r.URL.Host)
if sign := gtscontext.HTTPClientSignFunc(r.Context()); sign != nil {
// Reset signing header fields
now := time.Now().UTC()

View File

@ -97,7 +97,6 @@ func (p *Processor) DebugAPUrl(
req.Header.Add("Accept", string(apiutil.AppActivityLDJSON)+","+string(apiutil.AppActivityJSON))
req.Header.Add("Accept-Charset", "utf-8")
req.Header.Set("Host", url.Host)
// Perform the HTTP request,
// and return everything.

View File

@ -120,7 +120,6 @@ func (t *transport) deliver(ctx context.Context, b []byte, to *url.URL) error {
req.Header.Add("Content-Type", string(apiutil.AppActivityLDJSON))
req.Header.Add("Accept-Charset", "utf-8")
req.Header.Set("Host", to.Host)
rsp, err := t.POST(req, b)
if err != nil {

View File

@ -54,7 +54,6 @@ func (t *transport) Dereference(ctx context.Context, iri *url.URL) (*http.Respon
req.Header.Add("Accept", string(apiutil.AppActivityLDJSON)+","+string(apiutil.AppActivityJSON))
req.Header.Add("Accept-Charset", "utf-8")
req.Header.Set("Host", iri.Host)
// Perform the HTTP request
rsp, err := t.GET(req)

View File

@ -93,7 +93,6 @@ func dereferenceByAPIV1Instance(ctx context.Context, t *transport, iri *url.URL)
}
req.Header.Add("Accept", string(apiutil.AppJSON))
req.Header.Set("Host", cleanIRI.Host)
resp, err := t.GET(req)
if err != nil {
@ -250,7 +249,6 @@ func callNodeInfoWellKnown(ctx context.Context, t *transport, iri *url.URL) (*ur
return nil, err
}
req.Header.Add("Accept", string(apiutil.AppJSON))
req.Header.Set("Host", cleanIRI.Host)
resp, err := t.GET(req)
if err != nil {
@ -308,7 +306,6 @@ func callNodeInfo(ctx context.Context, t *transport, iri *url.URL) (*apimodel.No
return nil, err
}
req.Header.Add("Accept", string(apiutil.AppJSON))
req.Header.Set("Host", iri.Host)
resp, err := t.GET(req)
if err != nil {

View File

@ -36,7 +36,6 @@ func (t *transport) DereferenceMedia(ctx context.Context, iri *url.URL) (io.Read
return nil, 0, err
}
req.Header.Add("Accept", "*/*") // we don't know what kind of media we're going to get here
req.Header.Set("Host", iri.Host)
// Perform the HTTP request
rsp, err := t.GET(req)

View File

@ -68,7 +68,6 @@ func prepWebfingerReq(ctx context.Context, loc, domain, username string) (*http.
// including Gin itself. So concat the accept header with a comma
// instead which seems to work reliably
req.Header.Add("Accept", string(apiutil.AppJRDJSON)+","+string(apiutil.AppJSON))
req.Header.Set("Host", req.URL.Host)
return req, nil
}
@ -187,7 +186,6 @@ func (t *transport) webfingerFromHostMeta(ctx context.Context, targetDomain stri
// We're doing XML
req.Header.Add("Accept", string(apiutil.AppXML))
req.Header.Add("Accept", "application/xrd+xml")
req.Header.Set("Host", req.URL.Host)
// Perform the HTTP request
rsp, err := t.GET(req)