summaryrefslogtreecommitdiff
path: root/src/libtipidee/tipidee_headers_get_content_length.c
blob: 0b29ece6d3b932e2ef3954972ec593f0f90d1aff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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 ;
}