* no-op commit due to failed cherry-picking
* [NET-4897] net/http host header is now verified and request.host that contains socked now error (#18129)
### Description
This is related to https://github.com/hashicorp/consul/pull/18124 where
we pinned the go versions in CI to 1.20.5 and 1.19.10.
go 1.20.6 and 1.19.11 now validate request host headers for validity,
including the hostname cannot be prefixed with slashes.
For local communications (npipe://, unix://), the hostname is not used,
but we need valid and meaningful hostname. Prior versions go Go would
clean the host header, and strip slashes in the process, but go1.20.6
and go1.19.11 no longer do, and reject the host header. Around the
community we are seeing that others are intercepting the req.host and if
it starts with a slash or ends with .sock, they changing the host to
localhost or another dummy value.
[client: define a "dummy" hostname to use for local connections by
thaJeztah · Pull Request #45942 ·
moby/moby](https://github.com/moby/moby/pull/45942)
### Testing & Reproduction steps
Check CI tests.
### Links
* [ ] updated test coverage
* [ ] external facing docs updated
* [ ] appropriate backport labels added
* [ ] not a security concern
---------
Co-authored-by: temp <temp@hashicorp.com>
Co-authored-by: John Murret <john.murret@hashicorp.com>
Below is an example of using the Consul client. To run the example, you must first
install Consul and
Go.
To run the client API, create a new Go module.
go mod init consul-demo
Copy the example code into a file called main.go in the directory where the module is defined.
As seen in the example, the Consul API is often imported with the alias capi.
packagemainimport("fmt"capi"github.com/hashicorp/consul/api")funcmain(){// Get a new client
client,err:=capi.NewClient(capi.DefaultConfig())iferr!=nil{panic(err)}// Get a handle to the KV API
kv:=client.KV()// PUT a new KV pair
p:=&capi.KVPair{Key:"REDIS_MAXCLIENTS",Value:[]byte("1000")}_,err=kv.Put(p,nil)iferr!=nil{panic(err)}// Lookup the pair
pair,_,err:=kv.Get("REDIS_MAXCLIENTS",nil)iferr!=nil{panic(err)}fmt.Printf("KV: %v %s\n",pair.Key,pair.Value)}
Install the Consul API dependency with go mod tidy.
In a separate terminal window, start a local Consul server.
consul agent -dev -node machine
Run the example.
go run .
You should get the following result printed to the terminal.
KV: REDIS_MAXCLIENTS 1000
After running the code, you can also view the values in the Consul UI on your local machine at http://localhost:8500/ui/dc1/kv