Author: gonzalo
Date: 2005-04-10 02:00:03 -0400 (Sun, 10 Apr 2005)
New Revision: 42751

Modified:
   trunk/mcs/class/System/System.Net/ChangeLog
   trunk/mcs/class/System/System.Net/HttpWebRequest.cs
   trunk/mcs/class/System/System.Net/WebConnectionStream.cs
Log:
2005-04-10 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>

        * HttpWebRequest.cs: 
        * WebConnectionStream.cs: implemented support for ReadWriteTimeout.



Modified: trunk/mcs/class/System/System.Net/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.Net/ChangeLog 2005-04-10 05:08:55 UTC (rev 
42750)
+++ trunk/mcs/class/System/System.Net/ChangeLog 2005-04-10 06:00:03 UTC (rev 
42751)
@@ -1,5 +1,10 @@
 2005-04-10 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
 
+       * HttpWebRequest.cs: 
+       * WebConnectionStream.cs: implemented support for ReadWriteTimeout.
+
+2005-04-10 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
        * WebConnection.cs: if we're reading chunked data and didn't use the
        stream to read, we gotta set the async. result as complete and invoke
        the callback. Don't call nstream.EndRead with the wrong IAsyncResult.

Modified: trunk/mcs/class/System/System.Net/HttpWebRequest.cs
===================================================================
--- trunk/mcs/class/System/System.Net/HttpWebRequest.cs 2005-04-10 05:08:55 UTC 
(rev 42750)
+++ trunk/mcs/class/System/System.Net/HttpWebRequest.cs 2005-04-10 06:00:03 UTC 
(rev 42751)
@@ -93,7 +93,7 @@
 #if NET_1_1
                int maxResponseHeadersLength;
                static int defaultMaxResponseHeadersLength;
-               int readWriteTimeout;
+               int readWriteTimeout = 300000; // ms
                
                // Constructors
                static HttpWebRequest ()
@@ -339,12 +339,22 @@
                        set { defaultMaxResponseHeadersLength = value; }
                }
 
-               [MonoTODO ("Use this")]
-               public int ReadWriteTimeout {
+               public
+#else
+               internal
+#endif
+               int ReadWriteTimeout {
                        get { return readWriteTimeout; }
-                       set { readWriteTimeout = value; }
+                       set {
+                               if (requestSent)
+                                       throw new InvalidOperationException 
("The request has already been sent.");
+
+                               if (value < -1)
+                                       throw new ArgumentOutOfRangeException 
("value", "Must be >= -1");
+
+                               readWriteTimeout = value;
+                       }
                }
-#endif
                
                public string MediaType {
                        get { return mediaType; }

Modified: trunk/mcs/class/System/System.Net/WebConnectionStream.cs
===================================================================
--- trunk/mcs/class/System/System.Net/WebConnectionStream.cs    2005-04-10 
05:08:55 UTC (rev 42750)
+++ trunk/mcs/class/System/System.Net/WebConnectionStream.cs    2005-04-10 
06:00:03 UTC (rev 42751)
@@ -63,6 +63,7 @@
                {
                        isRead = true;
                        pending = new ManualResetEvent (true);
+                       this.request = cnc.Data.request;
                        this.cnc = cnc;
                        string clength = cnc.Data.Headers ["Content-Length"];
                        if (clength != null && clength != "") {
@@ -211,7 +212,12 @@
                        if (totalRead >= contentLength)
                                return 0;
 
-                       IAsyncResult res = BeginRead (buffer, offset, size, 
null, null);
+                       WebAsyncResult res = (WebAsyncResult) BeginRead 
(buffer, offset, size, null, null);
+                       if (!res.WaitUntilComplete (request.ReadWriteTimeout, 
false)) {
+                               cnc.Close (true);
+                               throw new IOException ("Read timed out.");
+                       }
+
                        return EndRead (res);
                }
 
@@ -378,7 +384,12 @@
                        if (isRead)
                                throw new NotSupportedException ("This stream 
does not allow writing");
 
-                       IAsyncResult res = BeginWrite (buffer, offset, size, 
null, null);
+                       WebAsyncResult res = (WebAsyncResult) BeginWrite 
(buffer, offset, size, null, null);
+                       if (!res.WaitUntilComplete (request.ReadWriteTimeout, 
false)) {
+                               cnc.Close (true);
+                               throw new IOException ("Write timed out.");
+                       }
+
                        EndWrite (res);
                }
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to