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

Fixed web service crash #4334

Merged
merged 2 commits into from
Jun 20, 2022
Merged
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
2 changes: 1 addition & 1 deletion src/webservice/GetFlagsHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ using proxygen::ResponseBuilder;
using proxygen::UpgradeProtocol;

void GetFlagsHandler::onRequest(std::unique_ptr<HTTPMessage> headers) noexcept {
if (headers->getMethod().value() != HTTPMethod::GET) {
if (!headers->getMethod() || headers->getMethod().value() != HTTPMethod::GET) {
// Unsupported method
err_ = HttpCode::E_UNSUPPORTED_METHOD;
return;
Expand Down
2 changes: 1 addition & 1 deletion src/webservice/GetStatsHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using proxygen::ResponseBuilder;
using proxygen::UpgradeProtocol;

void GetStatsHandler::onRequest(std::unique_ptr<HTTPMessage> headers) noexcept {
if (headers->getMethod().value() != HTTPMethod::GET) {
if (!headers->getMethod() || headers->getMethod().value() != HTTPMethod::GET) {
// Unsupported method
err_ = HttpCode::E_UNSUPPORTED_METHOD;
return;
Expand Down
3 changes: 3 additions & 0 deletions src/webservice/Router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ proxygen::RequestHandler *Route::generateHandler(const std::string &path) const

proxygen::RequestHandler *Router::dispatch(const proxygen::HTTPMessage *msg) const {
for (Route *r = head_; r != nullptr; r = r->next()) {
if (!msg->getMethod()) {
break;
}
if (r->matches(msg->getMethod().value(), msg->getPath())) {
return r->generateHandler(msg->getPath());
}
Expand Down
2 changes: 1 addition & 1 deletion src/webservice/SetFlagsHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ using proxygen::ResponseBuilder;
using proxygen::UpgradeProtocol;

void SetFlagsHandler::onRequest(std::unique_ptr<HTTPMessage> headers) noexcept {
if (headers->getMethod().value() != HTTPMethod::PUT) {
if (!headers->getMethod() || headers->getMethod().value() != HTTPMethod::PUT) {
// Unsupported method
err_ = HttpCode::E_UNSUPPORTED_METHOD;
return;
Expand Down
2 changes: 1 addition & 1 deletion src/webservice/StatusHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ using proxygen::ResponseBuilder;
using proxygen::UpgradeProtocol;

void StatusHandler::onRequest(std::unique_ptr<HTTPMessage> headers) noexcept {
if (headers->getMethod().value() != HTTPMethod::GET) {
if (!headers->getMethod() || headers->getMethod().value() != HTTPMethod::GET) {
// Unsupported method
err_ = HttpCode::E_UNSUPPORTED_METHOD;
return;
Expand Down