r17692 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17691‎ | r17692 | r17693 >
Date:05:12, 15 November 2006
Author:river
Status:old
Tags:
Comment:
need to add Via, X-Cache headers, and content-length if the cache entity doesn't have one and isn't chunked
Modified paths:
  • /trunk/willow/src/include/cache.h (modified) (history)
  • /trunk/willow/src/include/whttp.h (modified) (history)
  • /trunk/willow/src/willow/whttp.cc (modified) (history)

Diff [purge]

Index: trunk/willow/src/include/cache.h
@@ -49,6 +49,14 @@
5050 WDEBUG((WLOG_DEBUG, format("set_complete: void=%d") % _void));
5151 if (_void)
5252 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();
5361 _complete = true;
5462 }
5563
@@ -58,8 +66,8 @@
5967
6068 void store_headers(header_list const &h) {
6169 _headers = h;
62 - _builthdrs = _headers.build();
63 - _builtsz = _headers.length();
 70+ _headers.add("X-Cache", cache_hit_hdr);
 71+ _headers.add("Via", via_hdr);
6472 }
6573
6674 time_t lastuse(void) const {
Index: trunk/willow/src/include/whttp.h
@@ -24,6 +24,9 @@
2525
2626 extern const char *request_string[];
2727 extern char my_hostname[];
 28+extern char *cache_miss_hdr;
 29+extern char *cache_hit_hdr;
 30+extern char via_hdr[];
2831
2932 enum http_version {
3033 http10,
Index: trunk/willow/src/willow/whttp.cc
@@ -80,9 +80,9 @@
8181 static void *client_thread(void *);
8282 static void stats_merge(int, short, void *);
8383
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;
8787
8888 tss<event> merge_ev;
8989
@@ -601,6 +601,9 @@
602602 _backend_headers->_headers.add("Keep-Alive", "300");
603603 }
604604
 605+ _backend_headers->_headers.add("X-Cache", cache_miss_hdr);
 606+ _backend_headers->_headers.add("Via", via_hdr);
 607+
605608 /*
606609 * Send the headers to the client.
607610 */