@@ -10,7 +10,13 @@ extern "C"
10
10
#include " ../common/HTTPS.h"
11
11
#include " ../common/config.h"
12
12
13
- static std::set<std::string> validMethod {" GET" , " HEAD" , " POST" , " PUT" , " DELETE" , " PATCH" };
13
+ static std::string validMethod[] = {" GET" , " HEAD" , " POST" , " PUT" , " DELETE" , " PATCH" };
14
+
15
+ static int str_toupper (char c)
16
+ {
17
+ unsigned char uc = (unsigned char ) c;
18
+ return toupper (uc);
19
+ }
14
20
15
21
static std::string w_checkstring (lua_State *L, int idx)
16
22
{
@@ -41,13 +47,15 @@ static void w_readheaders(lua_State *L, int idx, HTTPSClient::header_map &header
41
47
42
48
static std::string w_optmethod (lua_State *L, int idx, const std::string &defaultMethod)
43
49
{
50
+ std::string *const validMethodEnd = validMethod + sizeof (validMethod) / sizeof (std::string);
51
+
44
52
if (lua_isnoneornil (L, idx))
45
53
return defaultMethod;
46
54
47
55
std::string str = w_checkstring (L, idx);
48
- std::transform (str.begin (), str.end (), str.begin (), []( unsigned char c) { return toupper (c); } );
56
+ std::transform (str.begin (), str.end (), str.begin (), str_toupper );
49
57
50
- if (validMethod. find (str) == validMethod. end () )
58
+ if (std:: find (validMethod, validMethodEnd, str) == validMethodEnd )
51
59
luaL_argerror (L, idx, " expected one of \" get\" , \" head\" , \" post\" , \" put\" , \" delete\" , or \" patch\" " );
52
60
53
61
return str;
0 commit comments