From 630a3b7f4fb0c786170e3903175e964bbc1bc77f Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Sun, 30 Aug 2026 15:41:46 +0200 Subject: fix(http): bracket IPv6 host in Host header The Host header must wrap an IPv6 literal in brackets (RFC 7230), but adjustheaders() used reqt.host as-is, which is unbracketed after url.parse(). Use url.classify_host() to detect IPv6 and bracket it, handling an already-bracketed input without doubling the brackets. Closes #445 --- src/http.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/http.lua') diff --git a/src/http.lua b/src/http.lua index 259eb2b..64bbd8e 100644 --- a/src/http.lua +++ b/src/http.lua @@ -229,7 +229,8 @@ end local function adjustheaders(reqt) -- default headers - local host = reqt.host + local hosttype, host = url.classify_host(reqt.host) + if hosttype == "ipv6" then host = "[" .. host .. "]" end local port = tostring(reqt.port) if port ~= tostring(SCHEMES[reqt.scheme].port) then host = host .. ':' .. port end -- cgit v1.2.3-55-g6feb