Merge pull request #2020 from tomjepp/master
[mono.git] / mcs / class / System / System.Net / WebRequest.cs
index eeed685db3af763ec2a84aa1f0b8ec177c79d5b2..efb06fe9aa82385b6a9df86d0c63fb8c121111b2 100644 (file)
@@ -39,9 +39,7 @@ using System.Net.Configuration;
 using System.Net.Security;
 using System.Net.Cache;
 using System.Security.Principal;
-#if NET_4_5
 using System.Threading.Tasks;
-#endif
 
 #if NET_2_1
 using ConfigurationException = System.ArgumentException;
@@ -211,6 +209,13 @@ namespace System.Net
                                isDefaultWebProxySet = true;
                        }
                }
+
+               internal static IWebProxy InternalDefaultWebProxy {
+                       get {
+                               return DefaultWebProxy;
+                       }
+               }
+
                
                [MonoTODO("Needs to respect Module, Proxy.AutoDetect, and Proxy.ScriptLocation config settings")]
                static IWebProxy GetDefaultWebProxy ()
@@ -286,19 +291,27 @@ namespace System.Net
                                throw new ArgumentNullException ("requestUri");
                        return GetCreator (requestUri.Scheme).Create (requestUri);
                }
-#if NET_4_0
-               [MonoTODO ("for portable library support")]
+               static HttpWebRequest SharedCreateHttp (Uri uri)
+               {
+                       if (uri.Scheme != "http" && uri.Scheme != "https")
+                               throw new NotSupportedException ("The uri should start with http or https");
+
+                       return new HttpWebRequest (uri);
+               }
+
                public static HttpWebRequest CreateHttp (string requestUriString)
                {
-                       throw new NotImplementedException ();
+                       if (requestUriString == null)
+                               throw new ArgumentNullException ("requestUriString");
+                       return SharedCreateHttp (new Uri (requestUriString));
                }
                        
-               [MonoTODO ("for portable library support")]
                public static HttpWebRequest CreateHttp (Uri requestUri)
                {
-                       throw new NotImplementedException ();
+                       if (requestUri == null)
+                               throw new ArgumentNullException ("requestUri");
+                       return SharedCreateHttp (requestUri);
                }
-#endif
                public virtual Stream EndGetRequestStream (IAsyncResult asyncResult)
                {
                        throw GetMustImplement ();
@@ -506,7 +519,6 @@ namespace System.Net
                        prefixes [prefix] = o;
                }
 
-#if NET_4_5
                public virtual Task<Stream> GetRequestStreamAsync ()
                {
                        return Task<Stream>.Factory.FromAsync (BeginGetRequestStream, EndGetRequestStream, null);
@@ -516,7 +528,6 @@ namespace System.Net
                {
                        return Task<WebResponse>.Factory.FromAsync (BeginGetResponse, EndGetResponse, null);
                }
-#endif
 
        }
 }