From 9c087f6b4e4eb5d2f445386128382b094a467408 Mon Sep 17 00:00:00 2001 From: Petr Kristan Date: Thu, 12 Dec 2024 08:48:07 +0100 Subject: [PATCH] Http header host for ipv6 address must be enclosed in square brackets. Same as is in url. url: http://[1080:0:0:0:8:800:200C:417A]/index.html headers.host: [1080:0:0:0:8:800:200C:417A] url.parse removes square brackets, I rather place them back here, than break something else depanding on url.parse --- src/http.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/http.lua b/src/http.lua index 259eb2b..6d13783 100644 --- a/src/http.lua +++ b/src/http.lua @@ -230,6 +230,10 @@ end local function adjustheaders(reqt) -- default headers local host = reqt.host + --ipv6 host address must be in [] + if string.find(host, "^[0-9a-fA-F:]+$") then + host = "["..host.."]" + end local port = tostring(reqt.port) if port ~= tostring(SCHEMES[reqt.scheme].port) then host = host .. ':' .. port end