Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hosts options doesn't work well with non-lowercase hosts #3651

Closed
joanlopez opened this issue Mar 18, 2024 · 0 comments · Fixed by #3653
Closed

Hosts options doesn't work well with non-lowercase hosts #3651

joanlopez opened this issue Mar 18, 2024 · 0 comments · Fixed by #3653
Assignees
Labels

Comments

@joanlopez
Copy link
Contributor

joanlopez commented Mar 18, 2024

Brief summary

The Hosts option doesn't work well with non-lowercase hosts, and it causes the k6/http module to fail with connect: connection refused even before actually trying to perform any HTTP request.

The problem seems to be originated in the Hosts type, and more specifically in the Hosts.Match, because the internal trie succesfully reports the match, but then the Match function uses the lowercased host to lookup in the map, so if the user didn't specify the host in strict lowercase, it would return an empty host (wouldn't find it).

I've been able to successfully reproduce this issue since v0.42.0 and up to v0.49.0 (including master).

Related with #3620

k6 version

v0.49.0

OS

Any

Docker version and image (if applicable)

No response

Steps to reproduce the problem

Run any k6 test script with a non-lowercase host (see the example below):

import http from "k6/http";
import {check} from "k6";

export var options = {hosts: {'your-UPPER-case-host.io': 'your-ip'}};
export default function () {
	var param = {headers: {'Accept': 'text/html'}};
	check(http.get("https://your-UPPER-case-host.io", param), {
		"status is 200": (r) => r.status == 200,
		"protocol is HTTP/1.1": (r) => r.proto == "HTTP/1.1",
	});
}

Expected behaviour

The script execution shouldn't fail despite of the case used to describe the host, as hosts are considered case insensitive as per DNS.

Actual behaviour

Since v0.42.0 (and most specifically, probably since 120436b610070f85f04c524fb20c35202627fcea) it fails with:

time="2024-03-18T12:21:55Z" level=warning msg="Request Failed" error="Get \"https://your-UPPER-case-host.io\": dial tcp :443: connect: connection refused"

before actually trying to perform any HTTP request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant