diff options
author | Aliaksandr Valialkin <valyala@gmail.com> | 2015-12-07 16:44:14 +0200 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2015-12-07 16:44:14 +0200 |
commit | 0ac2d5f35e32b6a6218d9b7db4cb6d3efc6e946e (patch) | |
tree | 8a59d880f0de2ceb1876a0888308a1089efe92de /tcpdialer.go | |
parent | typo fix (diff) | |
download | fasthttp-0ac2d5f35e32b6a6218d9b7db4cb6d3efc6e946e.tar.gz fasthttp-0ac2d5f35e32b6a6218d9b7db4cb6d3efc6e946e.tar.bz2 fasthttp-0ac2d5f35e32b6a6218d9b7db4cb6d3efc6e946e.zip |
Removed DialTLS*, since it must be handled by client code
Diffstat (limited to 'tcpdialer.go')
-rw-r--r-- | tcpdialer.go | 42 |
1 files changed, 1 insertions, 41 deletions
diff --git a/tcpdialer.go b/tcpdialer.go index f9219d9..3e65612 100644 --- a/tcpdialer.go +++ b/tcpdialer.go @@ -1,10 +1,8 @@ package fasthttp import ( - "fmt" "net" "strconv" - "strings" "sync" "sync/atomic" "time" @@ -18,44 +16,20 @@ import ( // For instance, per-host counters and/or limits may be implemented // by such wrappers. // -// The addr passed to dial func may contain port. Example addr values: +// The addr passed to dial func must contain port. Example addr values: // -// * google.com // * foobar.baz:443 // * foo.bar:80 // * aaa.com:8080 -// -// Default port is appended to the addr if port is missing: -// -// * ':80' if Dial is used -// * ':443' if DialTLS is used var ( // Dial dials the given addr using tcp4. - // '80' port is used if port is missing in the addr passed to the func. Dial = DialFunc((&tcpDialer{}).NewDial()) - // DialTLS dials the given addr using tcp4. - // '443' port is used if port is missing in the addr passed to the func. - DialTLS = DialFunc((&tcpDialer{IsTLS: true}).NewDial()) - // DialDualStack dials the given addr using both tcp4 and tcp6. - // '80' port is used if port is missing in the addr passed to the func. DialDualStack = DialFunc((&tcpDialer{DualStack: true}).NewDial()) - - // DialTLSDualStack dials the given addr using both tcp4 and tcp6. - // '443' port is used if port is missing in the addr passed to the func. - DialTLSDualStack = DialFunc((&tcpDialer{IsTLS: true, DualStack: true}).NewDial()) ) -// tcpDialer implements default TCP dialer for the Client and HostClient. -// -// tcpDialer instance copying is forbiddent. Create new instance instead. type tcpDialer struct { - // Appends ':80' to the addr with missing port in Dial if set to false. - // Appends ':443' to the addr with missing port in Dial if set to true. - IsTLS bool - - // Set to true if you want simultaneously dialing tcp4 and tcp6. DualStack bool tcpAddrsLock sync.Mutex @@ -110,8 +84,6 @@ func (d *tcpDialer) tcpAddrsClean() { } func (d *tcpDialer) getTCPAddr(addr string) (*net.TCPAddr, error) { - addr = addMissingPort(addr, d.IsTLS) - d.tcpAddrsLock.Lock() e := d.tcpAddrsMap[addr] if e != nil && !e.pending && time.Since(e.resolveTime) > tcpAddrsCacheDuration { @@ -151,18 +123,6 @@ func (d *tcpDialer) getTCPAddr(addr string) (*net.TCPAddr, error) { return tcpAddr, nil } -func addMissingPort(addr string, isTLS bool) string { - n := strings.Index(addr, ":") - if n >= 0 { - return addr - } - port := 80 - if isTLS { - port = 443 - } - return fmt.Sprintf("%s:%d", addr, port) -} - func resolveTCPAddrs(addr string, dualStack bool) ([]net.TCPAddr, error) { host, portS, err := net.SplitHostPort(addr) if err != nil { |