forked from xavi/libweb
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:
parent
4ee88984fc
commit
f6562ddab3
20
http.c
20
http.c
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue