src/server/daemon/protocol.c

changeset 103
d3b514e2ddbd
parent 101
7fbcdbad0baa
child 104
a8acbb12f27c
equal deleted inserted replaced
102:136a76e293b5 103:d3b514e2ddbd
30 30
31 #include "../util/pblock.h" 31 #include "../util/pblock.h"
32 #include "../util/pool.h" 32 #include "../util/pool.h"
33 #include "session.h" 33 #include "session.h"
34 #include "../util/io.h" 34 #include "../util/io.h"
35 35 #include "../util/util.h"
36 #include "../util/strbuf.h" 36 #include "../util/strbuf.h"
37 37
38 38
39 void protocol_status(Session *sn, Request *rq, int n, const char *m) { 39 void protocol_status(Session *sn, Request *rq, int n, const char *m) {
40 rq->status_num = n; 40 rq->status_num = n;
306 // add the http status line to the output buffer 306 // add the http status line to the output buffer
307 add_http_status_line(out, sn->pool, rq); 307 add_http_status_line(out, sn->pool, rq);
308 308
309 // add server header 309 // add server header
310 sbuf_write(out, "Server: webserver\r\n", 19); 310 sbuf_write(out, "Server: webserver\r\n", 19);
311
312 // add date header
313 struct tm mtms;
314 struct tm *mtm = system_gmtime(&rq->req_start, &mtms);
315 char date[HTTP_DATE_LEN + 1];
316 strftime(date, HTTP_DATE_LEN, HTTP_DATE_FMT, mtm);
317 sbuf_write(out, "Date: ", 6);
318 sbuf_write(out, date, strlen(date));
319 sbuf_write(out, "\r\n", 2);
311 320
312 // check content length ans transfer encoding 321 // check content length ans transfer encoding
313 char *ctlen = pblock_findkeyval(pb_key_content_length, rq->srvhdrs); 322 char *ctlen = pblock_findkeyval(pb_key_content_length, rq->srvhdrs);
314 char *enc = pblock_findkeyval(pb_key_transfer_encoding, rq->srvhdrs); 323 char *enc = pblock_findkeyval(pb_key_transfer_encoding, rq->srvhdrs);
315 if(ctlen && enc) { 324 if(ctlen && enc) {

mercurial