1
Fork 0

http::new_request: wrap Host in [] for ipv6

This commit is contained in:
Drew DeVault 2023-02-09 23:31:12 +01:00
parent 4bb0cd5c7e
commit 8cde44d639
2 changed files with 5 additions and 1 deletions

View file

@ -11,6 +11,7 @@ export fn main() void = {
scheme = "http",
host = ip::LOCAL_V6,
path = "/",
port = 8080,
...
});
http::write_header(os::stdout, &req.header)!;

View file

@ -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) {