Przeglądaj źródła

* MonoHttpDate.cs: added
* HttpWebRequest.cs: using MonoHttpDate
* HttpWebResponse.cs: using MonoHttpDate
* DnsPermission.cs: correct XML output
* SocketPermission.cs: correct XML output

svn path=/trunk/mcs/; revision=4990

Lawrence Pit 23 lat temu
rodzic
commit
ff8a89dcca

+ 8 - 0
mcs/class/System/System.Net/ChangeLog

@@ -1,3 +1,11 @@
+2002-05-29  Lawrence Pit <[email protected]>
+
+	* MonoHttpDate.cs: added
+	* HttpWebRequest.cs: using MonoHttpDate
+	* HttpWebResponse.cs: using MonoHttpDate
+	* DnsPermission.cs: correct XML output
+	* SocketPermission.cs: correct XML output
+
 2002-05-21  Lawrence Pit <[email protected]>
 
 	* WebClient.cs: stubbed

+ 1 - 11
mcs/class/System/System.Net/DnsPermission.cs

@@ -92,17 +92,7 @@ namespace System.Net
 		{
              
 			SecurityElement root = new SecurityElement ("IPermission");
-
-			root.AddAttribute ("class", this.GetType ().FullName + ", " + 
-			                            "System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
-
-/*			
-GetType ().Module doesn't work yet with Mono.. (2002-05-01)
-We need to do it as below though, because this class can be extended
-
-			root.AddAttribute ("class", this.GetType ().FullName + ", " + 
-			                            this.GetType ().Module.Assembly.FullName);
-*/			                            
+			root.AddAttribute ("class", this.GetType ().AssemblyQualifiedName);
 			root.AddAttribute ("version", "1");
 			if (m_noRestriction)
 				root.AddAttribute ("Unrestricted", "true");				

+ 1 - 6
mcs/class/System/System.Net/HttpWebRequest.cs

@@ -199,13 +199,8 @@ namespace System.Net
 				string str = webHeaders ["If-Modified-Since"];
 				if (str == null)
 					return DateTime.Now;
-					
-				// TODO:
-				// HTTP-date    = rfc1123-date | rfc850-date | asctime-date
-				// for now, assume rfc1123 only
 				try {
-					DateTime dt = DateTime.ParseExact (str, "r", null);
-					return dt;
+					return MonoHttpDate.Parse (str);
 				} catch (Exception) {
 					return DateTime.Now;
 				}

+ 1 - 3
mcs/class/System/System.Net/HttpWebResponse.cs

@@ -128,9 +128,7 @@ namespace System.Net
 				CheckDisposed ();
 				try {
 					string dtStr = webHeaders ["Last-Modified"];
-					// TODO: accept more than rfc1123 dates
-					DateTime dt = DateTime.ParseExact (dtStr, "r", null);
-					return dt;
+					return MonoHttpDate.Parse (dtStr);
 				} catch (Exception) {
 					return DateTime.Now;	
 				}

+ 33 - 0
mcs/class/System/System.Net/MonoHttpDate.cs

@@ -0,0 +1,33 @@
+//
+// System.Net.MonoHttpDate
+//
+// Author:
+//   Lawrence Pit ([email protected])
+//
+
+using System;
+using System.Globalization;
+
+namespace System.Net 
+{
+	/// <summary>
+	/// See RFC 2068 3.3.1
+	/// </summary>
+	internal class MonoHttpDate
+	{
+		private static readonly string rfc1123_date = "r";
+		private static readonly string rfc850_date = "dddd, dd-MMM-yy HH:mm:ss G\\MT";
+		private static readonly string asctime_date = "ddd MMM d HH:mm:ss yyyy";
+		private static readonly string [] formats = 
+			new string [] {rfc1123_date, rfc850_date, asctime_date};
+		private static readonly CultureInfo enUS = new CultureInfo("en-US", false);
+		
+		internal static DateTime Parse (string dateStr)
+		{			
+			 return DateTime.ParseExact (dateStr, 
+			                             formats, 
+			                             enUS, 
+			                             DateTimeStyles.AllowWhiteSpaces);
+		}
+	}
+}

+ 1 - 10
mcs/class/System/System.Net/SocketPermission.cs

@@ -224,16 +224,7 @@ namespace System.Net
              
 			SecurityElement root = new SecurityElement ("IPermission");
 
-			root.AddAttribute ("class", this.GetType ().FullName + ", " + 
-			                            "System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
-
-/*			
-GetType ().Module doesn't work yet with Mono.. (2002-04-27)
-We need to do it as below though, because this class can be extended
-
-			root.AddAttribute ("class", this.GetType ().FullName + ", " + 
-			                            this.GetType ().Module.Assembly.FullName);
-*/			                            
+			root.AddAttribute ("class", this.GetType ().AssemblyQualifiedName);
 			root.AddAttribute ("version", "1");
 			if (m_noRestriction) {
 				root.AddAttribute ("Unrestricted", "true");