From 0361fc34a8953b79bf531f9ddadf7b04cb9cc431 Mon Sep 17 00:00:00 2001 From: Marcos Henrich Date: Mon, 1 Jun 2015 11:30:33 +0100 Subject: [PATCH] [System] Test HttpRequest Uri unescaping Covers #29927 --- .../System.Net/HttpListenerRequestTest.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/mcs/class/System/Test/System.Net/HttpListenerRequestTest.cs b/mcs/class/System/Test/System.Net/HttpListenerRequestTest.cs index 4d8564237d6..bc2bb3fa23d 100644 --- a/mcs/class/System/Test/System.Net/HttpListenerRequestTest.cs +++ b/mcs/class/System/Test/System.Net/HttpListenerRequestTest.cs @@ -184,5 +184,31 @@ namespace MonoTests.System.Net Assert.AreEqual ("/RequestUriDecodeTest/?a=b&c=d%26e", request.Url.PathAndQuery); listener.Close (); } + + [Test] // #29927 + public void HttpRequestUriUnescape () + { + var prefix = "http://localhost:12345/"; + var key = "Product/1"; + + var expectedUrl = prefix + key + "/"; + var rawUrl = prefix + Uri.EscapeDataString (key) + "/"; + + HttpListener listener = new HttpListener (); + listener.Prefixes.Add (prefix); + listener.Start (); + + var contextTask = listener.GetContextAsync (); + + var request = (HttpWebRequest) WebRequest.Create (rawUrl); + request.GetResponseAsync (); + + if(!contextTask.Wait (1000)) + Assert.Fail ("Timeout"); + + Assert.AreEqual (expectedUrl, contextTask.Result.Request.Url.AbsoluteUri); + + listener.Close (); + } } } -- 2.25.1