summaryrefslogtreecommitdiff
path: root/httpd.c
diff options
context:
space:
mode:
authorGravatar default2022-09-24 12:22:17 +0200
committerGravatar default2022-09-24 12:22:17 +0200
commitc3e19f1650ce37b9fe138e1de03083faa2d593a5 (patch)
treecb09d9e1f982ffebe394f8ce11756526e972d55d /httpd.c
parentMore work. (diff)
downloadsnac2-c3e19f1650ce37b9fe138e1de03083faa2d593a5.tar.gz
snac2-c3e19f1650ce37b9fe138e1de03083faa2d593a5.tar.xz
snac2-c3e19f1650ce37b9fe138e1de03083faa2d593a5.zip
Added some aechiving.
Diffstat (limited to 'httpd.c')
-rw-r--r--httpd.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/httpd.c b/httpd.c
index 8e40d55..2c36364 100644
--- a/httpd.c
+++ b/httpd.c
@@ -169,6 +169,40 @@ void httpd_connection(int rs)
169 169
170 fclose(f); 170 fclose(f);
171 171
172 /* obsessive archiving */
173 {
174 xs *date = xs_local_time("%Y%m%d%H%M%S");
175 xs *dir = xs_fmt("%s/archive/%s", srv_basedir, date);
176
177 if (mkdir(dir, 0755) != -1) {
178 xs *meta_fn = xs_fmt("%s/meta", dir);
179 xs *payload_fn = xs_fmt("%s/payload", dir);
180 xs *body_fn = xs_fmt("%s/body", dir);
181
182 if ((f = fopen(meta_fn, "w")) != NULL) {
183 xs *j1 = xs_json_dumps_pp(req, 4);
184 xs *j2 = xs_json_dumps_pp(headers, 4);
185
186 fprintf(f, "req: %s\n", j1);
187 fprintf(f, "p_size: %d\n", p_size);
188 fprintf(f, "status: %d\n", status);
189 fprintf(f, "response: %s\n", j2);
190 fprintf(f, "b_size: %d\n", b_size);
191 fclose(f);
192 }
193
194 if (p_size && payload && (f = fopen(payload_fn, "w")) != NULL) {
195 fwrite(payload, p_size, 1, f);
196 fclose(f);
197 }
198
199 if (b_size && body && (f = fopen(body_fn, "w")) != NULL) {
200 fwrite(body, p_size, 1, f);
201 fclose(f);
202 }
203 }
204 }
205
172 free(body); 206 free(body);
173} 207}
174 208