diff --git a/src/HTTP.cpp b/src/HTTP.cpp index 3666b68..d0decd0 100644 --- a/src/HTTP.cpp +++ b/src/HTTP.cpp @@ -1,17 +1,6 @@ #include "Helpers.hpp" #include "Main.hpp" -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include void HTTPrequest::start() { // Possible Logging here @@ -36,6 +25,8 @@ void HTTPrequest::sendResponse(std::string status, std::string mime, << "\r\nConnection: close\r\n\r\n" << data; + // Idea here is that in TCP oncee you sent a shutdown you should read until + // EOF. When that happens, you know that the package is fully recieved responseText = output.str(); asio::async_write( sock, asio::buffer(responseText), @@ -47,14 +38,15 @@ void HTTPrequest::sendResponse(std::string status, std::string mime, // I'm not happy with this void HTTPrequest::waitForClientClose() { - auto buf = std::array(); + auto buf = std::array(); // I don't think there is a smaller possible + // constructor :( sock.async_read_some(asio::buffer(buf), [this, self = shared_from_this()]( const std::error_code &error, std::size_t) { if (error) { - sock.close(); + sock.close(); // This triggers when EOF } - waitForClientClose(); + waitForClientClose(); // Ew recursion. Must fix. }); } // ================= CLASS HANDLING SPECIFIC =================