36 |
|
|
37 |
void print_content_length(request * req) |
void print_content_length(request * req) |
38 |
{ |
{ |
39 |
|
char buf[22]; |
40 |
|
|
41 |
|
simple_itoa(req->filesize, buf); |
42 |
req_write(req, "Content-Length: "); |
req_write(req, "Content-Length: "); |
43 |
req_write(req, simple_itoa(req->filesize)); |
req_write(req, buf); |
44 |
req_write(req, "\r\n"); |
req_write(req, "\r\n"); |
45 |
} |
} |
46 |
|
|
47 |
void print_last_modified(request * req) |
void print_last_modified(request * req) |
48 |
{ |
{ |
49 |
static char lm[] = "Last-Modified: " |
char lm[] = "Last-Modified: " |
50 |
" " "\r\n"; |
" " "\r\n"; |
51 |
rfc822_time_buf(lm + 15, req->last_modified); |
rfc822_time_buf(lm + 15, req->last_modified); |
52 |
req_write(req, lm); |
req_write(req, lm); |
54 |
|
|
55 |
void print_ka_phrase(request * req) |
void print_ka_phrase(request * req) |
56 |
{ |
{ |
57 |
|
|
58 |
if (req->kacount > 0 && |
if (req->kacount > 0 && |
59 |
req->keepalive == KA_ACTIVE && req->response_status < 500) { |
req->keepalive == KA_ACTIVE && req->response_status < 500) { |
60 |
|
char buf[22]; |
61 |
req_write(req, "Connection: Keep-Alive\r\nKeep-Alive: timeout="); |
req_write(req, "Connection: Keep-Alive\r\nKeep-Alive: timeout="); |
62 |
req_write(req, simple_itoa(ka_timeout)); |
simple_itoa(ka_timeout, buf); |
63 |
|
req_write(req, buf); |
64 |
req_write(req, ", max="); |
req_write(req, ", max="); |
65 |
req_write(req, simple_itoa(req->kacount)); |
simple_itoa(req->kacount, buf); |
66 |
|
req_write(req, buf); |
67 |
req_write(req, "\r\n"); |
req_write(req, "\r\n"); |
68 |
} else |
} else |
69 |
req_write(req, "Connection: close\r\n"); |
req_write(req, "Connection: close\r\n"); |
73 |
|
|
74 |
void print_http_headers(request * req) |
void print_http_headers(request * req) |
75 |
{ |
{ |
76 |
static char date_stuff[] = "Date: " |
char date_stuff[] = "Date: " |
77 |
" " |
" " |
78 |
"\r\n"; |
"\r\n"; |
79 |
|
|
328 |
/* R_SERVICE_UNAVAILABLE: 503 */ |
/* R_SERVICE_UNAVAILABLE: 503 */ |
329 |
void send_r_service_unavailable(request * req) /* 503 */ |
void send_r_service_unavailable(request * req) /* 503 */ |
330 |
{ |
{ |
331 |
static char body[] = |
static const char body[] = |
332 |
"<HTML><HEAD><TITLE>503 Service Unavailable</TITLE></HEAD>\n" |
"<HTML><HEAD><TITLE>503 Service Unavailable</TITLE></HEAD>\n" |
333 |
"<BODY><H1>503 Service Unavailable</H1>\n" |
"<BODY><H1>503 Service Unavailable</H1>\n" |
334 |
"There are too many connections in use right now.\r\n" |
"There are too many connections in use right now.\r\n" |
335 |
"Please try again later.\r\n</BODY></HTML>\n"; |
"Please try again later.\r\n</BODY></HTML>\n"; |
336 |
static int _body_len; |
static int _body_len; |
337 |
static char *body_len; |
static char body_len[22]; |
338 |
|
|
339 |
if (!_body_len) |
if (!_body_len) |
340 |
_body_len = strlen(body); |
_body_len = strlen(body); |
341 |
if (!body_len) |
if (!body_len[0]) |
342 |
body_len = strdup(simple_itoa(_body_len)); |
simple_itoa( _body_len, body_len); |
|
if (!body_len) { |
|
|
log_error_time(); |
|
|
perror("strdup of _body_len from simple_itoa"); |
|
|
} |
|
|
|
|
343 |
|
|
344 |
SQUASH_KA(req); |
SQUASH_KA(req); |
345 |
req->response_status = R_SERVICE_UNAV; |
req->response_status = R_SERVICE_UNAV; |