Something went wrong. Try again.
An HTTP library for Zig 0.17, server and client, HTTP/1.0 through HTTP/3, with the protocol in a module that owns no socket.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us>// SPDX-License-Identifier: MIT
const std = @import("std");const quic = @import("quic");const http = @import("http");const z46 = @import("z46");const http_io = @import("http_io");
test "an address reaching a handler is a value, not socket plumbing" { // The boundary this module is built on, asserted rather than described. // `transport.Endpoint` is z46's, which parses, formats canonically and // compares; `std.Io.net.IpAddress` is what a socket hands over, and the // conversion between them happens once, in `http_io`, at the edge. // // If these were ever made the same type again, `http` would be naming // the networking namespace and this would say so. try std.testing.expect(http.transport.Endpoint != std.Io.net.IpAddress); try std.testing.expect(http.transport.Endpoint == z46.Endpoint);
// And it survives the round trip, which is what makes the edge honest. const original: std.Io.net.IpAddress = .{ .ip4 = .loopback(8080) }; const value: http.transport.Endpoint = .fromStdAddress(original); try std.testing.expect(value.eql(.fromStdAddress(value.toStdAddress())));
var buffer: [64]u8 = undefined; try std.testing.expectEqualStrings("127.0.0.1:8080", try value.bufPrint(&buffer));}
test "one certificate type, not two that look alike" { // The claim in 621bde5's message, checked rather than asserted: both // modules reach tls.zig through `b.dependency("tls", .{})` with the same // pin and the same (empty) options, so the dependency cache hands them // the same module -- and a `CertKeyPair` loaded for QUIC is usable by the // TLS listener without a conversion. try std.testing.expect(quic.tls_handshake.CertKeyPair == http_io.tls.CertKeyPair);}