aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksey Veresov <aleksey@veresov.pro>2020-03-13 19:32:17 +0300
committerAleksey Veresov <aleksey@veresov.pro>2020-03-13 19:32:17 +0300
commitc5d69441bd43ace9d9c2b03a89aa0ed4871c288d (patch)
tree2577a813f8cf65bb0bbdb212da73e78af3bff58d /src
parentac5114fdf74099a8ce8b9c154231e226e6883b94 (diff)
downloadmagi-c5d69441bd43ace9d9c2b03a89aa0ed4871c288d.tar
magi-c5d69441bd43ace9d9c2b03a89aa0ed4871c288d.tar.xz
magi-c5d69441bd43ace9d9c2b03a89aa0ed4871c288d.zip
[magi] Cookies almost work.
Diffstat (limited to 'src')
-rw-r--r--src/response.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/response.c b/src/response.c
index f7a6f67..400080a 100644
--- a/src/response.c
+++ b/src/response.c
@@ -27,11 +27,18 @@ void magi_response_status(magi_request *r, int code, const char *description)
void magi_response_cookie(magi_request *r, const char *name, const char *data)
{
magi_param addon;
+ int nlen;
+ int dlen;
if (r->response->head_done) {
return;
}
+ nlen = strlen(name);
+ dlen = strlen(data);
addon.name = magi_str_create_copy("Set-Cookie", 10);
- /* TODO */
+ addon.data = malloc(nlen + dlen + 2);
+ memcpy(addon.data, name, nlen);
+ addon.data[nlen] = '=';
+ memcpy(addon.data + nlen + 1, data, dlen + 1);
magi_params_add(&r->response->head_general, &addon);
}