Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process all method like POST (with body). #165

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 1 addition & 7 deletions src/webserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,8 +776,6 @@ int webserver::answer_to_connection(void* cls, MHD_Connection* connection,
base_unescaper(t_url, static_cast<webserver*>(cls)->unescaper);
mr->standardized_url = new string(http_utils::standardize_url(t_url));

bool body = false;

access_log(
static_cast<webserver*>(cls),
*(mr->complete_uri) + " METHOD: " + method
Expand All @@ -790,22 +788,18 @@ int webserver::answer_to_connection(void* cls, MHD_Connection* connection,
else if (0 == strcmp(method, http_utils::http_method_post.c_str()))
{
mr->callback = &http_resource::render_POST;
body = true;
}
else if (0 == strcasecmp(method, http_utils::http_method_put.c_str()))
{
mr->callback = &http_resource::render_PUT;
body = true;
}
else if (0 == strcasecmp(method,http_utils::http_method_delete.c_str()))
{
mr->callback = &http_resource::render_DELETE;
body = true;
}
else if (0 == strcasecmp(method, http_utils::http_method_patch.c_str()))
{
mr->callback = &http_resource::render_PATCH;
body = true;
}
else if (0 == strcasecmp(method, http_utils::http_method_head.c_str()))
{
Expand All @@ -824,7 +818,7 @@ int webserver::answer_to_connection(void* cls, MHD_Connection* connection,
mr->callback = &http_resource::render_OPTIONS;
}

return body ? static_cast<webserver*>(cls)->bodyfull_requests_answer_first_step(connection, mr) : static_cast<webserver*>(cls)->bodyless_requests_answer(connection, method, version, mr);
return static_cast<webserver*>(cls)->bodyfull_requests_answer_first_step(connection, mr);
}

};