C and C++ web framework.
http://rapida.vilor.one/docs
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.2 KiB
51 lines
1.2 KiB
/* SPDX-License-Identifier: GPL-3.0-or-later */ |
|
/* Copyright 2022 Ivan Polyakov */ |
|
|
|
#include "request.h" |
|
#include <stdlib.h> |
|
#include <string.h> |
|
|
|
enum rpd_req_methods rpd_req_smethod(const char *method) |
|
{ |
|
if (!strcmp(method, "GET")) |
|
return GET; |
|
else if (!strcmp(method, "HEAD")) |
|
return HEAD; |
|
else if (!strcmp(method, "POST")) |
|
return POST; |
|
else if (!strcmp(method, "PUT")) |
|
return PUT; |
|
else if (!strcmp(method, "PATCH")) |
|
return PATCH; |
|
else if (!strcmp(method, "DELETE")) |
|
return DELETE; |
|
else if (!strcmp(method, "CONNECT")) |
|
return CONNECT; |
|
else if (!strcmp(method, "OPTIONS")) |
|
return OPTIONS; |
|
else if (!strcmp(method, "TRACE")) |
|
return TRACE; |
|
return UNKNOWN; |
|
} |
|
|
|
void rpd_req_cleanup(rpd_req *req) |
|
{ |
|
rpd_keyval_cleanup(&req->params); |
|
|
|
if (req->body) { |
|
free(req->body); |
|
req->body = NULL; |
|
} |
|
|
|
if (req->query.size) { |
|
rpd_keyval_cleanup(&req->query); |
|
} |
|
|
|
if (req->params.size) { |
|
for (int i = 0; i < req->params.size; i++) { |
|
rpd_keyval_item *item = req->params.items + i; |
|
free(item->val); |
|
item->val = NULL; |
|
} |
|
} |
|
}
|
|
|