diff options
| author | Adnan Maolood <[email protected]> | 2020-10-27 19:21:33 -0400 |
|---|---|---|
| committer | Adnan Maolood <[email protected]> | 2020-10-27 19:22:34 -0400 |
| commit | 239ec885f7ff4c82195527543fe9fa79186ee405 (patch) | |
| tree | 136fcc482be539f313ba37a4d8c01688787cc546 /request.go | |
| parent | Make (*Response).Body an io.ReadCloser (diff) | |
| download | go-gemini-239ec885f7ff4c82195527543fe9fa79186ee405.tar.xz go-gemini-239ec885f7ff4c82195527543fe9fa79186ee405.zip | |
Add (*Client).Get function
Diffstat (limited to 'request.go')
| -rw-r--r-- | request.go | 25 |
1 files changed, 0 insertions, 25 deletions
@@ -33,15 +33,6 @@ type Request struct { TLS tls.ConnectionState } -// hostname returns the host without the port. -func hostname(host string) string { - hostname, _, err := net.SplitHostPort(host) - if err != nil { - return host - } - return hostname -} - // NewRequest returns a new request. The host is inferred from the URL. func NewRequest(rawurl string) (*Request, error) { u, err := url.Parse(rawurl) @@ -54,29 +45,13 @@ func NewRequest(rawurl string) (*Request, error) { // NewRequestFromURL returns a new request for the given URL. // The host is inferred from the URL. func NewRequestFromURL(url *url.URL) (*Request, error) { - // If there is no port, use the default port of 1965 host := url.Host if url.Port() == "" { host += ":1965" } - return &Request{ - Host: host, URL: url, - }, nil -} - -// NewRequestTo returns a new request for the provided URL to the provided host. -// The host must contain a port. -func NewRequestTo(rawurl, host string) (*Request, error) { - u, err := url.Parse(rawurl) - if err != nil { - return nil, err - } - - return &Request{ Host: host, - URL: u, }, nil } |