1
0
forked from cat/WebBase

No need to do a while loop

This commit is contained in:
2025-07-17 00:12:42 +03:00
parent 6f450eda86
commit e4d187e93e
2 changed files with 5 additions and 5 deletions

View File

@@ -1,5 +1,7 @@
#include "../Helpers.hpp"
#include "../Main.hpp"
#include <asio/impl/read.hpp>
#include <asio/impl/read_until.hpp>
#include <asio/socket_base.hpp>
#include <iostream>
#include <istream>
@@ -9,6 +11,7 @@ void HTTPrequest::processHTTPHeader() {
std::shared_ptr<HTTPrequest> self(shared_from_this());
// HEADER read
//
asio::async_read_until(
sock, buffer, "\r\n\r\n", // its not the other way bud
[this, self](std::error_code error, std::size_t packageSize) {
@@ -80,7 +83,7 @@ void inline HTTPrequest::processBody() {
// This part needs to be sync since we want this specific instance
// execution to pause
while (octetCount < uploadSize) {
if (octetCount < uploadSize) {
octetCount += asio::read(sock, buffer.prepare(uploadSize));
}

View File

@@ -1,6 +1,5 @@
#include "Helpers.hpp"
#include "Main.hpp"
#include <sstream>
// Idea is very simple this map has it so that stuff like
// responseMethods["GET","/"] have a method inside them
@@ -21,8 +20,6 @@ void Webserver::initResponses() {
responseMethods["POST"]["/upload"] = [](HTTPrequest *self) {
auto result = Helpers::processFormData(self->bodyContent,
self->headers["Content-Type"]);
std::stringstream resp;
resp << self->bodyContent;
self->sendResponse("200 OK", "text/text", resp.str());
self->sendResponse("200 OK", "text/text", self->bodyContent);
};
}