Merge pull request #371 from CrowCpp/lowercase_methods

Fixed issue where parser methods were in all caps
This commit is contained in:
Farook Al-Sammarraie 2022-03-21 14:22:07 +03:00 committed by GitHub
commit 588020ee1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 40 deletions

View File

@ -95,7 +95,7 @@ namespace crow
Subscribe,
Unsubscribe,
Mkcalendar,
MkCalendar,
Link,
Unlink,
@ -314,7 +314,7 @@ constexpr crow::HTTPMethod operator"" _method(const char* str, size_t /*len*/)
crow::black_magic::is_equ_p(str, "SUBSCRIBE", 9) ? crow::HTTPMethod::Subscribe :
crow::black_magic::is_equ_p(str, "UNSUBSCRIBE", 11) ? crow::HTTPMethod::Unsubscribe :
crow::black_magic::is_equ_p(str, "MKCALENDAR", 10) ? crow::HTTPMethod::Mkcalendar :
crow::black_magic::is_equ_p(str, "MKCALENDAR", 10) ? crow::HTTPMethod::MkCalendar :
crow::black_magic::is_equ_p(str, "LINK", 4) ? crow::HTTPMethod::Link :
crow::black_magic::is_equ_p(str, "UNLINK", 6) ? crow::HTTPMethod::Unlink :

View File

