Merge pull request #3656 from marek-safar/bootstrap
[mono.git] / mcs / class / System.Net.Http / System.Net.Http / HttpRequestMessage.cs
index 0bf3fba28abd6b381b465e039d404fcbcf48d3d9..0823365d74476ff243a965f357fc77203697beae 100644 (file)
@@ -89,13 +89,25 @@ namespace System.Net.Http
                                return uri;
                        }
                        set {
-                               if (value != null && (value.IsAbsoluteUri && value.Scheme != Uri.UriSchemeHttp && value.Scheme != Uri.UriSchemeHttps))
+                               if (value != null && value.IsAbsoluteUri && !IsAllowedAbsoluteUri (value))
                                        throw new ArgumentException ("Only http or https scheme is allowed");
 
                                uri = value;
                        }
                }
 
+               static bool IsAllowedAbsoluteUri (Uri uri)
+               {
+                       if (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)
+                               return true;
+
+                       // Mono URI handling which does not distinguish between file and url absolute paths without scheme
+                       if (uri.Scheme == Uri.UriSchemeFile && uri.OriginalString.StartsWith ("/", StringComparison.Ordinal))
+                               return true;
+
+                       return false;
+               }
+
                public Version Version {
                        get {
                                return version ?? HttpVersion.Version11;