diff --git a/dns/dns.go b/dns/dns.go index d1d3b75..0eb5fda 100644 --- a/dns/dns.go +++ b/dns/dns.go @@ -30,7 +30,7 @@ func CacheLookup(recordType, hostname string) ([]net.IP, error) { return ips, nil } -// Lookup looksup the record using Go's default resolver +// Lookup looks up the record using Go's default resolver func Lookup(recordType, hostname string) ([]net.IP, error) { host := hostname if url, err := url.Parse(hostname); err != nil { diff --git a/http/client.go b/http/client.go index 040688b..82b571d 100644 --- a/http/client.go +++ b/http/client.go @@ -209,11 +209,13 @@ func (c *Client) roundTrip(r *Request) (resp *Response, err error) { } else if h := r.getHeader("Host"); h != "" { host = h } else { - host = r.url.Host + host = r.url.Hostname() } - if ips, _ := dns.CacheLookup("A", host); len(ips) > 0 { - host = ips[0].String() + if c.cacheDNS { + if ips, _ := dns.CacheLookup("A", host); len(ips) > 0 { + host = ips[0].String() + } } req, err := http.NewRequestWithContext(r.ctx, r.method, r.url.String(), r.body)