summaryrefslogtreecommitdiff
path: root/httpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'httpd.c')
-rw-r--r--httpd.c34
1 files changed, 1 insertions, 33 deletions
diff --git a/httpd.c b/httpd.c
index 2c36364..bf72d5a 100644
--- a/httpd.c
+++ b/httpd.c
@@ -169,39 +169,7 @@ void httpd_connection(int rs)
169 169
170 fclose(f); 170 fclose(f);
171 171
172 /* obsessive archiving */ 172 srv_archive("RECV", req, payload, p_size, status, headers, body, b_size);
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 173
206 free(body); 174 free(body);
207} 175}