Implement vitastor-cli serve command to serve simple HTTP API

This commit is contained in:
Vitaliy Filippov
2026-04-17 13:53:40 +03:00
parent 4ba361d83d
commit 07c9606594
9 changed files with 561 additions and 38 deletions
+31
View File
@@ -503,3 +503,34 @@ bool is_zero(void *buf, size_t size)
}
return true;
}
char hextochar(char h)
{
if (h >= 'a' && h <= 'f')
return h-'a'+10;
else if (h >= 'A' && h <= 'F')
return h-'A'+10;
else if (h >= '0' && h <= '9')
return h-'0';
return 0;
}
std::string urldecode(const std::string & orig)
{
size_t len = orig.size();
std::string res;
res.reserve(len);
for (size_t i = 0; i < len; i++)
{
if (orig[i] == '+')
res.push_back(' ');
else if (orig[i] == '%' && i < len-2)
{
res.push_back(hextochar(orig[i+1])*16 + hextochar(orig[i+2]));
i += 2;
}
else
res.push_back(orig[i]);
}
return res;
}