Author: gonzalo
Date: 2005-04-11 12:47:54 -0400 (Mon, 11 Apr 2005)
New Revision: 42792

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-11 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>

        * WebConnection.cs:
        * WebConnectionStream.cs: don't start reading until we've sent at least
        the headers. This way we ensure that a Write happens before any Read,
        which is needed by the SSL code.



Modified: trunk/mcs/class/System/System.Net/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.Net/ChangeLog 2005-04-11 14:56:29 UTC (rev 
42791)
+++ trunk/mcs/class/System/System.Net/ChangeLog 2005-04-11 16:47:54 UTC (rev 
42792)
@@ -1,5 +1,12 @@
 2005-04-11 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
 
+       * WebConnection.cs:
+       * WebConnectionStream.cs: don't start reading until we've sent at least
+       the headers. This way we ensure that a Write happens before any Read,
+       which is needed by the SSL code.
+
+2005-04-11 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
        * HttpWebRequest.cs: ensure we read everything before redirecting.
 
 2005-04-11 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>

Modified: trunk/mcs/class/System/System.Net/WebConnection.cs
===================================================================
--- trunk/mcs/class/System/System.Net/WebConnection.cs  2005-04-11 14:56:29 UTC 
(rev 42791)
+++ trunk/mcs/class/System/System.Net/WebConnection.cs  2005-04-11 16:47:54 UTC 
(rev 42792)
@@ -396,7 +396,7 @@
                        certsAvailable = (server != null);
                }
                
-               static void InitRead (object state)
+               internal static void InitRead (object state)
                {
                        WebConnection cnc = (WebConnection) state;
                        Stream ns = cnc.nstream;
@@ -541,7 +541,6 @@
 
                        readState = ReadState.None;
                        request.SetWriteStream (new WebConnectionStream (this, 
request));
-                       InitRead (this);
                }
                
                internal EventHandler SendRequest (HttpWebRequest request)

Modified: trunk/mcs/class/System/System.Net/WebConnectionStream.cs
===================================================================
--- trunk/mcs/class/System/System.Net/WebConnectionStream.cs    2005-04-11 
14:56:29 UTC (rev 42791)
+++ trunk/mcs/class/System/System.Net/WebConnectionStream.cs    2005-04-11 
16:47:54 UTC (rev 42792)
@@ -58,6 +58,7 @@
                bool disposed;
                bool headersSent;
                object locker = new object ();
+               bool initRead;
 
                public WebConnectionStream (WebConnection cnc)
                {
@@ -429,6 +430,10 @@
                                        throw new WebException ("Not 
connected", null, WebExceptionStatus.SendFailure, null);
 
                                cnc.Write (buffer, offset, size);
+                               if (!initRead) {
+                                       initRead = true;
+                                       WebConnection.InitRead (cnc);
+                               }
                        } else {
                                headers = new byte [size];
                                Buffer.BlockCopy (buffer, offset, headers, 0, 
size);
@@ -496,9 +501,15 @@
                                                cnc.Close (true);
                                }
                                return;
+                       } else if (!allowBuffering) {
+                               if (!initRead) {
+                                       initRead = true;
+                                       WebConnection.InitRead (cnc);
+                               }
+                               return;
                        }
 
-                       if (!allowBuffering || disposed)
+                       if (disposed)
                                return;
 
                        disposed = true;
@@ -508,6 +519,10 @@
                                throw new IOException ("Cannot close the stream 
until all bytes are written");
 
                        WriteRequest ();
+                       if (!initRead) {
+                               initRead = true;
+                               WebConnection.InitRead (cnc);
+                       }
                }
 
                public override long Seek (long a, SeekOrigin b)

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

Reply via email to