You've already forked linux-packaging-mono
Imported Upstream version 4.8.0.309
Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
parent
ee1447783b
commit
94b2861243
@@ -71,6 +71,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void TestExpires ()
|
||||
{
|
||||
var cookies = DoRequest (A);
|
||||
@@ -81,6 +84,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void TestInvalidCookie ()
|
||||
{
|
||||
var cookies = DoRequest (B);
|
||||
@@ -91,6 +97,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void TestLocalCulture ()
|
||||
{
|
||||
var old = Thread.CurrentThread.CurrentCulture;
|
||||
@@ -108,6 +117,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void TestMultiple ()
|
||||
{
|
||||
var cookies = DoRequest (D);
|
||||
@@ -118,6 +130,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void TestMultiple2 ()
|
||||
{
|
||||
var cookies = DoRequest (E);
|
||||
@@ -127,6 +142,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void TestQuotation ()
|
||||
{
|
||||
var cookies = DoRequest (F);
|
||||
@@ -139,6 +157,7 @@ namespace MonoTests.System.Net
|
||||
{
|
||||
Socket socket;
|
||||
string[] headers;
|
||||
Exception ex;
|
||||
|
||||
public Listener (params string[] headers)
|
||||
{
|
||||
@@ -154,17 +173,28 @@ namespace MonoTests.System.Net
|
||||
socket.Bind (new IPEndPoint (IPAddress.Loopback, 0));
|
||||
socket.Listen (1);
|
||||
socket.BeginAccept ((result) => {
|
||||
var accepted = socket.EndAccept (result);
|
||||
HandleRequest (accepted);
|
||||
try {
|
||||
var accepted = socket.EndAccept (result);
|
||||
HandleRequest (accepted);
|
||||
} catch (Exception e) {
|
||||
ex = e;
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
|
||||
void ThrowIfException ()
|
||||
{
|
||||
if (ex != null)
|
||||
throw ex;
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
if (socket != null) {
|
||||
socket.Close ();
|
||||
socket = null;
|
||||
}
|
||||
ThrowIfException ();
|
||||
}
|
||||
|
||||
void HandleRequest (Socket accepted)
|
||||
@@ -182,11 +212,17 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
public EndPoint EndPoint {
|
||||
get { return socket.LocalEndPoint; }
|
||||
get {
|
||||
ThrowIfException ();
|
||||
return socket.LocalEndPoint;
|
||||
}
|
||||
}
|
||||
|
||||
public string URI {
|
||||
get { return string.Format ("http://{0}/", EndPoint); }
|
||||
get {
|
||||
ThrowIfException ();
|
||||
return string.Format ("http://{0}/", EndPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,41 +29,77 @@ namespace MonoTests.System.Net
|
||||
private uint site1IP = 134744072, site2IP = 134743044; // Big-Endian
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void AsyncGetHostByName ()
|
||||
{
|
||||
IAsyncResult r;
|
||||
r = Dns.BeginGetHostByName (site1Name, new AsyncCallback (GetHostByNameCallback), null);
|
||||
|
||||
IAsyncResult async = Dns.BeginGetHostByName (site1Name, null, null);
|
||||
IPHostEntry entry = Dns.EndGetHostByName (async);
|
||||
SubTestValidIPHostEntry (entry);
|
||||
Assert.IsTrue (entry.HostName == "google-public-dns-a.google.com");
|
||||
}
|
||||
|
||||
void GetHostByNameCallback (IAsyncResult ar)
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void AsyncGetHostByNameCallback ()
|
||||
{
|
||||
IPHostEntry h;
|
||||
h = Dns.EndGetHostByName (ar);
|
||||
SubTestValidIPHostEntry (h);
|
||||
var evt = new ManualResetEvent (false);
|
||||
Exception ex = null;
|
||||
Dns.BeginGetHostByName (site1Name, new AsyncCallback ((IAsyncResult ar) =>
|
||||
{
|
||||
try {
|
||||
IPHostEntry h;
|
||||
h = Dns.EndGetHostByName (ar);
|
||||
SubTestValidIPHostEntry (h);
|
||||
} catch (Exception e) {
|
||||
ex = e;
|
||||
} finally {
|
||||
evt.Set ();
|
||||
}
|
||||
}), null);
|
||||
|
||||
Assert.IsTrue (evt.WaitOne (TimeSpan.FromSeconds (60)), "Wait");
|
||||
Assert.IsNull (ex, "Exception");
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void AsyncResolve ()
|
||||
{
|
||||
IAsyncResult r;
|
||||
r = Dns.BeginResolve (site1Name, new AsyncCallback (ResolveCallback), null);
|
||||
|
||||
IAsyncResult async = Dns.BeginResolve (site1Dot, null, null);
|
||||
IPHostEntry entry = Dns.EndResolve (async);
|
||||
SubTestValidIPHostEntry (entry);
|
||||
SubTestValidIPHostEntry (entry);
|
||||
var ip = GetIPv4Address (entry);
|
||||
Assert.AreEqual (site1Dot, ip.ToString ());
|
||||
}
|
||||
|
||||
void ResolveCallback (IAsyncResult ar)
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void AsyncResolveCallback ()
|
||||
{
|
||||
IPHostEntry h = Dns.EndResolve (ar);
|
||||
SubTestValidIPHostEntry (h);
|
||||
var evt = new ManualResetEvent (false);
|
||||
Exception ex = null;
|
||||
Dns.BeginResolve (site1Name, new AsyncCallback ((IAsyncResult ar) =>
|
||||
{
|
||||
try {
|
||||
IPHostEntry h = Dns.EndResolve (ar);
|
||||
SubTestValidIPHostEntry (h);
|
||||
} catch (Exception e) {
|
||||
ex = e;
|
||||
} finally {
|
||||
evt.Set ();
|
||||
}
|
||||
}), null);
|
||||
|
||||
Assert.IsTrue (evt.WaitOne (TimeSpan.FromSeconds (60)), "Wait");
|
||||
Assert.IsNull (ex, "Exception");
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -72,7 +108,7 @@ namespace MonoTests.System.Net
|
||||
try {
|
||||
Dns.BeginGetHostAddresses (
|
||||
(string) null,
|
||||
new AsyncCallback (GetHostAddressesCallback),
|
||||
new AsyncCallback (ShouldntBeCalled),
|
||||
null);
|
||||
Assert.Fail ("#1");
|
||||
} catch (ArgumentNullException ex) {
|
||||
@@ -90,7 +126,7 @@ namespace MonoTests.System.Net
|
||||
try {
|
||||
Dns.BeginGetHostAddresses (
|
||||
"0.0.0.0",
|
||||
new AsyncCallback (GetHostAddressesCallback),
|
||||
new AsyncCallback (ShouldntBeCalled),
|
||||
null);
|
||||
Assert.Fail ("#A1");
|
||||
} catch (ArgumentException ex) {
|
||||
@@ -107,7 +143,7 @@ namespace MonoTests.System.Net
|
||||
try {
|
||||
Dns.BeginGetHostAddresses (
|
||||
"::0",
|
||||
new AsyncCallback (GetHostAddressesCallback),
|
||||
new AsyncCallback (ShouldntBeCalled),
|
||||
null);
|
||||
Assert.Fail ("#B1");
|
||||
} catch (ArgumentException ex) {
|
||||
@@ -121,10 +157,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
}
|
||||
|
||||
void GetHostAddressesCallback (IAsyncResult ar)
|
||||
void ShouldntBeCalled (IAsyncResult ar)
|
||||
{
|
||||
IPAddress [] addresses = Dns.EndGetHostAddresses (ar);
|
||||
Assert.IsNotNull (addresses);
|
||||
Assert.Fail ("Should not be called");
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -181,6 +216,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void GetHostByName ()
|
||||
{
|
||||
SubTestGetHostByName (site1Name, site1Dot);
|
||||
@@ -306,17 +344,20 @@ namespace MonoTests.System.Net
|
||||
{
|
||||
IPAddress addr = new IPAddress (IPAddress.NetworkToHostOrder ((int) site2IP));
|
||||
IPHostEntry h = Dns.GetHostByAddress (addr);
|
||||
SubTestValidIPHostEntry (h);
|
||||
SubTestValidIPHostEntry (h);
|
||||
var ip = GetIPv4Address (h);
|
||||
Assert.AreEqual (addr.ToString (), ip.ToString ());
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void BeginResolve_HostName_Null ()
|
||||
{
|
||||
try {
|
||||
Dns.BeginResolve ((string) null,
|
||||
new AsyncCallback (ResolveCallback),
|
||||
new AsyncCallback (ShouldntBeCalled),
|
||||
null);
|
||||
Assert.Fail ("#1");
|
||||
} catch (ArgumentNullException ex) {
|
||||
@@ -328,6 +369,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Resolve ()
|
||||
{
|
||||
SubTestResolve (site1Name);
|
||||
@@ -343,6 +387,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Resolve_HostName_Null ()
|
||||
{
|
||||
try {
|
||||
@@ -357,12 +404,15 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test] // BeginGetHostEntry (IPAddress, AsyncCallback, Object)
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void BeginGetHostEntry1_Address_Null ()
|
||||
{
|
||||
try {
|
||||
Dns.BeginGetHostEntry (
|
||||
(IPAddress) null,
|
||||
new AsyncCallback (GetHostAddressesCallback),
|
||||
new AsyncCallback (ShouldntBeCalled),
|
||||
null);
|
||||
Assert.Fail ("#1");
|
||||
} catch (ArgumentNullException ex) {
|
||||
@@ -374,12 +424,15 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test] // BeginGetHostEntry (String, AsyncCallback, Object)
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void BeginGetHostEntry2_HostNameOrAddress_Null ()
|
||||
{
|
||||
try {
|
||||
Dns.BeginGetHostEntry (
|
||||
(string) null,
|
||||
new AsyncCallback (GetHostAddressesCallback),
|
||||
new AsyncCallback (ShouldntBeCalled),
|
||||
null);
|
||||
Assert.Fail ("#1");
|
||||
} catch (ArgumentNullException ex) {
|
||||
@@ -391,6 +444,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test] // BeginGetHostEntry (String, AsyncCallback, Object)
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void BeginGetHostEntry2_HostNameOrAddress_UnspecifiedAddress ()
|
||||
{
|
||||
// IPv4
|
||||
@@ -449,6 +505,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test] // GetHostEntry (String)
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void GetHostEntry2 ()
|
||||
{
|
||||
Dns.GetHostEntry (site1Name); // hostname
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -146,6 +146,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Test1 ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -154,10 +157,13 @@ namespace MonoTests.System.Net {
|
||||
Send (ns, "GET / HTTP/1.1\r\n\r\n"); // No host
|
||||
string response = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
StringAssert.StartsWith ("HTTP/1.1 400", response);
|
||||
Assert.IsTrue(response.StartsWith ("HTTP/1.1 400"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Test2 ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -166,10 +172,13 @@ namespace MonoTests.System.Net {
|
||||
Send (ns, "GET / HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n"); // no prefix
|
||||
string response = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
StringAssert.StartsWith ("HTTP/1.1 400", response);
|
||||
Assert.IsTrue(response.StartsWith ("HTTP/1.1 400"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Test3 ()
|
||||
{
|
||||
StringBuilder bad = new StringBuilder ();
|
||||
@@ -204,11 +213,14 @@ namespace MonoTests.System.Net {
|
||||
string response = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
listener.Close ();
|
||||
StringAssert.StartsWith ("HTTP/1.1 400", response, String.Format ("Failed on {0}", (int) b));
|
||||
Assert.IsTrue(response.StartsWith ("HTTP/1.1 400"), String.Format ("Failed on {0}", (int) b));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Test4 ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -217,10 +229,13 @@ namespace MonoTests.System.Net {
|
||||
Send (ns, "POST /test4/ HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n"); // length required
|
||||
string response = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
StringAssert.StartsWith ("HTTP/1.1 411", response);
|
||||
Assert.IsTrue(response.StartsWith ("HTTP/1.1 411"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Test5 ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -229,10 +244,13 @@ namespace MonoTests.System.Net {
|
||||
Send (ns, "POST / HTTP/1.1\r\nHost: 127.0.0.1\r\nTransfer-Encoding: pepe\r\n\r\n"); // not implemented
|
||||
string response = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
StringAssert.StartsWith ("HTTP/1.1 501", response);
|
||||
Assert.IsTrue(response.StartsWith ("HTTP/1.1 501"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Test6 ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -242,10 +260,13 @@ namespace MonoTests.System.Net {
|
||||
Send (ns, "POST /test6/ HTTP/1.1\r\nHost: 127.0.0.1\r\nTransfer-Encoding: identity\r\n\r\n");
|
||||
string response = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
StringAssert.StartsWith ("HTTP/1.1 501", response);
|
||||
Assert.IsTrue(response.StartsWith ("HTTP/1.1 501"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Test7 ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -257,11 +278,14 @@ namespace MonoTests.System.Net {
|
||||
ctx.Response.Close ();
|
||||
string response = Receive (ns, 1024);
|
||||
ns.Close ();
|
||||
StringAssert.StartsWith ("HTTP/1.1 200", response);
|
||||
StringAssert.Contains ("Transfer-Encoding: chunked", response);
|
||||
Assert.IsTrue(response.StartsWith ("HTTP/1.1 200"));
|
||||
Assert.IsTrue(response.Contains ("Transfer-Encoding: chunked"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Test8 ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -274,11 +298,14 @@ namespace MonoTests.System.Net {
|
||||
ctx.Response.Close ();
|
||||
string response = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
StringAssert.StartsWith ("HTTP/1.1 200", response);
|
||||
Assert.IsTrue(response.StartsWith ("HTTP/1.1 200"));
|
||||
Assert.IsTrue (-1 == response.IndexOf ("Transfer-Encoding: chunked"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Test9 ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -290,10 +317,13 @@ namespace MonoTests.System.Net {
|
||||
string response = ReceiveWithTimeout (ns, 512, 1000, out timeout);
|
||||
ns.Close ();
|
||||
Assert.IsFalse (timeout);
|
||||
StringAssert.StartsWith ("HTTP/1.1 411", response);
|
||||
Assert.IsTrue(response.StartsWith ("HTTP/1.1 411"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Test10 ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -306,10 +336,13 @@ namespace MonoTests.System.Net {
|
||||
string response = ReceiveWithTimeout (ns, 512, 1000, out timeout);
|
||||
ns.Close ();
|
||||
Assert.IsFalse (timeout);
|
||||
StringAssert.StartsWith ("HTTP/1.1 411", response);
|
||||
Assert.IsTrue(response.StartsWith ("HTTP/1.1 411"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Test11 ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -320,10 +353,13 @@ namespace MonoTests.System.Net {
|
||||
ns.GetSocket ().Shutdown (SocketShutdown.Send);
|
||||
string input = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
StringAssert.StartsWith ("HTTP/1.1 400", input);
|
||||
Assert.IsTrue(input.StartsWith ("HTTP/1.1 400"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Test12 ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -334,10 +370,13 @@ namespace MonoTests.System.Net {
|
||||
ns.GetSocket ().Shutdown (SocketShutdown.Send);
|
||||
string input = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
StringAssert.StartsWith ("HTTP/1.1 400", input);
|
||||
Assert.IsTrue(input.StartsWith ("HTTP/1.1 400"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Test13 ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -348,13 +387,16 @@ namespace MonoTests.System.Net {
|
||||
ns.GetSocket ().Shutdown (SocketShutdown.Send);
|
||||
string input = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
StringAssert.StartsWith ("HTTP/1.1 400", input);
|
||||
Assert.IsTrue(input.StartsWith ("HTTP/1.1 400"));
|
||||
}
|
||||
|
||||
HttpListenerRequest test14_request;
|
||||
ManualResetEvent test_evt;
|
||||
bool test14_error;
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Test14 ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -391,6 +433,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Test15 ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -413,6 +458,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Test16 ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -437,6 +485,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Test17 ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -448,11 +499,14 @@ namespace MonoTests.System.Net {
|
||||
ctx.Response.Close ();
|
||||
string response = Receive (ns, 1024);
|
||||
ns.Close ();
|
||||
StringAssert.StartsWith ("HTTP/1.1 200", response);
|
||||
StringAssert.Contains ("Transfer-Encoding: chunked", response);
|
||||
Assert.IsTrue(response.StartsWith ("HTTP/1.1 200"));
|
||||
Assert.IsTrue(response.Contains ("Transfer-Encoding: chunked"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Test_MultipleClosesOnOuputStreamAllowed ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -483,6 +537,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void ReceiveCookiesFromClient ()
|
||||
{
|
||||
sendCookiePort = NetworkHelpers.FindFreePort ();
|
||||
@@ -529,6 +586,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void SendCookiestoClient ()
|
||||
{
|
||||
receiveCookiePort = NetworkHelpers.FindFreePort ();
|
||||
@@ -580,6 +640,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void MultiResponses ()
|
||||
{
|
||||
echoServerPort = NetworkHelpers.FindFreePort ();
|
||||
@@ -647,6 +710,9 @@ namespace MonoTests.System.Net {
|
||||
[TestFixture]
|
||||
public class HttpListenerBugs {
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void TestNonChunkedAsync ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -701,6 +767,9 @@ namespace MonoTests.System.Net {
|
||||
// a documented pattern to close the connection
|
||||
//
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Test_MultipleConnections ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -731,6 +800,9 @@ namespace MonoTests.System.Net {
|
||||
// Test case for bug 341443, an pretty old bug, filed on November of 2007.
|
||||
//
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Test_HostInUri ()
|
||||
{
|
||||
var wait = new ManualResetEvent (false);
|
||||
@@ -760,6 +832,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test] // bug #513849
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void ClosePort ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -783,6 +858,9 @@ namespace MonoTests.System.Net {
|
||||
// does not also listen to another interface.
|
||||
//
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void BindToSingleInterface ()
|
||||
{
|
||||
IPAddress [] machineAddress = null;
|
||||
@@ -809,6 +887,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void BindToAllInterfaces ()
|
||||
{
|
||||
var h = new HttpListener ();
|
||||
@@ -821,6 +902,9 @@ namespace MonoTests.System.Net {
|
||||
|
||||
// Test case for bug #31209
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Test_EmptyLineAtStart ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
|
||||
@@ -36,6 +36,9 @@ namespace MonoTests.System.Net {
|
||||
public class HttpListenerPrefixCollectionTest {
|
||||
// NL -> Not listening -> tests when listener.IsListening == false
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void NL_DefaultProperties ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -46,6 +49,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void DefaultProperties ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -57,6 +63,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void AddOne ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -70,6 +79,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Duplicate ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -84,6 +96,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void EndsWithSlash ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -91,6 +106,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void DifferentPath ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -100,6 +118,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void NL_Clear ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -108,6 +129,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void NL_Remove ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -116,6 +140,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void NL_RemoveBadUri ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -124,7 +151,11 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#else
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
#endif
|
||||
public void NL_AddBadUri ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -133,7 +164,11 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#else
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
#endif
|
||||
public void NoHostInUrl ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -141,6 +176,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void MultipleSlashes ()
|
||||
{
|
||||
// this one throws on Start(), not when adding it.
|
||||
@@ -154,6 +192,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void PercentSign ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -167,6 +208,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Disposed1 ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -178,7 +222,11 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#else
|
||||
[ExpectedException (typeof (ObjectDisposedException))]
|
||||
#endif
|
||||
public void Disposed2 ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -188,7 +236,11 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#else
|
||||
[ExpectedException (typeof (ObjectDisposedException))]
|
||||
#endif
|
||||
public void Disposed3 ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -198,7 +250,11 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#else
|
||||
[ExpectedException (typeof (ObjectDisposedException))]
|
||||
#endif
|
||||
public void Disposed4 ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -208,7 +264,11 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#else
|
||||
[ExpectedException (typeof (ObjectDisposedException))]
|
||||
#endif
|
||||
public void Disposed5 ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -219,6 +279,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Disposed6 ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -232,6 +295,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Disposed7 ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
|
||||
@@ -150,6 +150,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void HttpMethod ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -164,6 +167,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void HttpBasicAuthScheme ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -179,6 +185,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void HttpRequestUriIsNotDecoded ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -193,6 +202,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void HttpRequestIsLocal ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -220,6 +232,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test] // #29927
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void HttpRequestUriUnescape ()
|
||||
{
|
||||
var prefix = "http://localhost:" + NetworkHelpers.FindFreePort () + "/";
|
||||
|
||||
@@ -39,14 +39,21 @@ namespace MonoTests.System.Net {
|
||||
[TestFixture]
|
||||
public class HttpListenerTest {
|
||||
|
||||
int port;
|
||||
int? _port;
|
||||
int port {
|
||||
get { return _port ?? (_port = NetworkHelpers.FindFreePort ()).Value; }
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void SetUp () {
|
||||
port = NetworkHelpers.FindFreePort ();
|
||||
[TearDown]
|
||||
public void Teardown ()
|
||||
{
|
||||
_port = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void DefaultProperties ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -60,6 +67,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Start1 ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -67,6 +77,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Stop1 ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -74,7 +87,11 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#else
|
||||
[ExpectedException (typeof (InvalidOperationException))]
|
||||
#endif
|
||||
public void GetContext1 ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -83,7 +100,11 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#else
|
||||
[ExpectedException (typeof (InvalidOperationException))]
|
||||
#endif
|
||||
public void GetContext2 ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -93,7 +114,11 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#else
|
||||
[ExpectedException (typeof (InvalidOperationException))]
|
||||
#endif
|
||||
public void BeginGetContext1 ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -102,6 +127,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void BeginGetContext2 ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -134,6 +162,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void DefaultHttpPort ()
|
||||
{
|
||||
if (!CanOpenPort (80))
|
||||
@@ -147,6 +178,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void DefaultHttpsPort ()
|
||||
{
|
||||
if (!CanOpenPort (443))
|
||||
@@ -160,6 +194,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void TwoListeners_SameAddress ()
|
||||
{
|
||||
if (!CanOpenPort (port))
|
||||
@@ -173,7 +210,11 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#else
|
||||
[ExpectedException (typeof (HttpListenerException))]
|
||||
#endif
|
||||
public void TwoListeners_SameURL ()
|
||||
{
|
||||
if (!CanOpenPort (port))
|
||||
@@ -187,7 +228,11 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#else
|
||||
[ExpectedException (typeof (HttpListenerException))]
|
||||
#endif
|
||||
public void MultipleSlashes ()
|
||||
{
|
||||
if (!CanOpenPort (port))
|
||||
@@ -199,7 +244,11 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#else
|
||||
[ExpectedException (typeof (HttpListenerException))]
|
||||
#endif
|
||||
public void PercentSign ()
|
||||
{
|
||||
if (!CanOpenPort (port))
|
||||
@@ -211,6 +260,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void CloseBeforeStart ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -218,6 +270,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void CloseTwice ()
|
||||
{
|
||||
if (!CanOpenPort (port))
|
||||
@@ -230,6 +285,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void StartStopStart ()
|
||||
{
|
||||
if (!CanOpenPort (port))
|
||||
@@ -243,6 +301,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void StartStopDispose ()
|
||||
{
|
||||
if (!CanOpenPort (port))
|
||||
@@ -255,6 +316,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void AbortBeforeStart ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -262,6 +326,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void AbortTwice ()
|
||||
{
|
||||
if (!CanOpenPort (port))
|
||||
@@ -274,6 +341,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void PropertiesWhenClosed1 ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -287,7 +357,11 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#else
|
||||
[ExpectedException (typeof (ObjectDisposedException))]
|
||||
#endif
|
||||
public void PropertiesWhenClosed2 ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -296,7 +370,11 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#else
|
||||
[ExpectedException (typeof (ObjectDisposedException))]
|
||||
#endif
|
||||
public void PropertiesWhenClosedSet1 ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -305,7 +383,11 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#else
|
||||
[ExpectedException (typeof (ObjectDisposedException))]
|
||||
#endif
|
||||
public void PropertiesWhenClosedSet2 ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -314,7 +396,11 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#else
|
||||
[ExpectedException (typeof (ObjectDisposedException))]
|
||||
#endif
|
||||
public void PropertiesWhenClosedSet3 ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -323,7 +409,11 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#else
|
||||
[ExpectedException (typeof (ObjectDisposedException))]
|
||||
#endif
|
||||
public void PropertiesWhenClosedSet4 ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -332,7 +422,11 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#else
|
||||
[ExpectedException (typeof (ObjectDisposedException))]
|
||||
#endif
|
||||
public void PropertiesWhenClosedSet5 ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -341,6 +435,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void PropertiesWhenClosed3 ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -349,6 +446,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void CloseWhileBegin ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -365,6 +465,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void AbortWhileBegin ()
|
||||
{
|
||||
HttpListener listener = new HttpListener ();
|
||||
@@ -381,7 +484,11 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#else
|
||||
[ExpectedException (typeof (HttpListenerException))]
|
||||
#endif
|
||||
public void CloseWhileGet ()
|
||||
{
|
||||
// "System.Net.HttpListener Exception : The I/O operation has been aborted
|
||||
@@ -398,7 +505,11 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#else
|
||||
[ExpectedException (typeof (HttpListenerException))]
|
||||
#endif
|
||||
public void AbortWhileGet ()
|
||||
{
|
||||
// "System.Net.HttpListener Exception : The I/O operation has been aborted
|
||||
@@ -478,6 +589,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void ConnectionReuse ()
|
||||
{
|
||||
var uri = "http://localhost:" + NetworkHelpers.FindFreePort () + "/";
|
||||
@@ -533,8 +647,41 @@ namespace MonoTests.System.Net {
|
||||
|
||||
return clientEndPoint;
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void UserHeaderWithDoubleMultiValue ()
|
||||
{
|
||||
string uri = "http://localhost:" + NetworkHelpers.FindFreePort () + "/";
|
||||
|
||||
var l = new HttpListener ();
|
||||
l.Prefixes.Add (uri);
|
||||
l.Start ();
|
||||
l.BeginGetContext (ar => {
|
||||
var ctx = l.EndGetContext (ar);
|
||||
|
||||
var response = ctx.Response;
|
||||
response.Headers.Add ("X-Custom-Header", "A");
|
||||
response.Headers.Add ("X-Custom-Header", "B");
|
||||
|
||||
response.Close ();
|
||||
}, null);
|
||||
|
||||
HttpWebRequest wr = HttpWebRequest.CreateHttp (uri);
|
||||
var resp = wr.GetResponse ();
|
||||
var vls = resp.Headers.GetValues ("X-Custom-Header");
|
||||
|
||||
Assert.AreEqual (2, vls.Length);
|
||||
|
||||
l.Close ();
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void HttpClientIsDisconnectedCheckForWriteException()
|
||||
{
|
||||
string uri = "http://localhost:" + NetworkHelpers.FindFreePort () + "/";
|
||||
|
||||
@@ -1 +1 @@
|
||||
a289a6b5e76e2ac19ac91ec28b641c358d2fcf10
|
||||
a597b4cd0a240dd08b9f9f2e1722d4a28bcc6754
|
||||
@@ -24,6 +24,9 @@ namespace MonoTests.System.Net
|
||||
public class HttpWebResponseTest
|
||||
{
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void CharacterSet_Disposed ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -52,6 +55,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Close_Disposed ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -71,6 +77,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void ContentEncoding_Disposed ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -99,6 +108,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void ContentLength_Disposed ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -119,6 +131,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void ContentType_Disposed ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -147,6 +162,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Cookies_Disposed ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -185,6 +203,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void GetResponseHeader_Disposed ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -213,6 +234,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void GetResponseStream_Disposed ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -241,6 +265,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Headers_Disposed ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -268,6 +295,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void LastModified_Disposed ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -296,6 +326,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Method_Disposed ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -324,6 +357,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void ProtocolVersion_Disposed ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -352,6 +388,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void ResponseUri_Disposed ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -380,6 +419,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Server_Disposed ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -408,6 +450,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void StatusCode_Disposed ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -428,6 +473,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void StatusDescription_Disposed ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -479,6 +527,9 @@ namespace MonoTests.System.Net
|
||||
public class HttpResponseStreamTest
|
||||
{
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void BeginRead_Buffer_Null ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -528,6 +579,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void BeginWrite ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -588,6 +642,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void CanSeek ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -615,6 +672,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test] // bug #324182
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void CanTimeout ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -642,6 +702,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void CanWrite ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -669,6 +732,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Read ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -706,6 +772,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Read_Buffer_Null ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -755,6 +824,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Read_Count_Negative ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -805,6 +877,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Read_Count_Overflow ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -855,6 +930,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Read_Offset_Negative ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -905,6 +983,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Read_Offset_Overflow ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -1019,6 +1100,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void ReadTimeout ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -1046,6 +1130,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Write ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
@@ -1078,6 +1165,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void WriteTimeout ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Security;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
@@ -99,6 +100,21 @@ namespace MonoTests.System.Net {
|
||||
nc = new NetworkCredential ("user", "********", "dom");
|
||||
CheckCustom (nc);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecipherSecureString ()
|
||||
{
|
||||
// many code snippets suggest using the following to get the decrypted string from a SecureString
|
||||
var ss = new SecureString ();
|
||||
ss.AppendChar('h');
|
||||
ss.AppendChar('e');
|
||||
ss.AppendChar('l');
|
||||
ss.AppendChar('l');
|
||||
ss.AppendChar('o');
|
||||
|
||||
string plain = new NetworkCredential (string.Empty, ss).Password;
|
||||
Assert.AreEqual ("hello", plain);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,10 @@ public class ServicePointManagerTest
|
||||
[SetUp]
|
||||
public void GetReady ()
|
||||
{
|
||||
#if !FEATURE_NO_BSD_SOCKETS
|
||||
maxIdle = ServicePointManager.MaxServicePointIdleTime;
|
||||
ServicePointManager.MaxServicePointIdleTime = 10;
|
||||
#endif
|
||||
googleUri = new Uri ("http://www.google.com");
|
||||
yahooUri = new Uri ("http://www.yahoo.com");
|
||||
apacheUri = new Uri ("http://www.apache.org");
|
||||
@@ -39,7 +41,9 @@ public class ServicePointManagerTest
|
||||
[TearDown]
|
||||
public void Finish ()
|
||||
{
|
||||
#if !FEATURE_NO_BSD_SOCKETS
|
||||
ServicePointManager.MaxServicePointIdleTime = maxIdle;
|
||||
#endif
|
||||
}
|
||||
|
||||
[Test, ExpectedException (typeof (InvalidOperationException))]
|
||||
@@ -82,12 +86,15 @@ public class ServicePointManagerTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void FindServicePoint ()
|
||||
{
|
||||
ServicePointManager.MaxServicePoints = 0;
|
||||
ServicePoint sp = ServicePointManager.FindServicePoint (googleUri, new WebProxy (apacheUri));
|
||||
Assert.AreEqual (apacheUri, sp.Address, "#1");
|
||||
#if NET_2_1 && !MONODROID
|
||||
#if MOBILE
|
||||
Assert.AreEqual (10, sp.ConnectionLimit, "#2");
|
||||
#else
|
||||
Assert.AreEqual (2, sp.ConnectionLimit, "#2");
|
||||
|
||||
@@ -13,7 +13,7 @@ using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
|
||||
namespace MonoTests.System.Net
|
||||
@@ -23,6 +23,8 @@ namespace MonoTests.System.Net
|
||||
public class ServicePointTest
|
||||
{
|
||||
static private int max;
|
||||
|
||||
#if !FEATURE_NO_BSD_SOCKETS
|
||||
[SetUp]
|
||||
public void SaveMax () {
|
||||
max = ServicePointManager.MaxServicePoints;
|
||||
@@ -33,6 +35,7 @@ public class ServicePointTest
|
||||
public void RestoreMax () {
|
||||
ServicePointManager.MaxServicePoints = max;
|
||||
}
|
||||
#endif
|
||||
|
||||
[Test]
|
||||
[Category ("InetAccess")]
|
||||
@@ -54,13 +57,13 @@ public class ServicePointTest
|
||||
HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://www.google.com");
|
||||
HttpWebResponse res = (HttpWebResponse) req.GetResponse ();
|
||||
|
||||
#if FOUND_SOME_OTHER_URL
|
||||
// URL is no longer found, disabled the test until a more reliable URL is found :P
|
||||
#if FOUND_SOME_OTHER_URL
|
||||
// URL is no longer found, disabled the test until a more reliable URL is found :P
|
||||
//WriteServicePoint ("google after getting a response", google);
|
||||
ServicePoint google2 = ServicePointManager.FindServicePoint (new Uri ("http://www.google.com/dilbert.html"));
|
||||
Assert.AreEqual (google, google2, "#equals");
|
||||
res.Close ();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// in both instances property CurrentConnections is 0 according to ms.net.
|
||||
// let's see what it says when we do async operations...
|
||||
@@ -87,8 +90,8 @@ public class ServicePointTest
|
||||
//Console.WriteLine ("ContentLength: " + res2.ContentLength);
|
||||
res2.Close ();
|
||||
|
||||
ServicePoint sp2;
|
||||
#if FOUND_SOME_OTHER_URL
|
||||
ServicePoint sp2;
|
||||
#if FOUND_SOME_OTHER_URL
|
||||
// unless of course some buffering is taking place.. let's check
|
||||
Uri uri2 = new Uri ("http://freedesktop.org/Software/pkgconfig/releases/pkgconfig-0.15.0.tar.gz");
|
||||
sp2 = ServicePointManager.FindServicePoint (uri2);
|
||||
@@ -102,7 +105,7 @@ public class ServicePointTest
|
||||
// and so it shows
|
||||
//Console.WriteLine ("ContentLength: " + res2.ContentLength);
|
||||
res2.Close ();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// what's the limit of the cache?
|
||||
@@ -154,7 +157,7 @@ public class ServicePointTest
|
||||
|
||||
[Test]
|
||||
[Category ("InetAccess")]
|
||||
[Category ("AndroidNotWorking")] // #A1 fails
|
||||
[Category ("AndroidNotWorking")] // #A1 fails
|
||||
public void EndPointBind ()
|
||||
{
|
||||
Uri uri = new Uri ("http://www.go-mono.com/");
|
||||
@@ -189,6 +192,10 @@ public class ServicePointTest
|
||||
}
|
||||
|
||||
[Test] //Covers #19823
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
// This test uses HttpWebRequest
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void CloseConnectionGroupConcurency ()
|
||||
{
|
||||
// Try with multiple service points
|
||||
@@ -206,36 +213,37 @@ public class ServicePointTest
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void DnsRefreshTimeout ()
|
||||
{
|
||||
const int dnsRefreshTimeout = 2000;
|
||||
|
||||
ServicePoint sp;
|
||||
IPHostEntry host0, host1, host2;
|
||||
Uri uri;
|
||||
PropertyInfo hostEntryProperty;
|
||||
|
||||
ServicePointManager.DnsRefreshTimeout = dnsRefreshTimeout;
|
||||
|
||||
uri = new Uri ("http://localhost/");
|
||||
sp = ServicePointManager.FindServicePoint (uri);
|
||||
|
||||
hostEntryProperty = typeof (ServicePoint).GetProperty ("HostEntry", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
host0 = hostEntryProperty.GetValue (sp, null) as IPHostEntry;
|
||||
host1 = hostEntryProperty.GetValue (sp, null) as IPHostEntry;
|
||||
|
||||
Assert.AreSame (host0, host1, "HostEntry should result in the same IPHostEntry object.");
|
||||
|
||||
Thread.Sleep (dnsRefreshTimeout * 2);
|
||||
host2 = hostEntryProperty.GetValue (sp, null) as IPHostEntry;
|
||||
|
||||
Assert.AreNotSame(host0, host2, "HostEntry should result in a new IPHostEntry " +
|
||||
"object when DnsRefreshTimeout is reached.");
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
[Category ("RequiresBSDSockets")] // Tests internals, so it doesn't make sense to assert that PlatformNotSupportedExceptions are thrown.
|
||||
public void DnsRefreshTimeout ()
|
||||
{
|
||||
const int dnsRefreshTimeout = 2000;
|
||||
|
||||
ServicePoint sp;
|
||||
IPHostEntry host0, host1, host2;
|
||||
Uri uri;
|
||||
PropertyInfo hostEntryProperty;
|
||||
|
||||
ServicePointManager.DnsRefreshTimeout = dnsRefreshTimeout;
|
||||
|
||||
uri = new Uri ("http://localhost/");
|
||||
sp = ServicePointManager.FindServicePoint (uri);
|
||||
|
||||
hostEntryProperty = typeof (ServicePoint).GetProperty ("HostEntry", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
host0 = hostEntryProperty.GetValue (sp, null) as IPHostEntry;
|
||||
host1 = hostEntryProperty.GetValue (sp, null) as IPHostEntry;
|
||||
|
||||
Assert.AreSame (host0, host1, "HostEntry should result in the same IPHostEntry object.");
|
||||
|
||||
Thread.Sleep (dnsRefreshTimeout * 2);
|
||||
host2 = hostEntryProperty.GetValue (sp, null) as IPHostEntry;
|
||||
|
||||
Assert.AreNotSame(host0, host2, "HostEntry should result in a new IPHostEntry " +
|
||||
"object when DnsRefreshTimeout is reached.");
|
||||
}
|
||||
|
||||
// Debug code not used now, but could be useful later
|
||||
/*
|
||||
private void WriteServicePoint (string label, ServicePoint sp)
|
||||
|
||||
@@ -1418,6 +1418,9 @@ namespace MonoTests.System.Net
|
||||
|
||||
[Test]
|
||||
[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void UploadValues1 ()
|
||||
{
|
||||
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
|
||||
@@ -1668,6 +1671,10 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
// We throw a PlatformNotSupportedException deeper, which is caught and re-thrown as WebException
|
||||
[ExpectedException (typeof (WebException))]
|
||||
#endif
|
||||
public void GetWebRequestOverriding ()
|
||||
{
|
||||
GetWebRequestOverridingTestClass testObject = new GetWebRequestOverridingTestClass ();
|
||||
@@ -1771,6 +1778,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void DefaultProxy ()
|
||||
{
|
||||
WebClient wc = new WebClient ();
|
||||
@@ -1780,9 +1790,11 @@ namespace MonoTests.System.Net
|
||||
Assert.AreSame (wc.Proxy, WebRequest.DefaultWebProxy);
|
||||
}
|
||||
|
||||
#if NET_4_5
|
||||
[Test]
|
||||
[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void UploadStringAsyncCancelEvent ()
|
||||
{
|
||||
UploadAsyncCancelEventTest (9301, (webClient, uri, cancelEvent) =>
|
||||
@@ -1800,6 +1812,9 @@ namespace MonoTests.System.Net
|
||||
|
||||
[Test]
|
||||
[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void UploadDataAsyncCancelEvent ()
|
||||
{
|
||||
UploadAsyncCancelEventTest (9302, (webClient, uri, cancelEvent) =>
|
||||
@@ -1816,6 +1831,9 @@ namespace MonoTests.System.Net
|
||||
|
||||
[Test]
|
||||
[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void UploadValuesAsyncCancelEvent ()
|
||||
{
|
||||
UploadAsyncCancelEventTest (9303, (webClient, uri, cancelEvent) =>
|
||||
@@ -1832,6 +1850,9 @@ namespace MonoTests.System.Net
|
||||
|
||||
[Test]
|
||||
[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void UploadFileAsyncCancelEvent ()
|
||||
{
|
||||
UploadAsyncCancelEventTest (9304,(webClient, uri, cancelEvent) =>
|
||||
@@ -1851,6 +1872,9 @@ namespace MonoTests.System.Net
|
||||
|
||||
[Test]
|
||||
[Category ("AndroidNotWorking")] // Test suite hangs if the tests runs as part of the entire BCL suite. Works when only this fixture is ran
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void UploadFileAsyncContentType ()
|
||||
{
|
||||
var port = NetworkHelpers.FindFreePort ();
|
||||
@@ -1872,7 +1896,6 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
listener.Close ();
|
||||
}
|
||||
#endif
|
||||
|
||||
public void UploadAsyncCancelEventTest (int port, Action<WebClient, Uri, EventWaitHandle> uploadAction)
|
||||
{
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
// 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_4_5
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
@@ -276,4 +275,3 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -124,6 +124,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void AddRestricted ()
|
||||
{
|
||||
col = CreateRestrictedHeaders ();
|
||||
@@ -236,6 +239,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void RemoveRestricted ()
|
||||
{
|
||||
col = CreateRestrictedHeaders ();
|
||||
|
||||
@@ -123,11 +123,6 @@ namespace MonoTests.System.Net
|
||||
Assert.AreEqual (1, p.BypassList.Length, "#4");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetProxy ()
|
||||
{
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsByPassed ()
|
||||
{
|
||||
|
||||
@@ -11,8 +11,10 @@
|
||||
//
|
||||
|
||||
using NUnit.Framework;
|
||||
using MonoTests.Helpers;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Collections;
|
||||
using System.Runtime.Serialization;
|
||||
using Socks = System.Net.Sockets;
|
||||
@@ -191,6 +193,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void All ()
|
||||
{
|
||||
WebRequest req = WebRequest.Create ("http://www.contoso.com");
|
||||
@@ -262,6 +267,9 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void DefaultWebProxy ()
|
||||
{
|
||||
WebProxy proxy = new WebProxy ("proxy.intern.com", 83);
|
||||
@@ -316,14 +324,18 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test] //BNC#323452
|
||||
// Throws exception with Status == Timeout. The same code behaves as the test expects when run from a regular app.
|
||||
// Might be an issue with the test suite. To investigate.
|
||||
[Category("AndroidNotWorking")]
|
||||
// Throws exception with Status == Timeout. The same code behaves as the test expects when run from a regular app.
|
||||
// Might be an issue with the test suite. To investigate.
|
||||
[Category("AndroidNotWorking")]
|
||||
public void TestFailedConnection ()
|
||||
{
|
||||
try {
|
||||
WebRequest.Create ("http://127.0.0.1:0/non-existant.txt").GetResponse ();
|
||||
Assert.Fail ("Should have raised an exception");
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
} catch (PlatformNotSupportedException) {
|
||||
// Expected
|
||||
#endif
|
||||
} catch (Exception e) {
|
||||
Assert.IsTrue (e is WebException, "Got " + e.GetType ().Name + ": " + e.Message);
|
||||
//#if NET_2_0 e.Message == "Unable to connect to the remote server"
|
||||
@@ -340,7 +352,7 @@ namespace MonoTests.System.Net {
|
||||
}
|
||||
|
||||
[Test] //BNC#323452
|
||||
[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
|
||||
[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
|
||||
public void TestFailedResolution ()
|
||||
{
|
||||
try {
|
||||
@@ -357,6 +369,10 @@ namespace MonoTests.System.Net {
|
||||
Assert.Ignore ("Misbehaving DNS server.");
|
||||
|
||||
Assert.Fail ("Should have raised an exception");
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
} catch (PlatformNotSupportedException) {
|
||||
// Expected
|
||||
#endif
|
||||
} catch (Exception e) {
|
||||
Assert.IsTrue (e is WebException);
|
||||
//#if NET_2_0 e.Message == "The underlying connection was closed: The remote name could not be resolved."
|
||||
@@ -410,6 +426,55 @@ namespace MonoTests.System.Net {
|
||||
{
|
||||
internal TestWebRequest3 () { }
|
||||
}
|
||||
|
||||
[Test] // Covers #41477
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void TestReceiveCancelation ()
|
||||
{
|
||||
var uri = "http://localhost:" + NetworkHelpers.FindFreePort () + "/";
|
||||
|
||||
HttpListener listener = new HttpListener ();
|
||||
listener.Prefixes.Add (uri);
|
||||
listener.Start ();
|
||||
|
||||
try {
|
||||
for (var i = 0; i < 10; i++) {
|
||||
var request = WebRequest.CreateHttp (uri);
|
||||
request.Method = "GET";
|
||||
|
||||
var tokenSource = new CancellationTokenSource ();
|
||||
tokenSource.Token.Register(() => request.Abort ());
|
||||
|
||||
var responseTask = request.GetResponseAsync ();
|
||||
|
||||
var context = listener.GetContext ();
|
||||
byte[] outBuffer = new byte[8 * 1024];
|
||||
context.Response.OutputStream.WriteAsync (outBuffer, 0, outBuffer.Length);
|
||||
|
||||
Assert.IsTrue (responseTask.Wait (1000), "Timeout #1");
|
||||
|
||||
WebResponse response = responseTask.Result;
|
||||
var stream = response.GetResponseStream ();
|
||||
|
||||
byte[] buffer = new byte[8 * 1024];
|
||||
var taskRead = stream.ReadAsync (buffer, 0, buffer.Length, tokenSource.Token);
|
||||
|
||||
tokenSource.Cancel ();
|
||||
|
||||
Assert.IsTrue (taskRead.Wait (1000), "Timeout #2");
|
||||
|
||||
var byteRead = taskRead.Result;
|
||||
}
|
||||
} catch (AggregateException ex) {
|
||||
var webEx = ex.InnerException as WebException;
|
||||
Assert.IsNotNull(webEx, "Inner exception is not a WebException");
|
||||
Assert.AreEqual (webEx.Status, WebExceptionStatus.RequestCanceled);
|
||||
}
|
||||
|
||||
listener.Close ();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user