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:
Erik Dubbelboer
2024-04-29 10:48:09 +02:00
committed by GitHub
parent 30adc7d046
commit a8fa9c04b4
+5
View File
@@ -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