mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-14 15:56:44 +03:00
Don't allow , in host when using Client (#1761)
When using a url like http://example.com,/ URI will parse "example.com," as host. HostClient then splits this by "," into multiple addresses and will connect to example.com. HostClient splitting the address by "," is only for direct use, not for use with Client.
This commit is contained in:
@@ -2,6 +2,7 @@ package fasthttp
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -477,6 +478,10 @@ func (c *Client) Do(req *Request, resp *Response) error {
|
||||
|
||||
host := uri.Host()
|
||||
|
||||
if bytes.ContainsRune(host, ',') {
|
||||
return fmt.Errorf("invalid host %q. Use HostClient for multiple hosts", host)
|
||||
}
|
||||
|
||||
isTLS := false
|
||||
if uri.isHTTPS() {
|
||||
isTLS = true
|
||||
|
||||
Reference in New Issue
Block a user