Template
1
0

Removed pointless headers, added comments

This commit is contained in:
2025-07-05 01:19:41 +03:00
parent 809c833259
commit b1e96274ae

View File

@@ -1,17 +1,6 @@
#include "Helpers.hpp"
#include "Main.hpp"
#include <asio/buffer.hpp>
#include <asio/completion_condition.hpp>
#include <asio/impl/write.hpp>
#include <asio/registered_buffer.hpp>
#include <asio/socket_base.hpp>
#include <asio/streambuf.hpp>
#include <iostream>
#include <ostream>
#include <sstream>
#include <stdexcept>
#include <string>
#include <system_error>
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<char, 1>();
auto buf = std::array<char, 1>(); // 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 =================