Skip to content

Commit

Permalink
fix: exec_cgi error route
Browse files Browse the repository at this point in the history
  • Loading branch information
ak0327 committed Mar 8, 2024
1 parent 31f38df commit cce610d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ NAME = webserv
CXX = c++
CXXFLAGS = -std=c++98 -Wall -Wextra -Werror -MMD -MP -pedantic
#CXXFLAGS += -g -fsanitize=address,undefined -fno-omit-frame-pointer
#CXXFLAGS += -D DEBUG
CXXFLAGS += -D DEBUG

# SRCS -------------------------------------------------------------------------
SRCS_DIR = srcs
Expand Down
6 changes: 3 additions & 3 deletions srcs/Event/process_client_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ ProcResult Event::create_http_response() {
}
DEBUG_SERVER_PRINT(" -> create body (L:%d)", __LINE__);
}
// fallthrough
// fallthrough

case kCreatingResponseBody: {
DEBUG_SERVER_PRINT("[CreatingResponse] CreatingResponseBody (L:%d)", __LINE__);
Expand Down Expand Up @@ -335,11 +335,11 @@ ProcResult Event::execute_each_method() {
ProcResult Event::exec_cgi() {
this->set_event_phase(kExecuteCGI);
EventResult result = process_file_event();
if (result.is_err()) {
if (result.is_err()) { // not come here?
std::cerr << result.err_value() << std::endl; // todo: logging
return Failure;
}
return ExecutingCgi;
return result.ok_value(); // Failure or ExecutingCgi
}


Expand Down
6 changes: 4 additions & 2 deletions srcs/Event/process_file_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ EventResult Event::process_file_event() {
DEBUG_PRINT(YELLOW, " CGI Executing");
ProcResult exec_result = this->response_->exec_cgi_process();
if (exec_result == Failure) {
const std::string error_msg = CREATE_ERROR_INFO_STR("cgi exec error");
return EventResult::err(error_msg);
// const std::string error_msg = CREATE_ERROR_INFO_STR("cgi exec error");
// return EventResult::err(error_msg);
this->set_event_phase(kCreatingCGIBody);
return EventResult::ok(Failure);
}
DEBUG_PRINT(YELLOW, " success -> send");
this->set_event_phase(kSendingRequestBodyToCgi);
Expand Down

0 comments on commit cce610d

Please sign in to comment.