Files
faumarayandClaude Opus 4.8 c92dff6ff7 Add Void::Net — HTTP client + URL parser + SOCKS5/CONNECT proxies
New SHARED module built on Boost.Beast/Asio + OpenSSL (all generic, no
application coupling):
- Void::Net::Url — RFC 3986 parse into scheme/host/port/path/query/target
  (Boost.URL), with scheme-default ports and TLS detection.
- Void::Net::HttpClient — synchronous GET/POST/send with TLS (SNI),
  configurable User-Agent and TLS verification, request/response types.
- Proxy support: HTTP CONNECT tunnelling for TLS targets, plain-HTTP
  forwarding, and a full SOCKS5 handshake (auth, IPv4/IPv6/domain).
- Reuses Void::Encoding::Base64 for proxy auth.

Build wiring: Dependencies.cmake resolves Boost (headers + url) and OpenSSL
+ Threads via find_package (system Boost/OpenSSL). Tests cover URL parsing
and live localhost HTTP GET/POST round-trips (full suite 1136 pass).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 16:21:08 +03:00

49 lines
1.7 KiB
C++

#include <Void/Net/Url.hpp>
#include <Void/Testing/Assert.hpp>
#include <Void/Testing/Test.hpp>
#include <string>
Void::Testing::Test url_parse_https_defaults_port()
{
const auto u = Void::Net::Url::parse("https://example.com/path?q=1");
Void::Testing::expect(u.has_value());
Void::Testing::expect_eq(u->scheme, std::string{"https"});
Void::Testing::expect_eq(u->host, std::string{"example.com"});
Void::Testing::expect_eq(u->port, std::string{"443"});
Void::Testing::expect(u->is_tls);
Void::Testing::expect_eq(u->path, std::string{"/path"});
Void::Testing::expect_eq(u->query, std::string{"q=1"});
Void::Testing::expect_eq(u->target, std::string{"/path?q=1"});
}
Void::Testing::Test url_parse_http_explicit_port()
{
const auto u = Void::Net::Url::parse("http://localhost:8080/x");
Void::Testing::expect(u.has_value());
Void::Testing::expect_eq(u->port, std::string{"8080"});
Void::Testing::expect(!u->is_tls);
Void::Testing::expect_eq(u->target, std::string{"/x"});
}
Void::Testing::Test url_parse_root_path_defaults()
{
const auto u = Void::Net::Url::parse("http://example.com");
Void::Testing::expect(u.has_value());
Void::Testing::expect_eq(u->path, std::string{"/"});
Void::Testing::expect_eq(u->target, std::string{"/"});
Void::Testing::expect_eq(u->port, std::string{"80"});
}
Void::Testing::Test url_parse_preserves_encoded_query()
{
const auto u = Void::Net::Url::parse("https://h/s?q=a%20b&x=1");
Void::Testing::expect(u.has_value());
Void::Testing::expect_eq(u->query, std::string{"q=a%20b&x=1"});
}
Void::Testing::Test url_parse_rejects_garbage()
{
Void::Testing::expect(!Void::Net::Url::parse("ht tp://bad url").has_value());
}