From 519559c12f87496e702def0fd5348287379b63dc Mon Sep 17 00:00:00 2001 From: Jianhui Zhao Date: Tue, 5 Dec 2017 15:52:27 +0800 Subject: [PATCH] uh_get_con_sock(): New function Signed-off-by: Jianhui Zhao --- src/include/uhttp/uhttp.h | 2 ++ src/uhttp.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/include/uhttp/uhttp.h b/src/include/uhttp/uhttp.h index 8e726cd..f69a669 100755 --- a/src/include/uhttp/uhttp.h +++ b/src/include/uhttp/uhttp.h @@ -109,6 +109,8 @@ struct uh_str *uh_get_query(struct uh_connection *con); struct uh_str uh_get_var(struct uh_connection *con, const char *name); struct uh_str *uh_get_header(struct uh_connection *con, const char *name); +int uh_get_con_sock(struct uh_connection *con); + /* Unescapes strings like '%7B1,%202,%203%7D' would become '{1, 2, 3}' */ int uh_unescape(const char *str, int len, char *out, int olen); diff --git a/src/uhttp.c b/src/uhttp.c index 199a16c..dd03fa1 100755 --- a/src/uhttp.c +++ b/src/uhttp.c @@ -582,6 +582,11 @@ inline struct uh_str *uh_get_query(struct uh_connection *con) return &con->req.query; } +int uh_get_con_sock(struct uh_connection *con) +{ + return con->sock; +} + static inline char c2hex(char c) { return c >= '0' && c <= '9' ? c - '0' : c >= 'A' && c <= 'F' ? c - 'A' + 10 : c - 'a' + 10; /* accept small letters just in case */