1
0
forked from cat/WebBase

Made args processing, header processing, and body processing inline methods. Additionally now most variables are class level instead of method level

This commit is contained in:
2025-07-03 00:04:03 +03:00
parent 64bc7d0fb7
commit b6e83e0216
3 changed files with 87 additions and 74 deletions

View File

@@ -18,7 +18,7 @@
using asocket = asio::ip::tcp::socket;
using asocket_ptr = std::shared_ptr<asocket>;
// We handle HTTP requests with readData, writeData, and processRequest
// We handle HTTP requests with processHTTPHeader, writeData, and processRequest
class HTTPrequest : public std::enable_shared_from_this<HTTPrequest> {
public:
typedef std::shared_ptr<HTTPrequest> HTTPrequest_ptr;
@@ -30,12 +30,23 @@ public:
private:
HTTPrequest(asio::io_context &context);
void processHTTPHeader();
void processRequest(std::string requestType, std::string requestPath,
std::unordered_map<std::string, std::string> request,
std::unordered_map<std::string, std::string> args);
void processRequest();
void writeData(std::string data);
// Breaking Header to in lines
void processHTTPHeader();
void inline processArgs();
void inline processHeaderValues(std::basic_istream<char> &stream,
std::size_t &octetCount,
std::size_t headerSize);
void inline processBody();
// Request itself
std::string requestType, requestPath;
std::unordered_map<std::string, std::string> headers, args;
std::string bodyContent;
// Networking
asio::ip::tcp::socket sock;
asio::streambuf buffer;
};