2008-10-30 Gonzalo Paniagua Javier <gonzalo@novell.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Thu, 30 Oct 2008 19:12:52 +0000 (19:12 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Thu, 30 Oct 2008 19:12:52 +0000 (19:12 -0000)
* HttpWebResponseTest.cs:
* SocketResponder.cs:
* HttpWebRequestTest.cs: don't pretend to be a 1.1 server or the
socket will stay open. Timeout for Ntlm test is 5s now.

svn path=/trunk/mcs/; revision=117510

mcs/class/System/Test/System.Net/ChangeLog
mcs/class/System/Test/System.Net/HttpWebRequestTest.cs
mcs/class/System/Test/System.Net/HttpWebResponseTest.cs
mcs/class/System/Test/System.Net/SocketResponder.cs

index 5611f6701de50402a92316eab98dd6648b4adc68..98cd79d38e44d6220db8ff24bbcce747c01f1d8e 100644 (file)
@@ -1,3 +1,11 @@
+
+2008-10-30 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * HttpWebResponseTest.cs:
+       * SocketResponder.cs:
+       * HttpWebRequestTest.cs: don't pretend to be a 1.1 server or the
+       socket will stay open. Timeout for Ntlm test is 5s now.
+
 2008-10-19  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * HttpWebRequestTest.cs: Fixed test for bug #429200.
index 6287a5f0c1e85a54829906577304133d6ab941b8..d7f3359a010c3b2115c84a870d48bb5976e4a0a1 100644 (file)
@@ -307,6 +307,7 @@ namespace MonoTests.System.Net
 #if TARGET_JVM
                [Category("NotWorking")]
 #endif
+               [Ignore ("This does not timeout any more. That's how MS works when reading small responses")]
                public void ReadTimeout ()
                {
                        IPEndPoint localEP = new IPEndPoint (IPAddress.Loopback, 8764);
@@ -659,19 +660,19 @@ namespace MonoTests.System.Net
 
                        StringWriter sw = new StringWriter ();
                        if (statusLine.StartsWith ("POST /original/")) {
-                               sw.WriteLine ("HTTP/1.1 302 Found");
+                               sw.WriteLine ("HTTP/1.0 302 Found");
                                sw.WriteLine ("Location: " + "http://" + IPAddress.Loopback.ToString () + ":8764/moved/");
                                sw.WriteLine ();
                                sw.Flush ();
                        } else if (statusLine.StartsWith ("GET /moved/")) {
-                               sw.WriteLine ("HTTP/1.1 200 OK");
+                               sw.WriteLine ("HTTP/1.0 200 OK");
                                sw.WriteLine ("Content-Type: text/plain");
                                sw.WriteLine ("Content-Length: 8");
                                sw.WriteLine ();
                                sw.Write ("LOOKS OK");
                                sw.Flush ();
                        } else {
-                               sw.WriteLine ("HTTP/1.1 500 Too Lazy");
+                               sw.WriteLine ("HTTP/1.0 500 Too Lazy");
                                sw.WriteLine ();
                                sw.Flush ();
                        }
@@ -708,6 +709,7 @@ namespace MonoTests.System.Net
 
                        string url = String.Format ("http://{0}:{1}/nothing.html", server.IPAddress, server.Port);
                        HttpWebRequest request = (HttpWebRequest) WebRequest.Create (url);
+                       request.Timeout = 5000;
                        request.Credentials = new NetworkCredential ("user", "password", "domain");
                        HttpWebResponse resp = (HttpWebResponse) request.GetResponse ();
                        string res = null;
@@ -720,38 +722,46 @@ namespace MonoTests.System.Net
                }
 
                class NtlmServer : HttpServer {
+                       public string Where = "";
                        protected override void Run ()
                        {
+                               Where = "before accept";
                                Socket client = sock.Accept ();
                                NetworkStream ns = new NetworkStream (client, false);
                                StreamReader reader = new StreamReader (ns, Encoding.ASCII);
                                string line;
+                               Where = "first read";
                                while ((line = reader.ReadLine ()) != null) {
                                        if (line.Trim () == String.Empty) {
                                                break;
                                        }
                                }
+                               Where = "first write";
                                StreamWriter writer = new StreamWriter (ns, Encoding.ASCII);
                                writer.Write (  "HTTP/1.1 401 Unauthorized\r\n" +
                                                "WWW-Authenticate: NTLM\r\n" +
                                                "Content-Length: 5\r\n\r\nWRONG");
 
                                writer.Flush ();
+                               Where = "second read";
                                while ((line = reader.ReadLine ()) != null) {
                                        if (line.Trim () == String.Empty) {
                                                break;
                                        }
                                }
+                               Where = "second write";
                                writer.Write (  "HTTP/1.1 401 Unauthorized\r\n" +
                                                "WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAAAAADgAAAABggAC8GDhqIONH3sAAAAAAAAAAAAAAAA4AAAABQLODgAAAA8=\r\n" +
                                                "Content-Length: 5\r\n\r\nWRONG");
                                writer.Flush ();
 
+                               Where = "third read";
                                while ((line = reader.ReadLine ()) != null) {
                                        if (line.Trim () == String.Empty) {
                                                break;
                                        }
                                }
+                               Where = "third write";
                                writer.Write (  "HTTP/1.1 200 OK\r\n" +
                                                "Keep-Alive: true\r\n" +
                                                "Content-Length: 2\r\n\r\nOK");
index eba0377e59a699db49f9523b517be2a1c4c17028..936de69c895d3d64c6afdc1e73c5ced77d1b102b 100644 (file)
@@ -533,7 +533,7 @@ namespace MonoTests.System.Net
                {
                        StringWriter sw = new StringWriter ();
                        sw.NewLine = "\r\n";
-                       sw.WriteLine ("HTTP/1.1 200 OK");
+                       sw.WriteLine ("HTTP/1.0 200 OK");
                        sw.WriteLine ("Server: Mono/Test");
                        sw.WriteLine ("Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT");
                        sw.WriteLine ("Content-Encoding: " + Encoding.UTF8.WebName);
index 42f04c8bb1ddf9a587a9527b14c94247bf64f60f..07525a78db380949e71c4a938884c1a268439479 100644 (file)
@@ -108,6 +108,9 @@ namespace MonoTests.System.Net
                                try {
                                        Socket socket = tcpListener.AcceptSocket ();
                                        socket.Send (_requestHandler (socket));
+                                       socket.Shutdown (SocketShutdown.Send);
+                                       Thread.Sleep (500);
+                                       socket.Close ();
                                } catch (SocketException ex) {
                                        // ignore interruption of blocking call
                                        if (ex.ErrorCode != SOCKET_CLOSED)