2 // System.Web.Caching.CachedVaryBy
5 // Jackson Harper (jackson@ximian.com)
7 // (C) 2003 Novell, Inc (http://www.novell.com)
14 namespace System.Web.Caching {
16 internal class CachedVaryBy {
18 private string[] prms;
19 private string[] headers;
20 private string custom;
22 internal CachedVaryBy (HttpCachePolicy policy)
24 prms = policy.VaryByParams.GetParamNames ();
25 headers = policy.VaryByHeaders.GetHeaderNames ();
26 custom = policy.GetVaryByCustom ();
29 internal string CreateKey (string file_path, HttpContext context)
31 StringBuilder builder = new StringBuilder ();
32 HttpApplication app = context.ApplicationInstance;
33 HttpRequest request = context.Request;
35 builder.Append ("CachedRawResponse\n");
36 builder.Append (file_path);
37 builder.Append ('\n');
38 builder.Append ("METHOD:" + request.HttpMethod);
39 builder.Append ('\n');
42 for (int i=0; i<prms.Length; i++) {
43 if (request.Params [prms [i]] == null)
45 builder.Append ("VP:");
46 builder.Append (prms [i]);
48 builder.Append (request.Params [prms [i]]);
49 builder.Append ('\n');
53 if (headers != null) {
54 for (int i=0; i<headers.Length; i++) {
55 builder.Append ("VH:");
56 builder.Append (headers [i]);
58 builder.Append (request.Headers [headers [i]]);
59 builder.Append ('\n');
64 string s = app.GetVaryByCustomString (context, custom);
65 builder.Append ("VC:");
66 builder.Append (custom);
68 builder.Append (s != null ? s : "__null__");
69 builder.Append ('\n');
72 return builder.ToString ();