CachedRawResponse cached_response;
string user_cache_control = "private";
string redirect_location;
-
- static string version_header;
+ string version_header;
+ bool version_header_checked;
//
// Negative Content-Length means we auto-compute the size of content-length
Encoding headerEncoding;
#endif
- static HttpResponse ()
- {
-#if NET_2_0
- HttpRuntimeSection config = WebConfigurationManager.GetWebApplicationSection ("system.web/httpRuntime") as HttpRuntimeSection;
-#else
- HttpRuntimeConfig config = HttpContext.GetAppConfig ("system.web/httpRuntime") as HttpRuntimeConfig;
-#endif
- if (config != null && config.EnableVersionHeader)
- version_header = Environment.Version.ToString (3);
- }
-
internal HttpResponse ()
{
output_stream = new HttpResponseStream (this);
return prev;
}
+ internal string VersionHeader {
+ get {
+ if (!version_header_checked && version_header == null) {
+ version_header_checked = true;
+#if NET_2_0
+ HttpRuntimeSection config = WebConfigurationManager.GetWebApplicationSection ("system.web/httpRuntime") as HttpRuntimeSection;
+#else
+ HttpRuntimeConfig config = HttpContext.GetAppConfig ("system.web/httpRuntime") as HttpRuntimeConfig;
+#endif
+ if (config != null && config.EnableVersionHeader)
+ version_header = Environment.Version.ToString (3);
+ }
+
+ return version_header;
+ }
+ }
+
internal string[] FileDependencies {
get {
if (fileDependencies == null || fileDependencies.Count == 0)
content_length = -1;
content_type = "text/html";
transfer_encoding = null;
- user_cache_control = null;
+ user_cache_control = "private";
+ if (cache_policy != null)
+ cache_policy.Cacheability = HttpCacheability.Private;
+
if (headers != null)
headers.Clear ();
}
write_headers.Add ("Location", redirect_location);
#if !TARGET_J2EE
- if (version_header != null)
- write_headers.Add ("X-AspNet-Version", version_header);
+ string vh = VersionHeader;
+ if (vh != null)
+ write_headers.Add ("X-AspNet-Version", vh);
//
// If Content-Length is set.
if (WorkerRequest != null) {
string header_name;
string[] values;
+ int header_index;
for (int i = 0; i < write_headers.Count; i++) {
header_name = write_headers.GetKey (i);
+ header_index = HttpWorkerRequest.GetKnownResponseHeaderIndex (header_name);
values = write_headers.GetValues (i);
if (values == null)
continue;
- foreach (string val in values)
- WorkerRequest.SendUnknownResponseHeader (header_name, val);
+ foreach (string val in values) {
+ if (header_index > -1)
+ WorkerRequest.SendKnownResponseHeader (header_index, val);
+ else
+ WorkerRequest.SendUnknownResponseHeader (header_name, val);
+ }
}
}
}