Skip to content

Commit

Permalink
chore(Server): rename is_request_ready to validate_request
Browse files Browse the repository at this point in the history
- moved the recv function to handle_connection for better logical separation
  • Loading branch information
samih713 committed Apr 21, 2024
1 parent e74242a commit c4ef4f1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions sources/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ Server::~Server()

/* ---------------------------- HANDLE CONNECTION --------------------------- */

bool Server::is_request_ready(Request& r, fd incoming)
bool Server::validate_request(Request& r)
{
try {
r.recv(incoming);
if (!r.parse_request(config))
return false;
return true;
Expand All @@ -75,7 +74,8 @@ void Server::handle_connection(fd incoming, fd_set& activeSockets)
ConnectionManager::check_connection(incoming);
Request& r = ConnectionManager::add_connection(incoming, activeSockets);
try {
if (!is_request_ready(r, incoming))
r.recv(incoming);
if (!validate_request(r))
return;

IRequestHandler* handler =
Expand Down
2 changes: 1 addition & 1 deletion sources/server/Server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Server {
const ServerConfig& config;
CachedPages* cachedPages;

bool is_request_ready(Request& r, fd incoming);
bool validate_request(Request& r);
void handle_connection(fd incoming, fd_set& activeSockets);
/* polling strats */
void select_strat();
Expand Down

0 comments on commit c4ef4f1

Please sign in to comment.