Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2016-11-23 19:40:00 +0300
committerMarek Safar <marek.safar@gmail.com>2016-11-23 19:40:49 +0300
commit9858a95dd1478c19832fadada318834de2c93aeb (patch)
treefa6ff0d4c10a20d2ff0c9c703c74dbd8e2536e1d /mcs/class/System/Test
parentc8f2e68962cafea5319a7229268e9ee3b32544d6 (diff)
[System] Don't send response on empty stream write. Fixes #47549
Diffstat (limited to 'mcs/class/System/Test')
-rw-r--r--mcs/class/System/Test/System.Net/HttpListenerRequestTest.cs31
1 files changed, 29 insertions, 2 deletions
diff --git a/mcs/class/System/Test/System.Net/HttpListenerRequestTest.cs b/mcs/class/System/Test/System.Net/HttpListenerRequestTest.cs
index 18dedcae32d..2f24f73ec0d 100644
--- a/mcs/class/System/Test/System.Net/HttpListenerRequestTest.cs
+++ b/mcs/class/System/Test/System.Net/HttpListenerRequestTest.cs
@@ -34,6 +34,7 @@ using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text;
using System.Collections.Generic;
+using System.Threading.Tasks;
using NUnit.Framework;
@@ -254,12 +255,38 @@ namespace MonoTests.System.Net
var request = (HttpWebRequest) WebRequest.Create (rawUrl);
request.GetResponseAsync ();
- if(!contextTask.Wait (1000))
- Assert.Fail ("Timeout");
+ Assert.IsTrue (contextTask.Wait (1000));
Assert.AreEqual (expectedUrl, contextTask.Result.Request.Url.AbsoluteUri);
listener.Close ();
}
+
+ [Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
+ public void EmptyWrite ()
+ {
+ var prefix = "http://localhost:" + NetworkHelpers.FindFreePort () + "/";
+
+ HttpListener listener = new HttpListener ();
+ listener.Prefixes.Add (prefix);
+ listener.Start ();
+
+ Task.Run (() => {
+ var context = listener.GetContext ();
+
+ var s = context.Response.OutputStream;
+ s.Write (new byte[10], 0, 0);
+ return;
+ });
+
+ var request = (HttpWebRequest)WebRequest.Create (prefix);
+ var rsp = request.GetResponseAsync ();
+ Assert.IsFalse (rsp.Wait (1000), "Don't send on empty write");
+
+ listener.Close ();
+ }
}
}