Author: gonzalo
Date: 2005-04-10 16:57:45 -0400 (Sun, 10 Apr 2005)
New Revision: 42768

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

        * WebConnection.cs: fix some breakage from my last patch.
        * WebConnectionStream.cs: invoke the callback when done even in EndRead.



Modified: trunk/mcs/class/System/System.Net/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.Net/ChangeLog 2005-04-10 20:49:04 UTC (rev 
42767)
+++ trunk/mcs/class/System/System.Net/ChangeLog 2005-04-10 20:57:45 UTC (rev 
42768)
@@ -1,3 +1,8 @@
+2005-04-10 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+       * WebConnection.cs: fix some breakage from my last patch.
+       * WebConnectionStream.cs: invoke the callback when done even in EndRead.
+
 2005-04-10  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
        * WebConnection.cs: Added support for TrustFailure when throwing a

Modified: trunk/mcs/class/System/System.Net/WebConnection.cs
===================================================================
--- trunk/mcs/class/System/System.Net/WebConnection.cs  2005-04-10 20:49:04 UTC 
(rev 42767)
+++ trunk/mcs/class/System/System.Net/WebConnection.cs  2005-04-10 20:57:45 UTC 
(rev 42768)
@@ -672,13 +672,20 @@
                        if (nstream == null)
                                return 0;
 
-                       if (chunkedRead) {
-                               WebAsyncResult wr = (WebAsyncResult) result;
+                       int nbytes = 0;
+                       WebAsyncResult wr = null;
+                       IAsyncResult nsAsync = ((WebAsyncResult) 
result).InnerAsyncResult;
+                       if (chunkedRead && (nsAsync is WebAsyncResult)) {
+                               wr = (WebAsyncResult) nsAsync;
                                IAsyncResult inner = wr.InnerAsyncResult;
-                               int nbytes = 0;
                                if (inner != null && !(inner is WebAsyncResult))
                                        nbytes = nstream.EndRead (inner);
+                       } else {
+                               nbytes = nstream.EndRead (nsAsync);
+                               wr = (WebAsyncResult) result;
+                       }
 
+                       if (chunkedRead) {
                                bool done = (nbytes == 0);
                                try {
                                        chunkStream.WriteAndReadBack 
(wr.Buffer, wr.Offset, wr.Size, ref nbytes);
@@ -696,11 +703,9 @@
                                        HandleError 
(WebExceptionStatus.ReceiveFailure, null, "chunked EndRead");
                                        throw new WebException ("Read error", 
null, WebExceptionStatus.ReceiveFailure, null);
                                }
-
-                               return (nbytes != 0) ? nbytes : -1;
                        }
 
-                       return nstream.EndRead (result);
+                       return (nbytes != 0) ? nbytes : -1;
                }
 
                // To be called on chunkedRead when we can read no data from 
the ChunkStream yet

Modified: trunk/mcs/class/System/System.Net/WebConnectionStream.cs
===================================================================
--- trunk/mcs/class/System/System.Net/WebConnectionStream.cs    2005-04-10 
20:49:04 UTC (rev 42767)
+++ trunk/mcs/class/System/System.Net/WebConnectionStream.cs    2005-04-10 
20:57:45 UTC (rev 42768)
@@ -283,6 +283,7 @@
                                        nbytes = 0;
 
                                result.SetCompleted (false, nbytes + 
result.NBytes);
+                               result.DoCallback ();
                                totalRead += nbytes;
                                if (finished || nbytes == 0)
                                        contentLength = totalRead;

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

Reply via email to