diff options
| author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2026-08-30 15:41:46 +0200 |
|---|---|---|
| committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2026-08-30 15:41:46 +0200 |
| commit | 630a3b7f4fb0c786170e3903175e964bbc1bc77f (patch) | |
| tree | a2ddb0387375ad6b329460848f18e7429d1931b7 | |
| parent | 6fe110be47c0fc34bc9dce6d377ce9b48ab27c2e (diff) | |
| download | luasocket-630a3b7f4fb0c786170e3903175e964bbc1bc77f.tar.gz luasocket-630a3b7f4fb0c786170e3903175e964bbc1bc77f.tar.bz2 luasocket-630a3b7f4fb0c786170e3903175e964bbc1bc77f.zip | |
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
| -rw-r--r-- | src/http.lua | 3 |
1 files changed, 2 insertions, 1 deletions
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 | |||
| 229 | 229 | ||
| 230 | local function adjustheaders(reqt) | 230 | local function adjustheaders(reqt) |
| 231 | -- default headers | 231 | -- default headers |
| 232 | local host = reqt.host | 232 | local hosttype, host = url.classify_host(reqt.host) |
| 233 | if hosttype == "ipv6" then host = "[" .. host .. "]" end | ||
| 233 | local port = tostring(reqt.port) | 234 | local port = tostring(reqt.port) |
| 234 | if port ~= tostring(SCHEMES[reqt.scheme].port) then | 235 | if port ~= tostring(SCHEMES[reqt.scheme].port) then |
| 235 | host = host .. ':' .. port end | 236 | host = host .. ':' .. port end |
