Exemplo n.º 1
0
		public void Test13 ()
		{
			// 0.9
			_listener = CreateAndStartListener ("http://127.0.0.1:9000/test13/");
			MyNetworkStream ns = CreateNS (9000);
			Send (ns, "GEt /test13/ HTTP/0.9\r\nHost: 127.0.0.1\r\n\r\n");
			ns.GetSocket ().Shutdown (SocketShutdown.Send);
			string input = Receive (ns, 512);
			ns.Close ();
			Assert.IsTrue (input.StartsWith ("HTTP/1.1 400"));
		}
		public void Test12 ()
		{
			// 0.9
			_listener = NetworkHelpers.CreateAndStartHttpListener ("http://127.0.0.1:", out var port, "/test12/");
			MyNetworkStream ns = CreateNS (port);
			Send (ns, "POST /test12/ HTTP/0.9\r\nHost: 127.0.0.1\r\nContent-Length: 3\r\n\r\n123");
			ns.GetSocket ().Shutdown (SocketShutdown.Send);
			string input = Receive (ns, 512);
			ns.Close ();
			Assert.IsTrue(input.StartsWith ("HTTP/1.1 400"));
		}
Exemplo n.º 3
0
 public void Test12()
 {
     // 0.9
     using (HttpListener listener = CreateAndStartListener("http://127.0.0.1:9000/test12/")) {
         MyNetworkStream ns = CreateNS(9000);
         Send(ns, "POST /test12/ HTTP/0.9\r\nHost: 127.0.0.1\r\nContent-Length: 3\r\n\r\n123");
         ns.GetSocket().Shutdown(SocketShutdown.Send);
         string input = Receive(ns, 512);
         ns.Close();
         Assert.IsTrue(input.StartsWith("HTTP/1.1 400"));
     }
 }
Exemplo n.º 4
0
		public void Test10 ()
		{
			// Same as Test9, but now we shutdown the socket for sending.
			_listener = CreateAndStartListener ("http://127.0.0.1:9000/test10/");
			MyNetworkStream ns = CreateNS (9000);
			Send (ns, "POST /test10/ HTTP/1.0\r\nHost: 127.0.0.1\r\nTransfer-Encoding: chunked\r\n\r\n3\r\n123\r\n0\r\n\r\n");
			ns.GetSocket ().Shutdown (SocketShutdown.Send);
			bool timeout;
			string response = ReceiveWithTimeout (ns, 512, 1000, out timeout);
			ns.Close ();
			Assert.IsFalse (timeout);
			Assert.IsTrue (response.StartsWith ("HTTP/1.1 411"));
		}
Exemplo n.º 5
0
        public void Test11()
        {
            var port = NetworkHelpers.FindFreePort();

            // 0.9
            _listener = CreateAndStartListener("http://127.0.0.1:" + port + "/test11/");
            MyNetworkStream ns = CreateNS(port);

            Send(ns, "POST /test11/ HTTP/0.9\r\nHost: 127.0.0.1\r\n\r\n123");
            ns.GetSocket().Shutdown(SocketShutdown.Send);
            string input = Receive(ns, 512);

            ns.Close();
            Assert.IsTrue(input.StartsWith("HTTP/1.1 400"));
        }