-
Notifications
You must be signed in to change notification settings - Fork 1
/
z_http.c
40 lines (34 loc) · 801 Bytes
/
z_http.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "z_features.h"
#include "z_http.h"
void http_content_type(const char *t)
{
sprintm("Content-type: ", t, "; charset=UTF-8\r\n\r\n");
}
void http_set_cookie(const char *k, const char *v, const char *o)
{
sprintm("Set-Cookie: ", k, "=");
sprint(v);
sprintm(";", o, "\r\n");
}
void http_set_cookie_ssl_age(const char *k, const char *v, const char *a)
{
sprintm("Set-Cookie: ", k, "=");
sprint(v);
sprintm(";", "Secure; HttpOnly; Discard; Max-Age=", a, "\";\r\n");
}
#ifdef WANT_HTTP_304
void http_last_modified(time_t t)
{
char fmt[FMT_HTTPDATE];
fmt[fmt_httpdate(fmt, t)] = 0;
sprintm("Last-Modified: ", fmt, "\r\n");
}
void http_not_changed_modified()
{
sprint("Status: 304 Not Modified\r\n\r\n");
}
#endif
void http_not_found()
{
sprint("Status: 404 Bad Request\r\n\r\n");
}