aboutsummaryrefslogtreecommitdiff
path: root/request.go
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2020-10-27 19:21:33 -0400
committerAdnan Maolood <[email protected]>2020-10-27 19:22:34 -0400
commit239ec885f7ff4c82195527543fe9fa79186ee405 (patch)
tree136fcc482be539f313ba37a4d8c01688787cc546 /request.go
parentMake (*Response).Body an io.ReadCloser (diff)
downloadgo-gemini-239ec885f7ff4c82195527543fe9fa79186ee405.tar.xz
go-gemini-239ec885f7ff4c82195527543fe9fa79186ee405.zip
Add (*Client).Get function
Diffstat (limited to 'request.go')
-rw-r--r--request.go25
1 files changed, 0 insertions, 25 deletions
diff --git a/request.go b/request.go
index 80b20be..1b43aa7 100644
--- a/request.go
+++ b/request.go
@@ -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
}