From 3e33fd972994c2cdc7b7c94b7c5ff0cd46b0c393 Mon Sep 17 00:00:00 2001 From: anulax1225 Date: Wed, 6 Mar 2024 18:31:31 +0100 Subject: [PATCH] Prepering for basic http --- sandbox/client/client.cpp | 4 ++-- sandbox/server/server.cpp | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/sandbox/client/client.cpp b/sandbox/client/client.cpp index 661c6bc..8a002a8 100644 --- a/sandbox/client/client.cpp +++ b/sandbox/client/client.cpp @@ -1,3 +1,5 @@ +#include + #include "../commun.h" using namespace Bk::Net; @@ -12,8 +14,6 @@ int main() void http_client() { - log(dns_lookup("edus2.rpn.ch", IpVersion::IPv4)[0]) - IpAddress ip("127.0.0.1"); Socket sock(ip, PORT, IpProtocol::TCP); diff --git a/sandbox/server/server.cpp b/sandbox/server/server.cpp index 2edce3f..2099cf8 100644 --- a/sandbox/server/server.cpp +++ b/sandbox/server/server.cpp @@ -16,6 +16,7 @@ std::string http_handler(Socket& sock, Connection conn); void http_parser(std::string req); HttpMethod resolve_methode(std::string method); std::unique_ptr> string_split(std::string s, std::string delimiter); +std::string string_trim(const std::string& str, const std::string& whitespace = " "); int main() { @@ -28,6 +29,9 @@ void http_server() IpAddress ip("127.0.0.1"); Socket sock(ip, PORT, IpProtocol::TCP); bool running = sock.init() && sock.start(5); + + auto trimed_str = string_trim(std::string(" Hello ")); + log(trimed_str) while (running) { Connection conn = sock.ack(); @@ -93,7 +97,7 @@ std::unique_ptr> string_split(std::string s, std::strin return splits; } -std::string string_trim(const std::string& str, const std::string& whitespace = " \t") +std::string string_trim(const std::string& str, const std::string& whitespace) { const auto strBegin = str.find_first_not_of(whitespace); if (strBegin == std::string::npos)