1
0
Fork 0

http.c: Merge payload_{get,post} into process_payload

Both functions were in fact identical, so there was no reason to keep
two definitions rather than one.
This commit is contained in:
Xavier Del Campo Romero 2023-08-13 01:23:48 +02:00
parent 4ee88984fc
commit f6562ddab3
Signed by untrusted user: xavi
GPG Key ID: 84FF3612A9BF43F2
1 changed files with 3 additions and 17 deletions

20
http.c
View File

@ -905,7 +905,7 @@ static struct http_payload ctx_to_payload(const struct ctx *const c)
};
}
static int payload_get(struct http_ctx *const h, const char *const line)
static int process_payload(struct http_ctx *const h, const char *const line)
{
struct ctx *const c = &h->ctx;
const struct http_payload p = ctx_to_payload(c);
@ -919,20 +919,6 @@ static int payload_get(struct http_ctx *const h, const char *const line)
return start_response(h);
}
static int payload_post(struct http_ctx *const h, const char *const line)
{
struct ctx *const c = &h->ctx;
const struct http_payload pl = ctx_to_payload(c);
const int ret = h->cfg.payload(&pl, &h->wctx.r, h->cfg.user);
ctx_free(c);
if (ret)
return ret;
return start_response(h);
}
static int get_field_value(const char *const line, size_t *const n,
const char **const value)
{
@ -1052,12 +1038,12 @@ static int header_cr_line(struct http_ctx *const h)
switch (c->op)
{
case HTTP_OP_GET:
return payload_get(h, line);
return process_payload(h, line);
case HTTP_OP_POST:
{
if (!c->post.len)
return payload_post(h, line);
return process_payload(h, line);
else if (c->boundary)
{
const int res = check_length(h);