aboutsummaryrefslogtreecommitdiffstats
path: root/src/libtipidee/tipidee_headers_get_content_length.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-08-05 11:51:25 +0000
committerLaurent Bercot <ska@appnovation.com>2023-08-05 11:51:25 +0000
commit17c382d1c9d7236c101418060758d2296cc5e17e (patch)
treefd00e58df0d9d3c70ddd1accfec9e819249c672a /src/libtipidee/tipidee_headers_get_content_length.c
downloadtipidee-17c382d1c9d7236c101418060758d2296cc5e17e.tar.gz
Initial commit
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libtipidee/tipidee_headers_get_content_length.c')
-rw-r--r--src/libtipidee/tipidee_headers_get_content_length.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libtipidee/tipidee_headers_get_content_length.c b/src/libtipidee/tipidee_headers_get_content_length.c
new file mode 100644
index 0000000..0b29ece
--- /dev/null
+++ b/src/libtipidee/tipidee_headers_get_content_length.c
@@ -0,0 +1,17 @@
+/* ISC license. */
+
+#include <stddef.h>
+#include <limits.h>
+
+#include <skalibs/types.h>
+
+#include <tipidee/headers.h>
+
+ssize_t tipidee_headers_get_content_length (tipidee_headers const *hdr)
+{
+ size_t n ;
+ char const *x = tipidee_headers_search(hdr, "Content-Length") ;
+ if (!x) return 0 ;
+ if (!size0_scan(x, &n) || n > SSIZE_MAX) return -1 ;
+ return n ;
+}