Skip to content

Commit

Permalink
ensure host header is set
Browse files Browse the repository at this point in the history
  • Loading branch information
BenLubar committed Apr 7, 2021
1 parent d282a50 commit 042ba2c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pub/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"context"
"crypto"
"fmt"
"github.com/go-fed/httpsig"
"io/ioutil"
"net/http"
"net/url"
"strings"
"sync"

"github.com/go-fed/httpsig"
)

const (
Expand Down Expand Up @@ -118,6 +119,7 @@ func (h HttpSigTransport) Dereference(c context.Context, iri *url.URL) ([]byte,
req.Header.Add("Accept-Charset", "utf-8")
req.Header.Add("Date", h.clock.Now().UTC().Format("Mon, 02 Jan 2006 15:04:05")+" GMT")
req.Header.Add("User-Agent", fmt.Sprintf("%s %s", h.appAgent, h.gofedAgent))
req.Header.Set("Host", iri.Host)
h.getSignerMu.Lock()
err = h.getSigner.SignRequest(h.privKey, h.pubKeyId, req, nil)
h.getSignerMu.Unlock()
Expand Down Expand Up @@ -146,6 +148,7 @@ func (h HttpSigTransport) Deliver(c context.Context, b []byte, to *url.URL) erro
req.Header.Add("Accept-Charset", "utf-8")
req.Header.Add("Date", h.clock.Now().UTC().Format("Mon, 02 Jan 2006 15:04:05")+" GMT")
req.Header.Add("User-Agent", fmt.Sprintf("%s %s", h.appAgent, h.gofedAgent))
req.Header.Set("Host", to.Host)
h.postSignerMu.Lock()
err = h.postSigner.SignRequest(h.privKey, h.pubKeyId, req, b)
h.postSignerMu.Unlock()
Expand Down

0 comments on commit 042ba2c

Please sign in to comment.