Skip to content

Commit

Permalink
Http header host for ipv6 address must be enclosed
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Petr-kk committed Dec 12, 2024
1 parent 1fad162 commit 9c087f6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/http.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9c087f6

Please sign in to comment.