// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_2_0
+
using System;
using System.Collections.Generic;
using System.Globalization;
}
}
}
-#endif
-
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_2_0
-
using System;
using System.IO;
using System.Net;
Assert.AreEqual ("pOsT", request.HttpMethod);
listener.Close ();
}
-
+
[Test]
- public void HttpBasicAuthScheme()
- {
- HttpListener listener = HttpListener2Test.CreateAndStartListener("http://*:9000/authTest/", AuthenticationSchemes.Basic);
- //dummy-wait for context
- listener.BeginGetContext(null, listener);
- NetworkStream ns = HttpListener2Test.CreateNS(9000);
- HttpListener2Test.Send(ns, "GET /authTest/ HTTP/1.0\r\n\r\n");
- String response = HttpListener2Test.Receive(ns, 512);
- Assert.IsTrue(response.Contains("WWW-Authenticate: Basic realm"), "#A");
- ns.Close();
- listener.Close();
- }
+ public void HttpBasicAuthScheme ()
+ {
+ HttpListener listener = HttpListener2Test.CreateAndStartListener ("http://*:9000/authTest/", AuthenticationSchemes.Basic);
+ //dummy-wait for context
+ listener.BeginGetContext (null, listener);
+ NetworkStream ns = HttpListener2Test.CreateNS (9000);
+ HttpListener2Test.Send (ns, "GET /authTest/ HTTP/1.0\r\n\r\n");
+ String response = HttpListener2Test.Receive (ns, 512);
+ Assert.IsTrue (response.Contains ("WWW-Authenticate: Basic realm"), "#A");
+ ns.Close ();
+ listener.Close ();
+ }
}
}
-
-#endif
req.SendChunked = true;
req.KeepAlive = false;
req.AllowWriteStreamBuffering = false;
+ req.GetRequestStream ().WriteByte (1);
req.BeginGetResponse (null, null);
req.Abort ();
req.SendChunked = false;
req.KeepAlive = false;
req.AllowWriteStreamBuffering = false;
+ req.GetRequestStream ().WriteByte (5);
req.BeginGetResponse (null, null);
req.Abort ();
req.Host = "go-mono.com:65536";
}
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void HostTooLong ()
+ {
+ HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://go-mono.com");
+ string s = new string ('a', 100);
+ req.Host = s + "." + s + "." + s + "." + s + "." + s + "." + s; // Over 255 bytes
+ }
+
[Test]
public void InvalidNamesThatWork ()
{
req.Host = "-.-";
req.Host = "รก";
req.Host = new string ('a', 64); // Should fail. Max. is 63.
- string s = new string ('a', 100);
- req.Host = s + "." + s + "." + s + "." + s + "." + s + "." + s; // Over 255 bytes
}
[Test]