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:
parent
436c844007
commit
180605cd5f
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user