From 8cea021d9708fa1370594863b1fafef292ab72ef Mon Sep 17 00:00:00 2001 From: Allan Que Date: Sun, 5 Jul 2026 19:43:49 -0500 Subject: [PATCH] Add IPv6 support to Host header --- http.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/http.lua b/http.lua index 947a761..e68bc02 100644 --- a/http.lua +++ b/http.lua @@ -681,7 +681,12 @@ function M.send(method, t) if not t.headers.host then -- 'Host' header must be provided for HTTP/1.1 - table.insert(hdr_tbl, "host: " .. host) + if addr:find(":") and not addr:match("^%[.*%]$") then + -- Enclose IPv6 addresses in square brackets + table.insert(hdr_tbl, string.format("host: [%s]:%s", addr, port)) + else + table.insert(hdr_tbl, "host: " .. host) + end end if not t.headers["accept"] then