From 0b7afa989dafd4d712d5a94044fd98ecc40f2ecc Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Wed, 25 Feb 2015 12:28:47 +0100 Subject: [PATCH] [system.net.http] Add another workaround for incompatible mono Uri handling. Fixes #27386 --- mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs | 7 ++++--- .../System.Net.Http/Test/System.Net.Http/HttpClientTest.cs | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs b/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs index fc17d4cc95b..114e78e83c2 100644 --- a/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs +++ b/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs @@ -242,16 +242,17 @@ namespace System.Net.Http if (request.SetIsUsed ()) throw new InvalidOperationException ("Cannot send the same request message multiple times"); - if (request.RequestUri == null) { + var uri = request.RequestUri; + if (uri == null) { if (base_address == null) throw new InvalidOperationException ("The request URI must either be an absolute URI or BaseAddress must be set"); request.RequestUri = base_address; - } else if (!request.RequestUri.IsAbsoluteUri) { + } else if (!uri.IsAbsoluteUri || uri.Scheme == Uri.UriSchemeFile && uri.OriginalString.StartsWith ("/", StringComparison.Ordinal)) { if (base_address == null) throw new InvalidOperationException ("The request URI must either be an absolute URI or BaseAddress must be set"); - request.RequestUri = new Uri (base_address, request.RequestUri); + request.RequestUri = new Uri (base_address, uri); } if (headers != null) { diff --git a/mcs/class/System.Net.Http/Test/System.Net.Http/HttpClientTest.cs b/mcs/class/System.Net.Http/Test/System.Net.Http/HttpClientTest.cs index 36d54a6845b..b58318819a2 100644 --- a/mcs/class/System.Net.Http/Test/System.Net.Http/HttpClientTest.cs +++ b/mcs/class/System.Net.Http/Test/System.Net.Http/HttpClientTest.cs @@ -330,6 +330,7 @@ namespace MonoTests.System.Net.Http }; Assert.AreEqual (response, client.GetAsync ("relative").Result, "#1"); + Assert.AreEqual (response, client.GetAsync ("/relative").Result, "#2"); } [Test] -- 2.25.1