Skip to content

Commit

Permalink
fuck timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Matisse Chenavas committed Aug 27, 2024
1 parent 301b8d0 commit aff4ae5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
9 changes: 8 additions & 1 deletion siegeurls.txt
Original file line number Diff line number Diff line change
@@ -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"}
11 changes: 7 additions & 4 deletions src/ConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* ConnectionHandler.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: agaley <agaley@student.42lyon.fr> +#+ +:+ +#+ */
/* By: mchenava <mchenava@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,6 @@ void Server::_setupServerSockets() {
continue;
}
_listenSockets[sock] = listenConfig;
// _listenEventData.insert(eventData);
_listenEventData.insert(eventData);
}
}

0 comments on commit aff4ae5

Please sign in to comment.