diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-09-21 02:18:35 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska@appnovation.com> | 2023-09-21 02:18:35 +0000 |
| commit | 3d334dca671898241732dbc0ef6838b768308da7 (patch) | |
| tree | 0cac6b60ea1356455fef2553e41105f3c68bce9d /src/libtipidee/tipidee_util_httpdate.c | |
| parent | 6be5496f8a5660875c5f45f915210f69496d231b (diff) | |
| download | tipidee-3d334dca671898241732dbc0ef6838b768308da7.tar.gz | |
Implement If-Modified-Since
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libtipidee/tipidee_util_httpdate.c')
| -rw-r--r-- | src/libtipidee/tipidee_util_httpdate.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libtipidee/tipidee_util_httpdate.c b/src/libtipidee/tipidee_util_httpdate.c new file mode 100644 index 0000000..cce735d --- /dev/null +++ b/src/libtipidee/tipidee_util_httpdate.c @@ -0,0 +1,22 @@ +/* ISC license. */ + +#include <errno.h> +#include <time.h> + +#include <skalibs/djbtime.h> + +#include <tipidee/util.h> + +int tipidee_util_httpdate (char const *s, tain *stamp) +{ + struct tm tm ; + if (strptime(s, "%a, %d %b %Y %T GMT", &tm)) goto got ; + if (strptime(s, "%a, %d-%b-%y %T GMT", &tm)) goto got ; + if (strptime(s, "%a %b %d %T %Y", &tm)) goto got ; + return (errno = EINVAL, 0) ; + + got: + if (!tai_from_localtm(tain_secp(stamp), &tm)) return 0 ; + stamp->nano = 0 ; + return 1 ; +} |
