aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Erik Dubbelboer <erik@dubbelboer.com> 2024-04-29 10:48:09 +0200
committerGravatar GitHub <noreply@github.com> 2024-04-29 10:48:09 +0200
commita8fa9c04b493324b7805dd5c6f8439b1b15a9f92 (patch)
tree3e96ca063b6a230e0211d308a84b19a2072a2cf8
parentchore(deps): bump golangci/golangci-lint-action from 4 to 5 (#1769) (diff)
downloadfasthttp-a8fa9c04b493324b7805dd5c6f8439b1b15a9f92.tar.gz
fasthttp-a8fa9c04b493324b7805dd5c6f8439b1b15a9f92.tar.bz2
fasthttp-a8fa9c04b493324b7805dd5c6f8439b1b15a9f92.zip
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.
-rw-r--r--client.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/client.go b/client.go
index 1f12d4a..5cae78d 100644
--- a/client.go
+++ b/client.go
@@ -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