Merge pull request #1659 from alexanderkyte/stringbuilder-referencesource
[mono.git] / mcs / class / System / Test / System.Net / ServicePointTest.cs
index da4a0f5dd4df0e2ec06134d0910c127851a7f4a1..bb12a4c28f3eb93112b9ac5e1952a68b9c80fa4a 100644 (file)
@@ -177,6 +177,28 @@ public class ServicePointTest
                Assert.IsTrue (called);\r
        }\r
 \r
+       public static void GetRequestStreamCallback (IAsyncResult asynchronousResult)\r
+       {\r
+       }\r
+\r
+       [Test] //Covers #19823\r
+       public void CloseConnectionGroupConcurency ()\r
+       {\r
+               // Try with multiple service points\r
+               for (var i = 0; i < 10; i++) {\r
+                       Uri targetUri = new Uri ("http://" + i + ".mono-project.com");\r
+                       var req = (HttpWebRequest) HttpWebRequest.Create (targetUri);\r
+                       req.ContentType = "application/x-www-form-urlencoded";\r
+                       req.Method = "POST";\r
+                       req.ConnectionGroupName = "" + i;\r
+                       req.ServicePoint.MaxIdleTime = 1;\r
+\r
+                       req.BeginGetRequestStream (new AsyncCallback (GetRequestStreamCallback), req);\r
+                       Thread.Sleep (1);\r
+                       req.ServicePoint.CloseConnectionGroup (req.ConnectionGroupName);\r
+               }\r
+       }\r
+\r
 // Debug code not used now, but could be useful later\r
 /*\r
        private void WriteServicePoint (string label, ServicePoint sp)\r