Respond to POSTs as well as GETs in /cm handler (#900)

* add method to parse args from body instead of just url

* Allow /cm to POST and PUT as well as GET

* forgot to ensure didn't misparse non GET/PUT/POST in /cm requests

---------

Co-authored-by: Tim Connors <tconnors@rather.puzzling.org>
This commit is contained in:
Tim Connors
2023-08-16 16:15:48 +10:00
committed by GitHub
parent a5cf6b3440
commit e130cfddbe
3 changed files with 27 additions and 10 deletions

View File

@ -351,14 +351,9 @@ int http_copyCarg(const char* atin, char* to, int maxSize) {
return realSize;
}
int http_getArg(const char* base, const char* name, char* o, int maxSize) {
int http_getRawArg(const char* base, const char* name, char* o, int maxSize) {
*o = '\0';
while (*base != '?') {
if (*base == 0)
return 0;
base++;
}
base++;
while (*base) {
const char* at = http_checkArg(base, name);
if (at) {
@ -375,6 +370,17 @@ int http_getArg(const char* base, const char* name, char* o, int maxSize) {
}
return 0;
}
int http_getArg(const char* base, const char* name, char* o, int maxSize) {
*o = '\0';
while (*base != '?') {
if (*base == '\0')
return 0;
base++;
}
base++;
return http_getRawArg(base, name, o, maxSize);
}
int http_getArgInteger(const char* base, const char* name) {
char tmp[16];
if (http_getArg(base, name, tmp, sizeof(tmp)) == 0)