[System] Suppress a few instances of CS0618 obsolete warnings
[mono.git] / mcs / class / System / System.Net / HttpWebRequest.cs
index 97233f4f488ad6cf0340fcfbb15a4c0d96f8c3d6..d05722051f93453ff405de19e8c76bf99fa2d380 100644 (file)
@@ -112,8 +112,8 @@ namespace System.Net
                int maxResponseHeadersLength;
                static int defaultMaxResponseHeadersLength;
                int readWriteTimeout = 300000; // ms
-               IMonoTlsProvider tlsProvider;
 #if SECURITY_DEP
+               MonoTlsProvider tlsProvider;
                MonoTlsSettings tlsSettings;
 #endif
                ServerCertValidationCallback certValidationCallback;
@@ -133,8 +133,10 @@ namespace System.Net
                static HttpWebRequest ()
                {
                        defaultMaxResponseHeadersLength = 64 * 1024;
-#if !NET_2_1
+#if !MOBILE
+#pragma warning disable 618
                        NetConfig config = ConfigurationSettings.GetConfig ("system.net/settings") as NetConfig;
+#pragma warning restore 618
                        if (config != null) {
                                int x = config.MaxResponseHeadersLength;
                                if (x != -1)
@@ -145,7 +147,7 @@ namespace System.Net
 #endif
                }
 
-#if NET_2_1
+#if MOBILE
                public
 #else
                internal
@@ -154,14 +156,14 @@ namespace System.Net
                {
                        this.requestUri = uri;
                        this.actualUri = uri;
-                       this.proxy = GlobalProxySelection.Select;
+                       this.proxy = InternalDefaultWebProxy;
                        this.webHeaders = new WebHeaderCollection (WebHeaderCollectionType.HttpWebRequest);
                        ThrowOnError = true;
                        ResetAuthorization ();
                }
 
 #if SECURITY_DEP
-               internal HttpWebRequest (Uri uri, IMonoTlsProvider tlsProvider, MonoTlsSettings settings = null)
+               internal HttpWebRequest (Uri uri, MonoTlsProvider tlsProvider, MonoTlsSettings settings = null)
                        : this (uri)
                {
                        this.tlsProvider = tlsProvider;
@@ -226,12 +228,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; }
                }
@@ -274,16 +276,16 @@ namespace System.Net
                        }
                }
 
-               internal IMonoTlsProvider TlsProvider {
+#if SECURITY_DEP
+               internal MonoTlsProvider TlsProvider {
                        get { return tlsProvider; }
                }
 
-#if SECURITY_DEP
                internal MonoTlsSettings TlsSettings {
                        get { return tlsSettings; }
                }
 #endif
-               
+
                public X509CertificateCollection ClientCertificates {
                        get {
                                if (certificates == null)
@@ -382,7 +384,7 @@ namespace System.Net
                                SetSpecialHeaders(headerName, HttpProtocolUtils.date2string(dateTime));
                }
 
-#if !NET_2_1
+#if !MOBILE
                [MonoTODO]
                public static new RequestCachePolicy DefaultCachePolicy
                {
@@ -450,7 +452,7 @@ namespace System.Net
                                        newWebHeaders.Add(headerName,webHeaders[headerName]);
                                }
 
-                               webHeaders = newWebHeaders;
+                               this.webHeaders = newWebHeaders;
                        }
                }
                
@@ -918,6 +920,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 +971,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);
@@ -1025,9 +1033,9 @@ namespace System.Net
                        return result.Response;
                }
                
-               public Stream EndGetRequestStream (IAsyncResult asyncResult, out TransportContext transportContext)
+               public Stream EndGetRequestStream (IAsyncResult asyncResult, out TransportContext context)
                {
-                       transportContext = null;
+                       context = null;
                        return EndGetRequestStream (asyncResult);
                }
 
@@ -1314,8 +1322,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 +1385,7 @@ namespace System.Net
                                        }
 
                                        if (asyncWrite != null) {
-                                               asyncWrite.SetCompleted (inner.CompletedSynchronously, writeStream);
+                                               asyncWrite.SetCompleted (inner.CompletedSynchronouslyPeek, writeStream);
                                                asyncWrite.DoCallback ();
                                                asyncWrite = null;
                                        }
@@ -1474,7 +1485,7 @@ namespace System.Net
                        if (wce != null) {
                                WebConnection cnc = wce.Connection;
                                cnc.PriorityRequest = this;
-                               ICredentials creds = !isProxy ? credentials : proxy.Credentials;
+                               ICredentials creds = (!isProxy || proxy == null) ? credentials : proxy.Credentials;
                                if (creds != null) {
                                        cnc.NtlmCredential = creds.GetCredential (requestUri, "NTLM");
                                        cnc.UnsafeAuthenticatedConnectionSharing = unsafe_auth_blah;
@@ -1531,7 +1542,7 @@ namespace System.Net
                                        return;
                                }
 
-                               bool isProxy = ProxyQuery && !proxy.IsBypassed (actualUri);
+                               bool isProxy = ProxyQuery && proxy != null && !proxy.IsBypassed (actualUri);
 
                                bool redirected;
                                try {
@@ -1793,6 +1804,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
        }
 }