Author: gonzalo
Date: 2005-04-08 16:56:04 -0400 (Fri, 08 Apr 2005)
New Revision: 42706

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

        * HttpWebRequest.cs: moved redirection handling to a proper place.



Modified: trunk/mcs/class/System/System.Net/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.Net/ChangeLog 2005-04-08 20:30:04 UTC (rev 
42705)
+++ trunk/mcs/class/System/System.Net/ChangeLog 2005-04-08 20:56:04 UTC (rev 
42706)
@@ -1,3 +1,7 @@
+2005-04-08 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+       * HttpWebRequest.cs: moved redirection handling to a proper place.
+
 2005-04-07 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
 
        * WebHeaderCollection.cs: added if-modified-since to the list of

Modified: trunk/mcs/class/System/System.Net/HttpWebRequest.cs
===================================================================
--- trunk/mcs/class/System/System.Net/HttpWebRequest.cs 2005-04-08 20:30:04 UTC 
(rev 42705)
+++ trunk/mcs/class/System/System.Net/HttpWebRequest.cs 2005-04-08 20:56:04 UTC 
(rev 42706)
@@ -594,6 +594,7 @@
                                WebAsyncResult result = asyncWrite;
                                if (!requestSent) {
                                        requestSent = true;
+                                       redirects = 0;
                                        servicePoint = GetServicePoint ();
                                        abortHandler = servicePoint.SendRequest 
(this, connectionGroup);
                                }
@@ -662,6 +663,7 @@
                        
                        if (!requestSent) {
                                requestSent = true;
+                               redirects = 0;
                                servicePoint = GetServicePoint ();
                                abortHandler = servicePoint.SendRequest (this, 
connectionGroup);
                        }
@@ -679,25 +681,10 @@
                        if (result == null)
                                throw new ArgumentException ("Invalid 
IAsyncResult", "asyncResult");
 
-                       redirects = 0;
-                       bool redirected = false;
-                       asyncRead = result;
-                       do {
-                               if (redirected) {
-                                       haveResponse = false;
-                                       webResponse = null;
-                                       result.Reset ();
-                                       servicePoint = GetServicePoint ();
-                                       abortHandler = servicePoint.SendRequest 
(this, connectionGroup);
-                               }
-
-                               if (!result.WaitUntilComplete (timeout, false)) 
{
-                                       Abort ();
-                                       throw new WebException("The request 
timed out", WebExceptionStatus.Timeout);
-                               }
-
-                               redirected = CheckFinalStatus (result);
-                       } while (redirected);
+                       if (!result.WaitUntilComplete (timeout, false)) {
+                               Abort ();
+                               throw new WebException("The request timed out", 
WebExceptionStatus.Timeout);
+                       }
                        
                        return result.Response;
                }
@@ -1035,10 +1022,33 @@
                        if (r != null) {
                                if (wexc != null) {
                                        r.SetCompleted (false, wexc);
-                               } else {
-                                       r.SetCompleted (false, webResponse);
+                                       r.DoCallback ();
+                                       return;
                                }
-                               r.DoCallback ();
+
+                               bool redirected;
+                               try {
+                                       redirected = CheckFinalStatus (r);
+                                       if (!redirected) {
+                                               r.SetCompleted (false, 
webResponse);
+                                               r.DoCallback ();
+                                       } else {
+                                               haveResponse = false;
+                                               webResponse = null;
+                                               r.Reset ();
+                                               servicePoint = GetServicePoint 
();
+                                               abortHandler = 
servicePoint.SendRequest (this, connectionGroup);
+                                       }
+                               } catch (WebException wexc2) {
+                                       r.SetCompleted (false, wexc2);
+                                       r.DoCallback ();
+                                       return;
+                               } catch (Exception ex) {
+                                       wexc = new WebException (ex.Message, 
ex, WebExceptionStatus.ProtocolError, null); 
+                                       r.SetCompleted (false, wexc);
+                                       r.DoCallback ();
+                                       return;
+                               }
                        }
                }
 

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

Reply via email to