2004-04-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Sat, 24 Apr 2004 01:23:49 +0000 (01:23 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Sat, 24 Apr 2004 01:23:49 +0000 (01:23 -0000)
* WebConnectionStream.cs: avoid the exception when getting the content
length if possible.

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

mcs/class/System/System.Net/ChangeLog
mcs/class/System/System.Net/WebConnectionStream.cs

index 168876b1e898320f92dfc03905d07707f8eba67a..f1779d17761132726a3c0c07de21194da5490dc0 100644 (file)
@@ -1,11 +1,16 @@
+2004-04-24  Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * WebConnectionStream.cs: avoid the exception when getting the content
+       length if possible.
+
 2004-03-29  Lluis Sanchez Gual <lluis@ximian.com>
 
        * HttpWebRequest.cs: Use a lock block instead of Monitor.Enter/Exit, so
        the lock is released in case of exception (for example, a 
        ThreadAbortException). This also "fixes" bug #52417.
        Beware, this requires a runtime update (due to a bug in Monitor.Exit).
-       * ServicePoint.cs: Changed method from internal to private, since it is not
-       called from outside the class.
+       * ServicePoint.cs: Changed method from internal to private, since it
+       is not called from outside the class.
 
 2004-03-24  Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
index abd9c73cc4c715df59a5462a6574e3c3f605ff39..2f03dad0c4146a3bcc79a99503c4519b67c60c6d 100644 (file)
@@ -42,9 +42,14 @@ namespace System.Net
                        isRead = true;
                        pending = new ManualResetEvent (true);
                        this.cnc = cnc;
-                       try {
-                               contentLength = Int32.Parse (cnc.Data.Headers ["Content-Length"]);
-                       } catch {
+                       string clength = cnc.Data.Headers ["Content-Length"];
+                       if (clength != null && clength != "") {
+                               try {
+                                       contentLength = Int32.Parse (clength);
+                               } catch {
+                                       contentLength = Int32.MaxValue;
+                               }
+                       } else {
                                contentLength = Int32.MaxValue;
                        }
                }