Skip to content

Commit

Permalink
Don't allow , in host when using Client (#1761)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
erikdubbelboer authored Apr 29, 2024
1 parent 30adc7d commit a8fa9c0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package fasthttp

import (
"bufio"
"bytes"
"crypto/tls"
"errors"
"fmt"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a8fa9c0

Please sign in to comment.