aboutsummaryrefslogtreecommitdiff
path: root/src/http.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/http.c')
-rw-r--r--src/http.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/http.c b/src/http.c
index 1312d4d..bfd6f9b 100644
--- a/src/http.c
+++ b/src/http.c
@@ -58,6 +58,11 @@ static void build_cookie_headers(char *cookie_headers_buffer,
}
}
+void beaker_clear_response_cookies(void) {
+ memset(cookies_to_set, 0, sizeof(cookies_to_set));
+ cookies_to_set_count = 0;
+}
+
void send_status(const char *status_line) {
if (current_client_socket == -1) {
beaker_log("ERROR",
@@ -97,6 +102,7 @@ void send_response(const char *html) {
char cookie_headers[BUFFER_SIZE];
build_cookie_headers(cookie_headers, sizeof(cookie_headers));
+ beaker_clear_response_cookies();
snprintf(http_response_header, sizeof(http_response_header),
"HTTP/1.1 200 OK\r\n"
@@ -119,8 +125,6 @@ void send_response(const char *html) {
"send_response: Failed to send HTML body.\n");
return;
}
-
- cookies_to_set_count = 0;
}
void send_redirect(const char *location) {
@@ -137,6 +141,7 @@ void send_redirect(const char *location) {
char cookie_headers[BUFFER_SIZE];
build_cookie_headers(cookie_headers, sizeof(cookie_headers));
+ beaker_clear_response_cookies();
snprintf(http_response_header, sizeof(http_response_header),
"HTTP/1.1 302 Found\r\n"
@@ -152,8 +157,6 @@ void send_redirect(const char *location) {
"send_redirect: Failed to send redirect header.\n");
return;
}
-
- cookies_to_set_count = 0;
}
void set_cookie(const char *name, const char *value, const char *expires,