1
0
mirror of https://git.sr.ht/~adnano/go-gemini synced 2024-11-23 21:02:28 +01:00

client: Allow Request.Host to omit a port

This commit is contained in:
adnano 2021-02-20 13:30:55 -05:00
parent 436c844007
commit 180605cd5f
2 changed files with 4 additions and 3 deletions

@ -86,8 +86,9 @@ func (c *Client) Do(req *Request) (*Response, error) {
if req.Host != "" {
hostname, port, err = net.SplitHostPort(req.Host)
if err != nil {
// Port is required
return nil, err
// Likely no port
hostname = req.Host
port = "1965"
}
// Punycode hostname
hostname, err = punycodeHostname(hostname)

@ -19,7 +19,7 @@ type Request struct {
URL *url.URL
// For client requests, Host optionally specifies the server to
// connect to. It must be of the form "host:port".
// connect to. It may be of the form "host" or "host:port".
// If empty, the value of URL.Host is used.
// For international domain names, Host may be in Punycode or
// Unicode form. Use golang.org/x/net/idna to convert it to