Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions include/crow/http_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,16 @@ namespace crow
// if no route is found for the request method, return the response without parsing or processing anything further.
if (!routing_handle_result_->rule_index)
{
parser_.done();
need_to_call_after_handlers_ = true;
complete_request();
if (req_.method == HTTPMethod::Options)
{
need_to_call_after_handlers_ = true;
}
else
{
parser_.done();
need_to_call_after_handlers_ = true; // Not sure if the order of this and the above line matters
complete_request();
}
}
}

Expand Down Expand Up @@ -180,7 +187,11 @@ namespace crow
CROW_LOG_INFO << "Request: " << utility::lexical_cast<std::string>(adaptor_.remote_endpoint()) << " " << this << " HTTP/" << (char)(req_.http_ver_major + '0') << "." << (char)(req_.http_ver_minor + '0') << ' ' << method_name(req_.method) << " " << req_.url;


need_to_call_after_handlers_ = false;
if (req_.method != HTTPMethod::Options)
{
need_to_call_after_handlers_ = false;
}

if (!is_invalid_request)
{
res.complete_request_handler_ = nullptr;
Expand Down
13 changes: 5 additions & 8 deletions include/crow/middlewares/cors.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,13 @@ namespace crow

bool origin_set = false;

if (req.method != HTTPMethod::Options)
if (allow_credentials_)
{
if (allow_credentials_)
set_header_no_override("Access-Control-Allow-Credentials", "true", res);
if (origin_ == "*")
{
set_header_no_override("Access-Control-Allow-Credentials", "true", res);
if (origin_ == "*")
{
set_header_no_override("Access-Control-Allow-Origin", req.get_header_value("Origin"), res);
origin_set = true;
}
set_header_no_override("Access-Control-Allow-Origin", req.get_header_value("Origin"), res);
origin_set = true;
}
}

Expand Down
Loading