commit 3ae9bb7ae9adf30f5dd75259f38912de64773bae
parent 4db51d78461cdfe84c19dc21f31de078f192c953
Author: Joris Vink <joris@coders.se>
Date: Fri, 10 Mar 2017 14:36:51 +0100
change type of maxage.
Diffstat:
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/examples/cookies/src/cookies.c b/examples/cookies/src/cookies.c
@@ -38,11 +38,11 @@ serve_cookies(struct http_request *req)
/* no expire, no maxage for current path. */
http_response_cookie(req, "Simple", "Hello World!",
- req->path, 0, -1, NULL);
+ req->path, 0, 0, NULL);
/* expire, no maxage, for /secure. */
http_response_cookie(req, "Complex", "Secure Value!", "/secure",
- time(NULL) + (1 * 60 * 60), -1, NULL);
+ time(NULL) + (1 * 60 * 60), 0, NULL);
/* maxage, no httponly, for current path. */
http_response_cookie(req, "key", "value", req->path, 0, 60, &cookie);
diff --git a/includes/http.h b/includes/http.h
@@ -75,7 +75,7 @@ struct http_cookie {
char *value;
char *path;
char *domain;
- int maxage;
+ u_int32_t maxage;
time_t expires;
u_int16_t flags;
@@ -269,7 +269,7 @@ int http_state_run(struct http_state *, u_int8_t,
int http_request_cookie(struct http_request *,
const char *, char **);
void http_response_cookie(struct http_request *, const char *,
- const char *, const char *, time_t, int,
+ const char *, const char *, time_t, u_int32_t,
struct http_cookie **);
int http_argument_urldecode(char *);
diff --git a/src/http.c b/src/http.c
@@ -1019,7 +1019,7 @@ http_file_rewind(struct http_file *file)
void
http_response_cookie(struct http_request *req, const char *name,
- const char *val, const char *path, time_t expires, int maxage,
+ const char *val, const char *path, time_t expires, u_int32_t maxage,
struct http_cookie **out)
{
struct http_cookie *ck;
@@ -1672,8 +1672,8 @@ http_write_response_cookie(struct http_cookie *ck)
kore_buf_appendf(ckhdr_buf, "; Expires=%s", expires);
}
- if (ck->maxage != -1)
- kore_buf_appendf(ckhdr_buf, "; Max-Age=%d", ck->maxage);
+ if (ck->maxage > 0)
+ kore_buf_appendf(ckhdr_buf, "; Max-Age=%u", ck->maxage);
if (ck->flags & HTTP_COOKIE_HTTPONLY)
kore_buf_appendf(ckhdr_buf, "; HttpOnly");