From aff4ae5b8793d9700959f58b362c74d6b6fb4675 Mon Sep 17 00:00:00 2001 From: Matisse Chenavas Date: Tue, 27 Aug 2024 19:13:30 +0200 Subject: [PATCH] fuck timeout --- siegeurls.txt | 9 ++++++++- src/ConnectionHandler.cpp | 11 +++++++---- src/Server.cpp | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/siegeurls.txt b/siegeurls.txt index 727f54b..d46d516 100644 --- a/siegeurls.txt +++ b/siegeurls.txt @@ -1 +1,8 @@ -http://localhost:8080/cgi/compute.py +http://localhost:8080/ +http://localhost:8080/nonexistent +http://localhost:8080/cgi/hello.py?name=Marvin +http://localhost:8080/cgi/hello.php?name=Marvin +http://localhost:8080/cgi/hello.js?name=Marvin +http://localhost:8080/cgi/post.py POST {"name": "Marvin"} +http://localhost:8080/cgi/post.php POST {"name": "Marvin"} +http://localhost:8080/cgi/post.js POST {"name": "Marvin"} diff --git a/src/ConnectionHandler.cpp b/src/ConnectionHandler.cpp index 19d9a6f..85cb7c8 100644 --- a/src/ConnectionHandler.cpp +++ b/src/ConnectionHandler.cpp @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* ConnectionHandler.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: agaley +#+ +:+ +#+ */ +/* By: mchenava +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/30 16:11:21 by agaley #+# #+# */ -/* Updated: 2024/08/27 17:20:41 by agaley ### ########lyon.fr */ +/* Updated: 2024/08/27 19:06:37 by mchenava ### ########.fr */ /* */ /* ************************************************************************** */ @@ -125,7 +125,7 @@ void ConnectionHandler::_receiveRequest(struct epoll_event& event) { } _request = new HTTPRequest(_requestString); } - + if (headersEnd){ if (_request->getMethod() == "GET" || _request->getMethod() == "HEAD" || _request->getMethod() == "DELETE") _processRequest(event); @@ -264,6 +264,9 @@ int ConnectionHandler::processConnection(struct epoll_event& event) { if ((time(NULL) - _startTime) > TIMEOUT) { HTTPResponse::sendResponse(HTTPResponse::GATEWAY_TIMEOUT, _clientSocket); + const LocationConfig location; + _response->setStatusCode(HTTPResponse::GATEWAY_TIMEOUT); + _cacheHandler.storeResponse(_cacheHandler.generateKey(*_request), *_response); _setConnectionStatus(CLOSED); } try { @@ -301,7 +304,7 @@ int ConnectionHandler::processConnection(struct epoll_event& event) { if (!_cgiHandler) { throw Exception("CONNECTION_HANDLER: CGIHandler is NULL"); } - _events.push(event); + _events.push(event); break; case CACHE_WAITING: diff --git a/src/Server.cpp b/src/Server.cpp index 7f5b37e..56248c2 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -262,6 +262,6 @@ void Server::_setupServerSockets() { continue; } _listenSockets[sock] = listenConfig; - // _listenEventData.insert(eventData); + _listenEventData.insert(eventData); } }