diff --git a/docs/manual.md b/docs/manual.md index 296fa5107..09d3e911b 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -617,6 +617,7 @@ http: skip: false ``` +**NOTE:** only the first `Host` header will be used to set the `Request.Host` value if multiple are provided. ### interface Validates network interface values diff --git a/extras/dgoss/README.md b/extras/dgoss/README.md index c7d027eb1..64d045d89 100644 --- a/extras/dgoss/README.md +++ b/extras/dgoss/README.md @@ -72,7 +72,7 @@ The following environment variables can be set to change the behavior of dgoss. ##### GOSS_PATH Location of the goss binary to use. (Default: `$(which goss)`) -#### GOSS_FILE +##### GOSS_FILE Name of the goss file to use. (Default: `goss.yaml`) ##### GOSS_OPTS diff --git a/integration-tests/goss/goss-shared.yaml b/integration-tests/goss/goss-shared.yaml index 68af361c0..a1a205129 100644 --- a/integration-tests/goss/goss-shared.yaml +++ b/integration-tests/goss/goss-shared.yaml @@ -188,11 +188,19 @@ http: - "Foo: bar" headers: ["Content-Type: application/json"] body: ['"Foo": "bar"'] + https://httpbin.org/headers?host: + status: 200 + allow-insecure: false + timeout: 5000 + request-headers: + - "Host: example.com" + headers: ["Content-Type: application/json"] + body: ['"Host": "example.com"'] https://httpbin.org/basic-auth/username/secret: status: 200 username: username password: secret - https://httpbin.org/basic-auth/username/secret: + https://httpbin.org/basic-auth/username/secret?failure: status: 401 username: username password: wrong diff --git a/integration-tests/test.sh b/integration-tests/test.sh index d8493eaf5..ac18920a2 100755 --- a/integration-tests/test.sh +++ b/integration-tests/test.sh @@ -45,9 +45,9 @@ out=$(docker_exec "/goss/$os/goss-linux-$arch" --vars "/goss/vars.yaml" --vars-i echo "$out" if [[ $os == "arch" ]]; then - egrep -q 'Count: 86, Failed: 0, Skipped: 3' <<<"$out" + egrep -q 'Count: 90, Failed: 0, Skipped: 3' <<<"$out" else - egrep -q 'Count: 103, Failed: 0, Skipped: 5' <<<"$out" + egrep -q 'Count: 107, Failed: 0, Skipped: 5' <<<"$out" fi if [[ ! $os == "arch" ]]; then diff --git a/system/http.go b/system/http.go index eb40f9f01..faefb342e 100644 --- a/system/http.go +++ b/system/http.go @@ -86,6 +86,11 @@ func (u *DefHTTP) setup() error { return u.err } req.Header = u.RequestHeader.Clone() + + if host := req.Header.Get("Host"); host != "" { + req.Host = host + } + if u.Username != "" || u.Password != "" { req.SetBasicAuth(u.Username, u.Password) }