Merge pull request #4433 from kumpera/android-fixes
[mono.git] / mcs / class / System / System.Net / HttpWebRequest.cs
index a151f6bb870e2ed992fa5b5639864d82835979ec..a57c579250ed33e6f27cb11ad04469840f3a06b3 100644 (file)
@@ -133,7 +133,7 @@ namespace System.Net
                static HttpWebRequest ()
                {
                        defaultMaxResponseHeadersLength = 64 * 1024;
-#if !NET_2_1
+#if !MOBILE
                        NetConfig config = ConfigurationSettings.GetConfig ("system.net/settings") as NetConfig;
                        if (config != null) {
                                int x = config.MaxResponseHeadersLength;
@@ -145,7 +145,7 @@ namespace System.Net
 #endif
                }
 
-#if NET_2_1
+#if MOBILE
                public
 #else
                internal
@@ -226,12 +226,12 @@ namespace System.Net
                        internal set { actualUri = value; } // Used by Ftp+proxy
                }
                
-               public bool AllowAutoRedirect {
+               public virtual bool AllowAutoRedirect {
                        get { return allowAutoRedirect; }
                        set { this.allowAutoRedirect = value; }
                }
                
-               public bool AllowWriteStreamBuffering {
+               public virtual bool AllowWriteStreamBuffering {
                        get { return allowBuffering; }
                        set { allowBuffering = value; }
                }
@@ -382,7 +382,7 @@ namespace System.Net
                                SetSpecialHeaders(headerName, HttpProtocolUtils.date2string(dateTime));
                }
 
-#if !NET_2_1
+#if !MOBILE
                [MonoTODO]
                public static new RequestCachePolicy DefaultCachePolicy
                {
@@ -450,7 +450,7 @@ namespace System.Net
                                        newWebHeaders.Add(headerName,webHeaders[headerName]);
                                }
 
-                               webHeaders = newWebHeaders;
+                               this.webHeaders = newWebHeaders;
                        }
                }
                
@@ -918,6 +918,12 @@ namespace System.Net
                        return EndGetRequestStream (asyncResult);
                }
 
+               [MonoTODO]
+               public Stream GetRequestStream (out TransportContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
                bool CheckIfForceWrite (SimpleAsyncResult result)
                {
                        if (writeStream == null || writeStream.RequestWritten || !InternalAllowBuffering)
@@ -963,7 +969,7 @@ namespace System.Net
                        initialMethod = method;
 
                        SimpleAsyncResult.RunWithLock (locker, CheckIfForceWrite, inner => {
-                               var synch = inner.CompletedSynchronously;
+                               var synch = inner.CompletedSynchronouslyPeek;
 
                                if (inner.GotException) {
                                        aread.SetCompleted (synch, inner.Exception);
@@ -1314,8 +1320,11 @@ namespace System.Net
                                        msg = "Error: " + status;
                                        wex = new WebException (msg, status);
                                } else {
-                                       msg = String.Format ("Error: {0} ({1})", status, exc.Message);
-                                       wex = new WebException (msg, status, WebExceptionInternalStatus.RequestFatal, exc);
+                                       wex = exc as WebException;
+                                       if (wex == null) {
+                                               msg = String.Format ("Error: {0} ({1})", status, exc.Message);
+                                               wex = new WebException (msg, status, WebExceptionInternalStatus.RequestFatal, exc);
+                                       }
                                }
                                r.SetCompleted (false, wex);
                                r.DoCallback ();
@@ -1374,7 +1383,7 @@ namespace System.Net
                                        }
 
                                        if (asyncWrite != null) {
-                                               asyncWrite.SetCompleted (inner.CompletedSynchronously, writeStream);
+                                               asyncWrite.SetCompleted (inner.CompletedSynchronouslyPeek, writeStream);
                                                asyncWrite.DoCallback ();
                                                asyncWrite = null;
                                        }
@@ -1793,6 +1802,22 @@ namespace System.Net
                }
 
                internal WebConnection StoredConnection;
+
+#region referencesource
+        internal static StringBuilder GenerateConnectionGroup(string connectionGroupName, bool unsafeConnectionGroup, bool isInternalGroup)
+        {
+            StringBuilder connectionLine = new StringBuilder(connectionGroupName);
+
+            connectionLine.Append(unsafeConnectionGroup ? "U>" : "S>");
+
+            if (isInternalGroup)
+            {
+                connectionLine.Append("I>");
+            }
+
+            return connectionLine;
+        }
+#endregion
        }
 }