From 8cde44d639244847ccb67c2735bc35b7f586f8f3 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 9 Feb 2023 23:31:12 +0100 Subject: [PATCH] http::new_request: wrap Host in [] for ipv6 --- cmd/http/main.ha | 1 + net/http/client.ha | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/http/main.ha b/cmd/http/main.ha index b7e9c16..c297459 100644 --- a/cmd/http/main.ha +++ b/cmd/http/main.ha @@ -11,6 +11,7 @@ export fn main() void = { scheme = "http", host = ip::LOCAL_V6, path = "/", + port = 8080, ... }); http::write_header(os::stdout, &req.header)!; diff --git a/net/http/client.ha b/net/http/client.ha index 43a77ac..0d6a41e 100644 --- a/net/http/client.ha +++ b/net/http/client.ha @@ -51,8 +51,11 @@ fn new_request(client: *client, method: str, target: *uri::uri) request = { let host = match (req.target.host) { case let host: str => yield host; - case let ip: ip::addr => + case let ip: ip::addr4 => yield ip::string(ip); + case let ip: ip::addr6 => + static let buf: [64 + 2]u8 = [0...]; + yield fmt::bsprintf(buf, "[{}]", ip::string(ip)); }; if (req.target.scheme == "http" && req.target.port != 80) {