@ -784,21 +784,21 @@ reexecute:
parser->method = 0;
parser->index = 1;
switch (ch) {
case 'A': parser->method = (unsigned)HTTPMethod::ACL; break;
case 'B': parser->method = (unsigned)HTTPMethod::BIND; break;
case 'C': parser->method = (unsigned)HTTPMethod::CONNECT; /* or COPY, CHECKOUT */ break;
case 'D': parser->method = (unsigned)HTTPMethod::DELETE; break;
case 'G': parser->method = (unsigned)HTTPMethod::GET; break;
case 'H': parser->method = (unsigned)HTTPMethod::HEAD; break;
case 'L': parser->method = (unsigned)HTTPMethod::LOCK; /* or LINK */ break;
case 'M': parser->method = (unsigned)HTTPMethod::MKCOL; /* or MOVE, MKACTIVITY, MERGE, M-SEARCH, MKCALENDAR */ break;
case 'N': parser->method = (unsigned)HTTPMethod::NOTIFY; break;
case 'O': parser->method = (unsigned)HTTPMethod::OPTIONS; break;
case 'P': parser->method = (unsigned)HTTPMethod::POST; /* or PROPFIND|PROPPATCH|PUT|PATCH|PURGE */ break;
case 'R': parser->method = (unsigned)HTTPMethod::REPORT; /* or REBIND */ break;
case 'S': parser->method = (unsigned)HTTPMethod::SUBSCRIBE; /* or SEARCH, SOURCE */ break;
case 'T': parser->method = (unsigned)HTTPMethod::TRACE; break;
case 'U': parser->method = (unsigned)HTTPMethod::UNLOCK; /* or UNSUBSCRIBE, UNBIND, UNLINK */ break;
case 'A': parser->method = (unsigned)HTTPMethod::Acl; break;
case 'B': parser->method = (unsigned)HTTPMethod::Bind; break;
case 'C': parser->method = (unsigned)HTTPMethod::Connect; /* or COPY, CHECKOUT */ break;
case 'D': parser->method = (unsigned)HTTPMethod::Delete; break;
case 'G': parser->method = (unsigned)HTTPMethod::Get; break;
case 'H': parser->method = (unsigned)HTTPMethod::Head; break;
case 'L': parser->method = (unsigned)HTTPMethod::Lock; /* or LINK */ break;
case 'M': parser->method = (unsigned)HTTPMethod::MkCol; /* or MOVE, MKACTIVITY, MERGE, M-SEARCH, MKCALENDAR */ break;
case 'N': parser->method = (unsigned)HTTPMethod::Notify; break;
case 'O': parser->method = (unsigned)HTTPMethod::Options; break;
case 'P': parser->method = (unsigned)HTTPMethod::Post; /* or PROPFIND|PROPPATCH|PUT|PATCH|PURGE */ break;
case 'R': parser->method = (unsigned)HTTPMethod::Report; /* or REBIND */ break;
case 'S': parser->method = (unsigned)HTTPMethod::Subscribe; /* or SEARCH, SOURCE */ break;
case 'T': parser->method = (unsigned)HTTPMethod::Trace; break;
case 'U': parser->method = (unsigned)HTTPMethod::Unlock; /* or UNSUBSCRIBE, UNBIND, UNLINK */ break;
default:
CROW_SET_ERRNO(CHPE_INVALID_METHOD);
goto error;
@ -830,25 +830,25 @@ reexecute:
case ((unsigned)HTTPMethod::meth << 16 | pos << 8 | ch): \
parser->method = (unsigned)HTTPMethod::new_meth; break;
CROW_XX(POST, 1, 'U', PUT)
CROW_XX(POST, 1, 'A', PATCH)
CROW_XX(POST, 1, 'R', PROPFIND)
CROW_XX(PUT, 2, 'R', PURGE)
CROW_XX(CONNECT, 1, 'H', CHECKOUT)
CROW_XX(CONNECT, 2, 'P', COPY)
CROW_XX(MKCOL, 1, 'O', MOVE)
CROW_XX(MKCOL, 1, 'E', MERGE)
CROW_XX(MKCOL, 1, '-', MSEARCH)
CROW_XX(MKCOL, 2, 'A', MKACTIVITY)
CROW_XX(MKCOL, 3, 'A', MKCALENDAR)
CROW_XX(SUBSCRIBE, 1, 'E', SEARCH)
CROW_XX(SUBSCRIBE, 1, 'O', SOURCE)
CROW_XX(REPORT, 2, 'B', REBIND)
CROW_XX(PROPFIND, 4, 'P', PROPPATCH)
CROW_XX(LOCK, 1, 'I', LINK)
CROW_XX(UNLOCK, 2, 'S', UNSUBSCRIBE)
CROW_XX(UNLOCK, 2, 'B', UNBIND)
CROW_XX(UNLOCK, 3, 'I', UNLINK)
CROW_XX(Post, 1, 'U', Put)
CROW_XX(Post, 1, 'A', Patch)
CROW_XX(Post, 1, 'R', Propfind)
CROW_XX(Put, 2, 'R', Purge)
CROW_XX(Connect, 1, 'H', Checkout)
CROW_XX(Connect, 2, 'P', Copy)
CROW_XX(MkCol, 1, 'O', Move)
CROW_XX(MkCol, 1, 'E', Merge)
CROW_XX(MkCol, 1, '-', MSearch)
CROW_XX(MkCol, 2, 'A', MkActivity)
CROW_XX(MkCol, 3, 'A', MkCalendar)
CROW_XX(Subscribe, 1, 'E', Search)
CROW_XX(Subscribe, 1, 'O', Source)
CROW_XX(Report, 2, 'B', Rebind)
CROW_XX(Propfind, 4, 'P', Proppatch)
CROW_XX(Lock, 1, 'I', Link)
CROW_XX(Unlock, 2, 'S', Unsubscribe)
CROW_XX(Unlock, 2, 'B', Unbind)
CROW_XX(Unlock, 3, 'I', Unlink)
#undef CROW_XX
default:
CROW_SET_ERRNO(CHPE_INVALID_METHOD);
@ -869,7 +869,7 @@ reexecute:
CROW_MARK(url);
CROW_MARK(url_start);
if (parser->method == (unsigned)HTTPMethod::CONNECT) {
if (parser->method == (unsigned)HTTPMethod::Connect) {
parser->state = s_req_server_start;
}
@ -918,7 +918,7 @@ reexecute:
break;
case cr: // No space after URL means no HTTP version. Which means the request is using HTTP/0.9
case lf:
if (CROW_UNLIKELY(parser->method != (unsigned)HTTPMethod::GET)) // HTTP/0.9 doesn't define any method other than GET
if (CROW_UNLIKELY(parser->method != (unsigned)HTTPMethod::Get)) // HTTP/0.9 doesn't define any method other than GET
{
parser->state = s_dead;
CROW_SET_ERRNO(CHPE_INVALID_VERSION);
@ -949,7 +949,7 @@ reexecute:
parser->state = s_req_http_H;
break;
case 'I':
if (parser->method == (unsigned)HTTPMethod::SOURCE) {
if (parser->method == (unsigned)HTTPMethod::Source) {
parser->state = s_req_http_I;
break;
}
@ -1603,7 +1603,7 @@ reexecute:
/* Set this here so that on_headers_complete() callbacks can see it */
parser->upgrade =
(parser->flags & F_UPGRADE || parser->method == (unsigned)HTTPMethod::CONNECT);
(parser->flags & F_UPGRADE || parser->method == (unsigned)HTTPMethod::Connect);
/* Here we call the headers_complete callback. This is somewhat
* different than other callbacks because if the user returns 1, we