Add HTTP PATCH method (#476)

This commit is contained in:
itgenie98 2020-06-14 15:57:25 +02:00 committed by GitHub
parent 2457f9b413
commit 14b5ec08ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 0 deletions

View File

@ -21,6 +21,8 @@ std::string method2String(HttpMethod m)
return "DELETE";
case Options:
return "OPTIONS";
case Patch:
return "PATCH";
default:
return "INVALID";
}

View File

@ -334,6 +334,9 @@ int main()
case Head:
std::cout << " (Head) ";
break;
case Patch:
std::cout << " (PATCH) ";
break;
default:
break;
}

View File

@ -118,6 +118,7 @@ enum HttpMethod
Put,
Delete,
Options,
Patch,
Invalid
};

View File

@ -202,6 +202,10 @@ static void loadControllers(const Json::Value &controllers)
{
constraints.push_back(Delete);
}
else if (strMethod == "patch")
{
constraints.push_back(Patch);
}
}
}
if (!controller["filters"].isNull())

View File

@ -536,6 +536,9 @@ const char *HttpRequestImpl::methodString() const
case Options:
result = "OPTIONS";
break;
case Patch:
result = "PATCH";
break;
default:
break;
}
@ -576,6 +579,16 @@ bool HttpRequestImpl::setMethod(const char *start, const char *end)
method_ = Invalid;
}
break;
case 5:
if (m == "PATCH")
{
method_ = Patch;
}
else
{
method_ = Invalid;
}
break;
case 6:
if (m == "DELETE")
{