connection: New API: get_content_length

Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
This commit is contained in:
Jianhui Zhao committed 2021-01-15 17:17:23 +08:00
1 parent fa6248b1f1
commit 2f12b7d434
3 files changed
+10 -7

No files matched your search

+8
View File
@@ -305,6 +305,13 @@ static struct uh_str conn_get_header(struct uh_connection *conn, const char *nam
return value;
}
static uint64_t conn_get_content_length(struct uh_connection *conn)
{
struct uh_connection_internal *conni = (struct uh_connection_internal *)conn;
return conni->parser.content_length;
}
static struct uh_str conn_get_body(struct uh_connection *conn)
{
struct uh_connection_internal *conni = (struct uh_connection_internal *)conn;
@@ -752,6 +759,7 @@ static void conn_init_cb(struct uh_connection *conn)
conn->get_path = conn_get_path;
conn->get_query = conn_get_query;
conn->get_header = conn_get_header;
conn->get_content_length = conn_get_content_length;
conn->get_body = conn_get_body;
conn->extract_body = conn_extract_body;
}
+1
View File
@@ -75,6 +75,7 @@ struct uh_connection {
struct uh_str (*get_path)(struct uh_connection *conn);
struct uh_str (*get_query)(struct uh_connection *conn);
struct uh_str (*get_header)(struct uh_connection *conn, const char *name);
uint64_t (*get_content_length)(struct uh_connection *conn);
struct uh_str (*get_body)(struct uh_connection *conn);
/* The remain body data will be discurd after this function called */
struct uh_str (*extract_body)(struct uh_connection *conn);