feat(net): implement VL-004 HttpServer and VL-005 streaming HttpClient with secure TLS

This commit is contained in:
faumaray committed 2026-11-26 21:47:15 +03:00
1 parent 22c8538754
commit 66baae74a0
12 files changed
+3984 -119

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 4.0)
project(VoidNetOnlyConsumer LANGUAGES CXX)
find_package(Void CONFIG REQUIRED COMPONENTS Net)
add_executable(void_net_only_consumer main.cpp)
target_link_libraries(void_net_only_consumer PRIVATE Void::Net)
target_compile_features(void_net_only_consumer PRIVATE cxx_std_26)
enable_testing()
add_test(NAME NetOnlyConsumer COMMAND void_net_only_consumer)
+31
View File
@@ -0,0 +1,31 @@
#include <Void/Net/Http.hpp>
#include <Void/Net/HttpServer.hpp>
#include <string>
int main()
{
Void::Net::HttpServer server;
if (!server
.add_route(Void::Net::Method::Get, "/ping",
[](const Void::Net::ServerRequest&) {
return Void::Result::ok(Void::Net::ServerResponse{
.status = 200, .body = "pong"});
})
.has_value()) {
return 1;
}
if (!server.start().has_value() || server.bound_port() == 0) {
return 2;
}
auto client = Void::Net::HttpClient::secure();
if (!client.verify_tls()) {
return 3;
}
auto resp = client.get(server.base_url() + "/ping");
server.shutdown();
if (!resp.has_value() || resp->status != 200 || resp->body != "pong") {
return 4;
}
return 0;
}