Skip to content

Commit

Permalink
fix(compile): fix compilation error
Browse files Browse the repository at this point in the history
  • Loading branch information
dantol29 committed May 22, 2024
1 parent de35844 commit 34f26b1
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
11 changes: 6 additions & 5 deletions src/HTTPResponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ std::string HTTPResponse::objToString() const
std::stringstream responseStream;
if (_statusCode == 0)
{
std::cerr << "\033[31mWarning: Sending a response with status code 0\033[0m" << std::endl;
Debug::log("Sending a response with status code 0", Debug::NORMAL);
}
responseStream << "HTTP/1.1 " << _statusCode << " " << getStatusMessage(_statusCode) << "\r\n";
for (size_t i = 0; i < _headers.size(); ++i)
Expand Down Expand Up @@ -70,12 +70,13 @@ int HTTPResponse::getStatusCode() const
void HTTPResponse::setStatusCode(int statusCode, const std::string &message)
{
if (!message.empty())
std::cerr << message << std::endl;
Debug::log(message, Debug::NORMAL);
if (_statusCode != 0)
{
std::cerr << "\033[31mWarning: Overwriting existing status code (" << _statusCode << ") and message ("
<< _statusMessage << ") with new code (" << statusCode << ") and message ("
<< getStatusMessage(statusCode) << ").\033[0m" << std::endl;
Debug::log("Warning: Overwriting existing status code (" + toString(_statusCode) + ") and message (" +
_statusMessage + ") with new code (" + toString(statusCode) + ") and message (" +
getStatusMessage(statusCode) + ").",
Debug::NORMAL);
}

_statusCode = statusCode;
Expand Down
2 changes: 1 addition & 1 deletion src/Router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void Router::routeRequest(HTTPRequest &request, HTTPResponse &response)
Debug::log("Routing Request: path = " + request.getPath(), Debug::NORMAL);

PathValidation pathResult = pathIsValid(response, request);
Debug::log("Routing Request: pathResult = " + std::to_string(pathResult), Debug::NORMAL);
Debug::log("Routing Request: pathResult = " + toString(pathResult), Debug::NORMAL);
Debug::log("Path requested: " + request.getPath(), Debug::NORMAL);
// check if method is allowed

Expand Down
8 changes: 4 additions & 4 deletions src/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const EventManager &Server::getEventManager() const
void Server::startListening()
{
createServerSockets(_serverBlocks);
printServerSockets();
//printServerSockets();
setReuseAddrAndPort();
checkSocketOptions();
bindToPort();
Expand Down Expand Up @@ -124,8 +124,8 @@ void Server::waitCGI()
Debug::log("PID: " + toString(pid), Debug::CGI);

for (size_t i = 0; i < originalSize && i < _FDs.size(); i++)
Debug::log("PID: " + toString(_connections[i].getCGIPid() + ", hasCGI: " + \
toString(_connections[i].getHasCGI())), Debug::CGI);
Debug::log("PID: " + toString(_connections[i].getCGIPid()) + ", hasCGI: " + \
toString(_connections[i].getHasCGI()), Debug::CGI);

if (pid > 0)
{
Expand Down Expand Up @@ -561,7 +561,7 @@ void Server::createServerSockets(std::vector<ServerBlock> &serverBlocks)
}
else
{
std::cout << "IPV6_V6ONLY: " << ipv6only << std::endl;
Debug::log("IPV6_V6ONLY: " + toString(ipv6only), Debug::SERVER);
}
ServerSocket serverSocket(serverFD, *it);
_serverSockets.push_back(serverSocket);
Expand Down
2 changes: 1 addition & 1 deletion src/Server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "ServerSocket.hpp"
#include "EventManager.hpp"

#define VERBOSE 1
#define VERBOSE 0

class Connection; // Forward declaration for circular dependencyA

Expand Down
5 changes: 3 additions & 2 deletions src/ServerSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ void ServerSocket::prepareServerSocketAddr()

std::ostream &operator<<(std::ostream &out, const ServerSocket &socket)
{
out << "Fd: " << socket.getServerFD() << std::endl;
out << "Listen: " << socket.getListen() << std::endl;
(void)socket;
//out << "Fd: " << socket.getServerFD() << std::endl;
//out << "Listen: " << socket.getListen() << std::endl;
// out << "ServerSocketAddr: " << socket.getServerSocketAddr() << std::endl;
return out;
}
6 changes: 2 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

int main(int argc, char **argv)
{
Debug::enable(true);
Debug::enable(false);
Debug::setLevel(Debug::NORMAL);

if (argc > 2)
Expand All @@ -19,16 +19,14 @@ int main(int argc, char **argv)
if (!config.getErrorMessage().empty())
return 1;

std::cout << config << std::endl; // should be in the DEBUG?
//std::cout << config << std::endl; // should be in the DEBUG?
EventManager eventManager;
Server webserv(config, eventManager);

ServerEventListener serverEventListener(webserv);

eventManager.subscribe(&serverEventListener);

std::cout << &webserv.getEventManager() << std::endl;

webserv.startListening();
webserv.startPollEventLoop();

Expand Down

0 comments on commit 34f26b1

Please sign in to comment.