X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem%2FTest%2FSystem.Net%2FHttpListenerRequestTest.cs;h=2066cc6a6db490128d6ecf29756286db2e776030;hb=e3685c4c9aad38851097cff877dc0fb7ed47ab10;hp=d782103f33e33709321e1c7f2211d2b4fccf8a90;hpb=4c960e1dd530396fdd9400c87729a6ce3101e5c1;p=mono.git diff --git a/mcs/class/System/Test/System.Net/HttpListenerRequestTest.cs b/mcs/class/System/Test/System.Net/HttpListenerRequestTest.cs index d782103f33e..2066cc6a6db 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; @@ -211,6 +212,8 @@ namespace MonoTests.System.Net var ips = new List (); ips.Add (IPAddress.Loopback); foreach (var adapter in NetworkInterface.GetAllNetworkInterfaces ()) { + if (adapter.OperationalStatus != OperationalStatus.Up) + continue; foreach (var ip in adapter.GetIPProperties ().UnicastAddresses) { ips.Add (ip.Address); } @@ -252,12 +255,50 @@ 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"); + } + + [Test] + public void HttpRequestIgnoreBadCookies () + { + var port = NetworkHelpers.FindFreePort (); + HttpListener listener = HttpListener2Test.CreateAndStartListener ( + "http://127.0.0.1:" + port + "/HttpRequestIgnoreBadCookiesTest/"); + NetworkStream ns = HttpListener2Test.CreateNS (port); + HttpListener2Test.Send (ns, "GET /HttpRequestIgnoreBadCookiesTest/?a=b HTTP/1.1\r\nHost: 127.0.0.1\r\nCookie: ELOQUA=GUID=5ca2346347357f4-f877-4eff-96aa-70fe0b677650; ELQSTATUS=OK; WRUID=609099666.123259461695; CommunityServer-UserCookie2101=lv=Thu, 26 Jul 2012 15:25:11 GMT&mra=Mon, 01 Oct 2012 17:40:05 GMT; PHPSESSID=1234dg3opfjb4qafp0oo645; __utma=9761706.1153317537.1357240270.1357240270.1357317902.2; __utmb=9761706.6.10.1357317902; __utmc=9761706; __utmz=9761706.1357240270.1.1.utmcsr=test.testdomain.com|utmccn=(referral)|utmcmd=referral|utmcct=/test/1234\r\n\r\n"); + HttpListenerContext ctx = listener.GetContext (); + HttpListenerRequest request = ctx.Request; + Assert.AreEqual ("/HttpRequestIgnoreBadCookiesTest/?a=b", request.Url.PathAndQuery); + listener.Close (); + } } }