New function: uh_unescape()

Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
This commit is contained in:
Jianhui Zhao committed 2017-11-14 22:16:26 +08:00
1 parent a01d37430d
commit f9184839ff
4 files changed
+42 -24

No files matched your search

+4
View File
@@ -15,6 +15,9 @@ void route_test(struct uh_connection *con)
struct uh_value name = uh_get_var(con, "name");
struct uh_value *header_host = uh_get_header(con, "Host");
struct uh_value *header_ua = uh_get_header(con, "User-Agent");
char unescaped_name[128];
uh_unescape(name.at, name.len, unescaped_name, sizeof(unescaped_name));
uh_send_head(con, UH_STATUS_OK, -1, NULL);
uh_printf_chunk(con, "<h1>Hello World</h1>");
@@ -22,6 +25,7 @@ void route_test(struct uh_connection *con)
uh_printf_chunk(con, "<h1>Url: %.*s</h1>", (int)url->len, url->at);
uh_printf_chunk(con, "<h1>Path: %.*s</h1>", (int)path->len, path->at);
uh_printf_chunk(con, "<h1>Name: %.*s</h1>", (int)name.len, name.at);
uh_printf_chunk(con, "<h1>Unescaped Name: %s</h1>", unescaped_name);
if (header_host)
uh_printf_chunk(con, "<h1>Host: %.*s</h1>", (int)header_host->len, header_host->at);