aboutsummaryrefslogtreecommitdiffstats
path: root/src/tipideed/tipideed.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-12-20 14:08:25 +0000
committerLaurent Bercot <ska@appnovation.com>2023-12-20 14:08:25 +0000
commit51d0fdce74aeb23ef28336037b2d35aa4c955cee (patch)
tree9c178c8e6756ec770b85efd54235cd7c2a97888f /src/tipideed/tipideed.c
parentd2959364ef8d6bc948474a8facf497788b4e768b (diff)
downloadtipidee-51d0fdce74aeb23ef28336037b2d35aa4c955cee.tar.gz
Major refactors; implement ranges
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/tipideed/tipideed.c')
-rw-r--r--src/tipideed/tipideed.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/tipideed/tipideed.c b/src/tipideed/tipideed.c
index 8323db1..69280f6 100644
--- a/src/tipideed/tipideed.c
+++ b/src/tipideed/tipideed.c
@@ -11,6 +11,7 @@
#include <skalibs/posixplz.h>
#include <skalibs/env.h>
#include <skalibs/uint16.h>
+#include <skalibs/uint64.h>
#include <skalibs/types.h>
#include <skalibs/bytestr.h>
#include <skalibs/sgetopt.h>
@@ -286,7 +287,7 @@ static inline int serve (tipidee_rql *rql, char const *docroot, char *uribuf, ti
if (!ra.flags & TIPIDEE_RA_FLAG_CGI)
{
if (infopath) { respond_404(rql, docroot) ; return 0 ; }
- if (rql->m == TIPIDEE_METHOD_POST) exit_405(rql) ;
+ if (rql->m == TIPIDEE_METHOD_POST) exit_405(rql, docroot, 0) ;
}
if (rql->m == TIPIDEE_METHOD_OPTIONS)
@@ -306,6 +307,19 @@ static inline int serve (tipidee_rql *rql, char const *docroot, char *uribuf, ti
&& tain_less(&actual, &wanted))
return respond_304(rql, fn, &st) ;
}
+
+ if (rql->m == TIPIDEE_METHOD_GET)
+ {
+ infopath = tipidee_headers_search(hdr, "Range") ;
+ if (infopath)
+ {
+ uint64_t start, len ;
+ int r = tipidee_util_parse_range(infopath, st.st_size, &start, &len) ;
+ if (r > 0) return respond_partial(rql, docroot, fn, &st, start, len, &ra) ;
+ if (r < 0) { respond_416(rql, docroot, st.st_size) ; return 0 ; }
+ }
+ }
+
return respond_regular(rql, docroot, fn, &st, &ra) ;
}