From 1873edb5ed254c367bd9f47a69c057fa9c06764e Mon Sep 17 00:00:00 2001 From: Jianhui Zhao Date: Sat, 9 Dec 2017 17:00:25 +0800 Subject: [PATCH] Fix bug: uh_get_var() Signed-off-by: Jianhui Zhao --- src/uhttp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/uhttp.c b/src/uhttp.c index 3db56fd..fe9c29f 100755 --- a/src/uhttp.c +++ b/src/uhttp.c @@ -661,11 +661,14 @@ struct uh_str uh_get_var(struct uh_connection *con, const char *name) struct uh_str *body = &con->req.body; const char *pos, *tail, *p, *q; struct uh_str var = {.at = NULL, .len = 0}; + struct uh_str *content_type = uh_get_header(con, "Content-Type"); if (query->len > 0) { pos = query->at; tail = query->at + query->len - 1; } else if (body->len > 0) { + if (!content_type || !uh_str_cmp(content_type, "application/x-www-form-urlencoded")) + return var; pos = body->at; tail = body->at + body->len - 1; } else {