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