Author: gonzalo
Date: 2005-04-21 22:34:23 -0400 (Thu, 21 Apr 2005)
New Revision: 43424
Modified:
trunk/mcs/class/System.Web/System.Web/ChangeLog
trunk/mcs/class/System.Web/System.Web/HttpResponse.cs
Log:
2005-04-21 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* HttpResponse.cs: only add the charset when explicitly set or for
well-known content types.
Modified: trunk/mcs/class/System.Web/System.Web/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web/ChangeLog 2005-04-22 02:03:47 UTC
(rev 43423)
+++ trunk/mcs/class/System.Web/System.Web/ChangeLog 2005-04-22 02:34:23 UTC
(rev 43424)
@@ -1,3 +1,8 @@
+2005-04-21 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+ * HttpResponse.cs: only add the charset when explicitly set or for
+ well-known content types.
+
2005-04-20 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* HttpCachePolicy.cs:
Modified: trunk/mcs/class/System.Web/System.Web/HttpResponse.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web/HttpResponse.cs 2005-04-22
02:03:47 UTC (rev 43423)
+++ trunk/mcs/class/System.Web/System.Web/HttpResponse.cs 2005-04-22
02:34:23 UTC (rev 43424)
@@ -73,6 +73,7 @@
string _sTransferEncoding;
string _sCharset;
string _sStatusDescription;
+ bool forced_charset;
HttpCookieCollection _Cookies;
HttpCachePolicy _CachePolicy;
@@ -204,20 +205,21 @@
_lContentLength.ToString ()));
}
+ // Apache2 only auto-adds 'charset=blah' for text/plain
and text/html
if (_sContentType != null) {
- if (_sContentType.IndexOf ("charset=") == -1) {
- if (Charset.Length == 0) {
- Charset =
ContentEncoding.HeaderName;
- }
+ string ctype = _sContentType;
+ if (forced_charset || _sContentType ==
"text/plain" || _sContentType == "text/html") {
+ if (_sContentType.IndexOf ("charset=")
== -1) {
+ if (Charset.Length == 0)
+ Charset =
ContentEncoding.HeaderName;
- // Time to build our string
- if (Charset.Length > 0) {
- _sContentType += "; charset=" +
Charset;
+ // Time to build our string
+ if (Charset.Length > 0)
+ ctype += "; charset=" +
Charset;
}
}
- oHeaders.Add (new HttpResponseHeader
(HttpWorkerRequest.HeaderContentType,
-
_sContentType));
+ oHeaders.Add (new HttpResponseHeader
(HttpWorkerRequest.HeaderContentType, ctype));
}
if (_CachePolicy != null)
@@ -448,6 +450,10 @@
if (_bHeadersSent)
throw new HttpException ("Headers has
been sent to the client");
+ if (value == null)
+ value = "";
+
+ forced_charset = true;
_sCharset = value;
}
}
@@ -728,6 +734,7 @@
throw new HttpException ("Headers has been sent
to the client");
_sContentType = "text/html";
+ forced_charset = false;
_iStatusCode = 200;
_sCharset = null;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches