feat(net): implement VL-004 HttpServer and VL-005 streaming HttpClient with secure TLS
This commit is contained in:
1 parent
22c8538754
commit
66baae74a0
12 files changed
+3984
-119
No files matched your search
@@ -292,6 +292,14 @@ if(_has_fsm)
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
||||
endif()
|
||||
|
||||
has_modules(_has_net Net Functional Text)
|
||||
if(_has_net)
|
||||
run_consumer(NetOnly "${install_prefix}" "NetOnly"
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
||||
endif()
|
||||
|
||||
# Foundation consumer with Core-formatting bridge and zero external packages.
|
||||
has_modules(_has_foundation Math Text Time Functional Binary FunctionalCoreFormatting Memory Core)
|
||||
if(_has_foundation)
|
||||
|
||||
@@ -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)
|
||||
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user