Add SetCookie method to redbean Lua (#265)

This commit is contained in:
Paul Kulchenko 2021-09-04 02:12:12 -07:00 committed by GitHub
parent 969174e155
commit 31dd714081
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 178 additions and 1 deletions

View file

@ -18,6 +18,7 @@
*/
#include "libc/bits/bits.h"
#include "libc/time/time.h"
#include "libc/str/str.h"
#include "net/http/http.h"
static unsigned ParseMonth(const char *p) {
@ -36,10 +37,12 @@ static unsigned ParseMonth(const char *p) {
* Sun, 04 Oct 2020 19:50:10 GMT
*
* @return seconds from unix epoch
* @param n if -1 implies strlen
* @see FormatHttpDateTime()
*/
int64_t ParseHttpDateTime(const char *p, size_t n) {
unsigned weekday, year, month, day, hour, minute, second, yday, leap;
if (n == -1) n = p ? strlen(p) : 0;
if (n != 29) return 0;
day = (p[5] - '0') * 10 + (p[6] - '0') - 1;
month = ParseMonth(p + 8);