mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-17 21:23:58 +00:00
net/http: Fix http.Get() with port specification
This commit is contained in:
+10
-2
@@ -38,8 +38,16 @@ func (c *Client) doHTTP(req *Request) (*Response, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make TCP connection
|
// make TCP connection
|
||||||
ip := net.ParseIP(req.URL.Host)
|
ip := net.ParseIP(req.URL.Hostname())
|
||||||
raddr := &net.TCPAddr{IP: ip, Port: 80}
|
port := 80
|
||||||
|
if req.URL.Port() != "" {
|
||||||
|
p, err := strconv.ParseUint(req.URL.Port(), 0, 64)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
port = int(p)
|
||||||
|
}
|
||||||
|
raddr := &net.TCPAddr{IP: ip, Port: port}
|
||||||
laddr := &net.TCPAddr{Port: 8080}
|
laddr := &net.TCPAddr{Port: 8080}
|
||||||
|
|
||||||
conn, err := net.DialTCP("tcp", laddr, raddr)
|
conn, err := net.DialTCP("tcp", laddr, raddr)
|
||||||
|
|||||||
Reference in New Issue
Block a user