Index: trunk/willow/src/include/cache.h |
— | — | @@ -49,6 +49,14 @@ |
50 | 50 | WDEBUG((WLOG_DEBUG, format("set_complete: void=%d") % _void)); |
51 | 51 | if (_void) |
52 | 52 | return; |
| 53 | + if (!_headers.find("content-length") && !_headers.find("transfer-encoding")) { |
| 54 | + char lenstr[64]; |
| 55 | + snprintf(lenstr, sizeof lenstr, "%lu", |
| 56 | + (unsigned long) _data.size()); |
| 57 | + _headers.add("Content-Length", lenstr); |
| 58 | + } |
| 59 | + _builthdrs = _headers.build(); |
| 60 | + _builtsz = _headers.length(); |
53 | 61 | _complete = true; |
54 | 62 | } |
55 | 63 | |
— | — | @@ -58,8 +66,8 @@ |
59 | 67 | |
60 | 68 | void store_headers(header_list const &h) { |
61 | 69 | _headers = h; |
62 | | - _builthdrs = _headers.build(); |
63 | | - _builtsz = _headers.length(); |
| 70 | + _headers.add("X-Cache", cache_hit_hdr); |
| 71 | + _headers.add("Via", via_hdr); |
64 | 72 | } |
65 | 73 | |
66 | 74 | time_t lastuse(void) const { |
Index: trunk/willow/src/include/whttp.h |
— | — | @@ -24,6 +24,9 @@ |
25 | 25 | |
26 | 26 | extern const char *request_string[]; |
27 | 27 | extern char my_hostname[]; |
| 28 | +extern char *cache_miss_hdr; |
| 29 | +extern char *cache_hit_hdr; |
| 30 | +extern char via_hdr[]; |
28 | 31 | |
29 | 32 | enum http_version { |
30 | 33 | http10, |
Index: trunk/willow/src/willow/whttp.cc |
— | — | @@ -80,9 +80,9 @@ |
81 | 81 | static void *client_thread(void *); |
82 | 82 | static void stats_merge(int, short, void *); |
83 | 83 | |
84 | | -static char via_hdr[1024]; |
85 | | -static char *cache_hit_hdr; |
86 | | -static char *cache_miss_hdr; |
| 84 | +char via_hdr[1024]; |
| 85 | +char *cache_hit_hdr; |
| 86 | +char *cache_miss_hdr; |
87 | 87 | |
88 | 88 | tss<event> merge_ev; |
89 | 89 | |
— | — | @@ -601,6 +601,9 @@ |
602 | 602 | _backend_headers->_headers.add("Keep-Alive", "300"); |
603 | 603 | } |
604 | 604 | |
| 605 | + _backend_headers->_headers.add("X-Cache", cache_miss_hdr); |
| 606 | + _backend_headers->_headers.add("Via", via_hdr); |
| 607 | + |
605 | 608 | /* |
606 | 609 | * Send the headers to the client. |
607 | 610 | */ |