Skip to content

Commit

Permalink
chore: ran formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
Taanviir committed Jun 8, 2024
1 parent ac9c760 commit 49232ce
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion sources/CGI/Cgi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CGI::CGI(const Request& request, const ServerConfig& cfg, CachedPages& cp)
: _requestBody(request.get_body()), _cp(cp)
{
string resourcePath = request.get_resource_path();
_filePath = resourcePath;
_filePath = resourcePath;
if (!request.get_query_string().empty())
_queryString = request.get_query_string();
_environment = set_environment(request, cfg);
Expand Down
2 changes: 1 addition & 1 deletion sources/http/handler/DeleteRequestHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Response DeleteRequestHandler::handle_request(const Request& r)
LOG_DEBUG("Handling Delete request for resource: " + r.get_resource());

_add_header("Server", cfg.serverName);
status = r.get_status();
status = r.get_status();
vector<char> body = get_resource(r);
return Response(status, responseHeaders, body);
}
Expand Down
2 changes: 1 addition & 1 deletion sources/http/handler/ErrorHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ErrorHandler: public RequestHandlerBase {
Response handle_request(const Request& r)
{
const vector<char>& body = get_resource(r);
r.sent = true;
r.sent = true;
return Response(status, responseHeaders, body);
};

Expand Down
2 changes: 1 addition & 1 deletion sources/http/handler/GetRequestHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const vector<char> GetRequestHandler::get_resource(const Request& r)
return body;
}

struct stat fileInfo;
struct stat fileInfo;
stat(resourcePath.c_str(), &fileInfo);
if (S_ISDIR(fileInfo.st_mode)) {
ifstream indexFile(index.c_str(), std::ios_base::binary);
Expand Down
8 changes: 4 additions & 4 deletions sources/http/handler/PostRequestHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,17 @@ vector<char> PostRequestHandler::handle_upload(const Request& r, const string& d
// Ensure the upload directory exists
struct stat st;
if (stat(dirPath.c_str(), &st) != 0) {
if (mkdir(dirPath.c_str(), 0700) != 0) {
if (mkdir(dirPath.c_str(), 0700) != 0)
return make_error_body(INTERNAL_SERVER_ERROR);
}
} else if (!S_ISDIR(st.st_mode)) {
}
else if (!S_ISDIR(st.st_mode)) {
return make_error_body(INTERNAL_SERVER_ERROR);
}

ofstream outputFile(fileName.c_str(), std::ios_base::binary);
if (outputFile.fail())
return make_error_body(INTERNAL_SERVER_ERROR);

outputFile.write(fileContent.c_str(), fileContent.size());
outputFile.close();

Expand Down
4 changes: 2 additions & 2 deletions sources/http/request/Request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class Request {

void set_status(STATUS_CODE);

TimeOut timer;
mutable bool sent;
TimeOut timer;
mutable bool sent;

friend ostream& operator<<(ostream& os, const Request& r);

Expand Down
2 changes: 1 addition & 1 deletion sources/http/response/Response.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Response {
~Response();
Response(const Response& other);
void send_response(fd recv_socket) const;
bool sent;
bool sent;

private:
STATUS_CODE status;
Expand Down
2 changes: 1 addition & 1 deletion sources/parser/ServerConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct ServerConfig {
StatusCodeMap errorPages;
map<string, Location> locations;
CachedPages* cp;
RedirectionMap redirections;
RedirectionMap redirections;

bool redirect_to(string& uri) const
{
Expand Down
3 changes: 1 addition & 2 deletions sources/server/CachedPages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ Page& CachedPages::get_page(const string& pageName)

void CachedPages::set_index_page(const string& indexPath)
{
if (pages.find(indexPath) == pages.end()) {
if (pages.find(indexPath) == pages.end())
load_page(indexPath);
}
}
4 changes: 2 additions & 2 deletions sources/server/connection_manager/ConnectionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ void ConnectionManager::check_connection(fd currentSocket)
ConnectionMap::iterator it = connectionMap.find(currentSocket);
if (it != connectionMap.end() && it->second.timer.is_timeout()) {
it->second.set_status(REQUEST_TIMEOUT);
it->second.cgiStatus = COMPLETED;
}
it->second.cgiStatus = COMPLETED;
}
}
5 changes: 2 additions & 3 deletions sources/server/connection_manager/ConnectionManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,8 @@ inline Request& ConnectionManager::add_connection(fd newConnection)
Request& r = connectionMap.insert(make_pair(newConnection, Request())).first->second;
LOG_DEBUG("ConnectionManager: Added connection [" + ws_itoa(newConnection) + "]");
maxSD = std::max(maxSD, newConnection);
if (r.get_status() != REQUEST_TIMEOUT) {
r.timer.update_time();
}
if (r.get_status() != REQUEST_TIMEOUT)
r.timer.update_time();
return (r);
}

Expand Down

0 comments on commit 49232ce

Please sign in to comment.