You've already forked linux-packaging-mono
Imported Upstream version 3.8.0
Former-commit-id: 6a76a29bd07d86e57c6c8da45c65ed5447d38a61
This commit is contained in:
@@ -550,8 +550,12 @@ namespace System.Net.Mail {
|
||||
MailAddress from = message.From;
|
||||
if (from == null)
|
||||
from = defaultFrom;
|
||||
|
||||
SendHeader (HeaderName.Date, DateTime.Now.ToString ("ddd, dd MMM yyyy HH':'mm':'ss zzz", DateTimeFormatInfo.InvariantInfo));
|
||||
|
||||
string dt = DateTime.Now.ToString("ddd, dd MMM yyyy HH':'mm':'ss zzz", DateTimeFormatInfo.InvariantInfo);
|
||||
// remove ':' from time zone offset (e.g. from "+01:00")
|
||||
dt = dt.Remove(dt.Length - 3, 1);
|
||||
SendHeader(HeaderName.Date, dt);
|
||||
|
||||
SendHeader (HeaderName.From, EncodeAddress(from));
|
||||
SendHeader (HeaderName.To, EncodeAddresses(message.To));
|
||||
if (message.CC.Count > 0)
|
||||
@@ -762,7 +766,7 @@ namespace System.Net.Mail {
|
||||
|
||||
static void SendMailAsyncCompletedHandler (TaskCompletionSource<object> source, AsyncCompletedEventArgs e, SendCompletedEventHandler handler, SmtpClient client)
|
||||
{
|
||||
if (handler != e.UserState)
|
||||
if ((object) handler != e.UserState)
|
||||
return;
|
||||
|
||||
client.SendCompleted -= handler;
|
||||
|
||||
@@ -79,4 +79,23 @@ namespace System.Net.NetworkInformation {
|
||||
LOOPBACK = 0x18,
|
||||
FDDI = 0xf
|
||||
}
|
||||
|
||||
internal enum MacOsInterfaceFlags {
|
||||
IFF_UP = 0x1, /* interface is up */
|
||||
IFF_BROADCAST = 0x2, /* broadcast address valid */
|
||||
IFF_DEBUG = 0x4, /* turn on debugging */
|
||||
IFF_LOOPBACK = 0x8, /* is a loopback net */
|
||||
IFF_POINTOPOINT = 0x10, /* interface is point-to-point link */
|
||||
IFF_NOTRAILERS = 0x20, /* avoid use of trailers */
|
||||
IFF_RUNNING = 0x40, /* resources allocated */
|
||||
IFF_NOARP = 0x80, /* no address resolution protocol */
|
||||
IFF_PROMISC = 0x100, /* receive all packets */
|
||||
IFF_ALLMULTI = 0x200, /* receive all multicast packets */
|
||||
IFF_OACTIVE = 0x400, /* transmission in progress */
|
||||
IFF_SIMPLEX = 0x800, /* can't hear own transmissions */
|
||||
IFF_LINK0 = 0x1000, /* per link layer defined bit */
|
||||
IFF_LINK1 = 0x2000, /* per link layer defined bit */
|
||||
IFF_LINK2 = 0x4000, /* per link layer defined bit */
|
||||
IFF_MULTICAST = 0x8000 /* supports multicast */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -446,6 +446,8 @@ namespace System.Net.NetworkInformation {
|
||||
const int AF_INET = 2;
|
||||
const int AF_INET6 = 30;
|
||||
const int AF_LINK = 18;
|
||||
|
||||
private uint _ifa_flags;
|
||||
|
||||
public static NetworkInterface [] ImplGetAllNetworkInterfaces ()
|
||||
{
|
||||
@@ -465,6 +467,7 @@ namespace System.Net.NetworkInformation {
|
||||
NetworkInterfaceType type = NetworkInterfaceType.Unknown;
|
||||
|
||||
if (addr.ifa_addr != IntPtr.Zero) {
|
||||
// optain IPAddress
|
||||
MacOsStructs.sockaddr sockaddr = (MacOsStructs.sockaddr) Marshal.PtrToStructure (addr.ifa_addr, typeof (MacOsStructs.sockaddr));
|
||||
|
||||
if (sockaddr.sa_family == AF_INET6) {
|
||||
@@ -478,7 +481,10 @@ namespace System.Net.NetworkInformation {
|
||||
sockaddrdl.Read (addr.ifa_addr);
|
||||
|
||||
macAddress = new byte [(int) sockaddrdl.sdl_alen];
|
||||
// copy mac address from sdl_data field starting at last index pos of interface name into array macaddress, starting
|
||||
// at index 0
|
||||
Array.Copy (sockaddrdl.sdl_data, sockaddrdl.sdl_nlen, macAddress, 0, Math.Min (macAddress.Length, sockaddrdl.sdl_data.Length - sockaddrdl.sdl_nlen));
|
||||
|
||||
index = sockaddrdl.sdl_index;
|
||||
|
||||
int hwtype = (int) sockaddrdl.sdl_type;
|
||||
@@ -515,14 +521,17 @@ namespace System.Net.NetworkInformation {
|
||||
|
||||
MacOsNetworkInterface iface = null;
|
||||
|
||||
// create interface if not already present
|
||||
if (!interfaces.TryGetValue (name, out iface)) {
|
||||
iface = new MacOsNetworkInterface (name);
|
||||
iface = new MacOsNetworkInterface (name, addr.ifa_flags);
|
||||
interfaces.Add (name, iface);
|
||||
}
|
||||
|
||||
// if a new address has been found, add it
|
||||
if (!address.Equals (IPAddress.None))
|
||||
iface.AddAddress (address);
|
||||
|
||||
// set link layer info, if iface has macaddress or is loopback device
|
||||
if (macAddress != null || type == NetworkInterfaceType.Loopback)
|
||||
iface.SetLinkLayerInfo (index, macAddress, type);
|
||||
|
||||
@@ -541,9 +550,10 @@ namespace System.Net.NetworkInformation {
|
||||
return result;
|
||||
}
|
||||
|
||||
MacOsNetworkInterface (string name)
|
||||
MacOsNetworkInterface (string name, uint ifa_flags)
|
||||
: base (name)
|
||||
{
|
||||
_ifa_flags = ifa_flags;
|
||||
}
|
||||
|
||||
public override IPInterfaceProperties GetIPProperties ()
|
||||
@@ -562,13 +572,16 @@ namespace System.Net.NetworkInformation {
|
||||
|
||||
public override OperationalStatus OperationalStatus {
|
||||
get {
|
||||
if(((MacOsInterfaceFlags)_ifa_flags & MacOsInterfaceFlags.IFF_UP) == MacOsInterfaceFlags.IFF_UP){
|
||||
return OperationalStatus.Up;
|
||||
}
|
||||
return OperationalStatus.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool SupportsMulticast {
|
||||
get {
|
||||
return false;
|
||||
return ((MacOsInterfaceFlags)_ifa_flags & MacOsInterfaceFlags.IFF_MULTICAST) == MacOsInterfaceFlags.IFF_MULTICAST;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ namespace System.Net.Sockets
|
||||
else if (op == SocketAsyncOperation.Disconnect)
|
||||
args.DisconnectCallback (ares);
|
||||
else if (op == SocketAsyncOperation.Connect)
|
||||
args.ConnectCallback ();
|
||||
args.ConnectCallback (ares);
|
||||
/*
|
||||
else if (op == Socket.SocketOperation.ReceiveMessageFrom)
|
||||
else if (op == Socket.SocketOperation.SendPackets)
|
||||
@@ -254,10 +254,12 @@ namespace System.Net.Sockets
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectCallback ()
|
||||
void ConnectCallback (IAsyncResult ares)
|
||||
{
|
||||
try {
|
||||
SocketError = (SocketError) Worker.result.error;
|
||||
curSocket.EndConnect (ares);
|
||||
} catch (SocketException se) {
|
||||
SocketError = se.SocketErrorCode;
|
||||
} finally {
|
||||
OnCompleted (this);
|
||||
}
|
||||
|
||||
@@ -1253,7 +1253,7 @@ namespace System.Net.Sockets {
|
||||
throw new SocketException (error);
|
||||
}
|
||||
|
||||
if (socket_type == SocketType.Dgram && (ep.Address.Equals (IPAddress.Any) || ep.Address.Equals (IPAddress.IPv6Any)))
|
||||
if (socket_type == SocketType.Dgram && ep != null && (ep.Address.Equals (IPAddress.Any) || ep.Address.Equals (IPAddress.IPv6Any)))
|
||||
connected = false;
|
||||
else
|
||||
connected = true;
|
||||
|
||||
@@ -196,7 +196,30 @@ namespace System.Net.WebSockets
|
||||
underlyingSocket.Send (sendBuffer, 0, buffer.Count + headerLength, SocketFlags.None);
|
||||
});
|
||||
}
|
||||
|
||||
const int messageTypeText = 1;
|
||||
const int messageTypeBinary = 2;
|
||||
const int messageTypeClose = 8;
|
||||
|
||||
static WebSocketMessageType WireToMessageType (byte msgType)
|
||||
{
|
||||
|
||||
if (msgType == messageTypeText)
|
||||
return WebSocketMessageType.Text;
|
||||
if (msgType == messageTypeBinary)
|
||||
return WebSocketMessageType.Binary;
|
||||
return WebSocketMessageType.Close;
|
||||
}
|
||||
|
||||
static byte MessageTypeToWire (WebSocketMessageType type)
|
||||
{
|
||||
if (type == WebSocketMessageType.Text)
|
||||
return messageTypeText;
|
||||
if (type == WebSocketMessageType.Binary)
|
||||
return messageTypeBinary;
|
||||
return messageTypeClose;
|
||||
}
|
||||
|
||||
public override Task<WebSocketReceiveResult> ReceiveAsync (ArraySegment<byte> buffer, CancellationToken cancellationToken)
|
||||
{
|
||||
EnsureWebSocketConnected ();
|
||||
@@ -208,7 +231,7 @@ namespace System.Net.WebSockets
|
||||
var isLast = (headerBuffer[0] >> 7) > 0;
|
||||
var isMasked = (headerBuffer[1] >> 7) > 0;
|
||||
int mask = 0;
|
||||
var type = (WebSocketMessageType)(headerBuffer[0] & 0xF);
|
||||
var type = WireToMessageType ((byte)(headerBuffer[0] & 0xF));
|
||||
long length = headerBuffer[1] & 0x7F;
|
||||
int offset = 0;
|
||||
if (length == 126) {
|
||||
@@ -279,7 +302,7 @@ namespace System.Net.WebSockets
|
||||
|
||||
int WriteHeader (WebSocketMessageType type, ArraySegment<byte> buffer, bool endOfMessage)
|
||||
{
|
||||
var opCode = (byte)type;
|
||||
var opCode = MessageTypeToWire (type);
|
||||
var length = buffer.Count;
|
||||
|
||||
headerBuffer[0] = (byte)(opCode | (endOfMessage ? 0 : 0x80));
|
||||
|
||||
@@ -35,9 +35,9 @@ namespace System.Net.WebSockets
|
||||
{
|
||||
public enum WebSocketMessageType
|
||||
{
|
||||
Text = 1,
|
||||
Binary = 2,
|
||||
Close = 8
|
||||
Text = 0,
|
||||
Binary = 1,
|
||||
Close = 2
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace System.Net
|
||||
{
|
||||
enum State {
|
||||
None,
|
||||
PartialSize,
|
||||
Body,
|
||||
BodyFinished,
|
||||
Trailer
|
||||
@@ -139,9 +140,9 @@ namespace System.Net
|
||||
|
||||
void InternalWrite (byte [] buffer, ref int offset, int size)
|
||||
{
|
||||
if (state == State.None) {
|
||||
if (state == State.None || state == State.PartialSize) {
|
||||
state = GetChunkSize (buffer, ref offset, size);
|
||||
if (state == State.None)
|
||||
if (state == State.PartialSize)
|
||||
return;
|
||||
|
||||
saved.Length = 0;
|
||||
@@ -262,7 +263,7 @@ namespace System.Net
|
||||
ThrowProtocolViolation ("Cannot parse chunk size.");
|
||||
}
|
||||
|
||||
return State.None;
|
||||
return State.PartialSize;
|
||||
}
|
||||
|
||||
chunkRead = 0;
|
||||
|
||||
@@ -181,7 +181,7 @@ namespace System.Net
|
||||
}
|
||||
|
||||
value = header.Substring (beginQ, pos - beginQ);
|
||||
pos += 2;
|
||||
pos += useQuote ? 2 : 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1405,10 +1405,12 @@ namespace System.Net
|
||||
string data2 = UploadString ((Uri) args [0], (string) args [1], (string) args [2]);
|
||||
OnUploadStringCompleted (
|
||||
new UploadStringCompletedEventArgs (data2, null, false, args [3]));
|
||||
} catch (ThreadInterruptedException){
|
||||
OnUploadStringCompleted (
|
||||
new UploadStringCompletedEventArgs (null, null, true, args [3]));
|
||||
} catch (Exception e){
|
||||
if (e is ThreadInterruptedException || e.InnerException is ThreadInterruptedException) {
|
||||
OnUploadStringCompleted (
|
||||
new UploadStringCompletedEventArgs (null, null, true, args [3]));
|
||||
return;
|
||||
}
|
||||
OnUploadStringCompleted (
|
||||
new UploadStringCompletedEventArgs (null, e, false, args [3]));
|
||||
}});
|
||||
|
||||
@@ -356,8 +356,6 @@ namespace System.Net
|
||||
|
||||
byte [] buffer = new byte [1024];
|
||||
MemoryStream ms = new MemoryStream ();
|
||||
bool gotStatus = false;
|
||||
WebHeaderCollection headers = null;
|
||||
|
||||
while (true) {
|
||||
int n = stream.Read (buffer, 0, 1024);
|
||||
@@ -369,7 +367,8 @@ namespace System.Net
|
||||
ms.Write (buffer, 0, n);
|
||||
int start = 0;
|
||||
string str = null;
|
||||
headers = new WebHeaderCollection ();
|
||||
bool gotStatus = false;
|
||||
WebHeaderCollection headers = new WebHeaderCollection ();
|
||||
while (ReadLine (ms.GetBuffer (), ref start, (int) ms.Length, ref str)) {
|
||||
if (str == null) {
|
||||
int contentLen = 0;
|
||||
@@ -399,13 +398,22 @@ namespace System.Net
|
||||
continue;
|
||||
}
|
||||
|
||||
int spaceidx = str.IndexOf (' ');
|
||||
if (spaceidx == -1) {
|
||||
string[] parts = str.Split (' ');
|
||||
if (parts.Length < 2) {
|
||||
HandleError (WebExceptionStatus.ServerProtocolViolation, null, "ReadHeaders2");
|
||||
return null;
|
||||
}
|
||||
|
||||
status = (int) UInt32.Parse (str.Substring (spaceidx + 1, 3));
|
||||
if (String.Compare (parts [0], "HTTP/1.1", true) == 0)
|
||||
Data.ProxyVersion = HttpVersion.Version11;
|
||||
else if (String.Compare (parts [0], "HTTP/1.0", true) == 0)
|
||||
Data.ProxyVersion = HttpVersion.Version10;
|
||||
else {
|
||||
HandleError (WebExceptionStatus.ServerProtocolViolation, null, "ReadHeaders2");
|
||||
return null;
|
||||
}
|
||||
|
||||
status = (int)UInt32.Parse (parts [1]);
|
||||
gotStatus = true;
|
||||
}
|
||||
}
|
||||
@@ -841,6 +849,8 @@ namespace System.Net
|
||||
string header = (sPoint.UsesProxy) ? "Proxy-Connection" : "Connection";
|
||||
string cncHeader = (Data.Headers != null) ? Data.Headers [header] : null;
|
||||
bool keepAlive = (Data.Version == HttpVersion.Version11 && this.keepAlive);
|
||||
if (Data.ProxyVersion != null && Data.ProxyVersion != HttpVersion.Version11)
|
||||
keepAlive = false;
|
||||
if (cncHeader != null) {
|
||||
cncHeader = cncHeader.ToLower ();
|
||||
keepAlive = (this.keepAlive && cncHeader.IndexOf ("keep-alive", StringComparison.Ordinal) != -1);
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace System.Net
|
||||
public string StatusDescription;
|
||||
public WebHeaderCollection Headers;
|
||||
public Version Version;
|
||||
public Version ProxyVersion;
|
||||
public Stream stream;
|
||||
public string[] Challenge;
|
||||
ReadState _readState;
|
||||
|
||||
@@ -428,7 +428,19 @@ namespace System.Security.Cryptography.X509Certificates {
|
||||
|
||||
private MX.X509Certificate ImportPkcs12 (byte[] rawData, string password)
|
||||
{
|
||||
MX.PKCS12 pfx = (password == null) ? new MX.PKCS12 (rawData) : new MX.PKCS12 (rawData, password);
|
||||
MX.PKCS12 pfx = null;
|
||||
if (string.IsNullOrEmpty (password)) {
|
||||
try {
|
||||
// Support both unencrypted PKCS#12..
|
||||
pfx = new MX.PKCS12 (rawData, (string)null);
|
||||
} catch {
|
||||
// ..and PKCS#12 encrypted with an empty password
|
||||
pfx = new MX.PKCS12 (rawData, string.Empty);
|
||||
}
|
||||
} else {
|
||||
pfx = new MX.PKCS12 (rawData, password);
|
||||
}
|
||||
|
||||
if (pfx.Certificates.Count == 0) {
|
||||
// no certificate was found
|
||||
return null;
|
||||
|
||||
@@ -246,6 +246,7 @@ System.Net.Sockets/TcpClientTest.cs
|
||||
System.Net.Sockets/TcpListenerTest.cs
|
||||
System.Net.Sockets/SocketTest.cs
|
||||
System.Net.Sockets/SocketAsyncEventArgsTest.cs
|
||||
System.Net.Sockets/SocketConnectAsyncTest.cs
|
||||
System.Net.Sockets/UdpClientTest.cs
|
||||
System.Net.Sockets/SocketAsyncTest.cs
|
||||
System.Net.Mail/LinkedResourceTest.cs
|
||||
|
||||
@@ -639,6 +639,62 @@ namespace MonoTests.System.ComponentModel
|
||||
|
||||
Assert.AreEqual (1, count, "1");
|
||||
}
|
||||
|
||||
private class Person : INotifyPropertyChanged
|
||||
{
|
||||
private string _lastName;
|
||||
private string _firstName;
|
||||
|
||||
public string FirstName {
|
||||
get { return _firstName; }
|
||||
set {
|
||||
_firstName = value;
|
||||
OnPropertyChanged ("FirstName"); // string matches property name
|
||||
}
|
||||
}
|
||||
|
||||
public string LastName {
|
||||
get { return _lastName; }
|
||||
set {
|
||||
_lastName = value;
|
||||
OnPropertyChanged ("Apepe"); // string doesn't match property name
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected virtual void OnPropertyChanged (string propertyName = null)
|
||||
{
|
||||
PropertyChangedEventHandler handler = PropertyChanged;
|
||||
if (handler != null)
|
||||
handler (this, new PropertyChangedEventArgs (propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
[Test] // https://bugzilla.xamarin.com/show_bug.cgi?id=20672
|
||||
public void Bug20672 ()
|
||||
{
|
||||
string changedPropertyName = string.Empty;
|
||||
bool isEventRaised = false;
|
||||
bool? hasPropertyDescriptor = false;
|
||||
|
||||
var persons = new BindingList<Person>();
|
||||
persons.Add (new Person() { FirstName = "Stefaan", LastName = "de Vogelaere" });
|
||||
persons.Add (new Person() { FirstName = "Christophe", LastName = "De Langhe" });
|
||||
persons.ListChanged += (object sender, ListChangedEventArgs e) => {
|
||||
isEventRaised = true;
|
||||
hasPropertyDescriptor = e.PropertyDescriptor != null;
|
||||
};
|
||||
|
||||
//if the OnPropertyChanged string matches a valid property name, PropertyDescriptor should be generated
|
||||
persons[0].FirstName = "Stefan";
|
||||
Assert.IsTrue (isEventRaised);
|
||||
Assert.IsTrue ((bool) hasPropertyDescriptor, "#1");
|
||||
|
||||
//if the OnPropertyChanged string doesn't match a valid property name, no PropertyDescriptor should be generated
|
||||
persons[0].LastName = "de le Vulu";
|
||||
Assert.IsFalse ((bool) hasPropertyDescriptor, "#2");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Threading;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System.Net.Sockets
|
||||
{
|
||||
[TestFixture]
|
||||
public class SocketConnectAsyncTest
|
||||
{
|
||||
Socket serverSocket;
|
||||
Socket clientSocket;
|
||||
SocketAsyncEventArgs clientSocketAsyncArgs;
|
||||
ManualResetEvent readyEvent;
|
||||
ManualResetEvent mainEvent;
|
||||
Exception error;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void SetUp ()
|
||||
{
|
||||
readyEvent = new ManualResetEvent (false);
|
||||
mainEvent = new ManualResetEvent (false);
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
public void TearDown ()
|
||||
{
|
||||
readyEvent.Close ();
|
||||
mainEvent.Close ();
|
||||
}
|
||||
|
||||
void StartServer()
|
||||
{
|
||||
readyEvent.Reset();
|
||||
mainEvent.Reset();
|
||||
ThreadPool.QueueUserWorkItem (_ => DoWork ());
|
||||
readyEvent.WaitOne ();
|
||||
}
|
||||
|
||||
void StopServer()
|
||||
{
|
||||
if (serverSocket != null)
|
||||
serverSocket.Close ();
|
||||
}
|
||||
|
||||
void DoWork ()
|
||||
{
|
||||
serverSocket = new Socket (
|
||||
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
serverSocket.Bind (new IPEndPoint (IPAddress.Loopback, 0));
|
||||
serverSocket.Listen (1);
|
||||
|
||||
var async = new SocketAsyncEventArgs ();
|
||||
async.Completed += (s,e) => OnAccepted (e);
|
||||
|
||||
readyEvent.Set ();
|
||||
|
||||
if (!serverSocket.AcceptAsync (async))
|
||||
OnAccepted (async);
|
||||
}
|
||||
|
||||
void OnAccepted (SocketAsyncEventArgs e)
|
||||
{
|
||||
var acceptSocket = e.AcceptSocket;
|
||||
mainEvent.Set ();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category("Test")]
|
||||
public void Connect ()
|
||||
{
|
||||
StartServer();
|
||||
|
||||
EndPoint serverEndpoint = serverSocket.LocalEndPoint;
|
||||
|
||||
var m = new ManualResetEvent (false);
|
||||
var e = new SocketAsyncEventArgs ();
|
||||
|
||||
clientSocket = new Socket (
|
||||
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
clientSocketAsyncArgs = new SocketAsyncEventArgs();
|
||||
clientSocketAsyncArgs.RemoteEndPoint = serverEndpoint;
|
||||
clientSocketAsyncArgs.Completed += (s,o) => {
|
||||
if (o.SocketError != SocketError.Success)
|
||||
error = new SocketException ((int)o.SocketError);
|
||||
m.Set ();
|
||||
};
|
||||
bool res = clientSocket.ConnectAsync(clientSocketAsyncArgs);
|
||||
if (res) {
|
||||
if (!m.WaitOne (1500))
|
||||
throw new TimeoutException ();
|
||||
}
|
||||
|
||||
if (!mainEvent.WaitOne (1500))
|
||||
throw new TimeoutException ();
|
||||
if (error != null)
|
||||
throw error;
|
||||
|
||||
m.Reset ();
|
||||
mainEvent.Reset ();
|
||||
|
||||
StopServer();
|
||||
|
||||
// Try again to non-listening endpoint, expect error
|
||||
|
||||
error = null;
|
||||
clientSocket = new Socket (
|
||||
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
clientSocketAsyncArgs = new SocketAsyncEventArgs ();
|
||||
clientSocketAsyncArgs.RemoteEndPoint = serverEndpoint;
|
||||
clientSocketAsyncArgs.Completed += (s,o) => {
|
||||
if (o.SocketError != SocketError.Success)
|
||||
error = new SocketException ((int)o.SocketError);
|
||||
m.Set ();
|
||||
};
|
||||
res = clientSocket.ConnectAsync (clientSocketAsyncArgs);
|
||||
if (res) {
|
||||
if (!m.WaitOne (1500))
|
||||
throw new TimeoutException ();
|
||||
}
|
||||
|
||||
Assert.IsTrue (error != null, "Connect - no error");
|
||||
SocketException socketException = (SocketException)error;
|
||||
Assert.IsTrue(socketException.ErrorCode == (int)SocketError.ConnectionRefused);
|
||||
|
||||
m.Reset ();
|
||||
mainEvent.Reset ();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
0ae72b4c29ac57ce57fafde17a909f16b88df913
|
||||
b6ddbf164a5e04ef05fc2d35b59923c2f82abef6
|
||||
@@ -74,6 +74,13 @@ namespace MonoTests.System.Net.Sockets {
|
||||
//Assert.AreEqual (32, client.Ttl, "#A:Ttl");
|
||||
#endif
|
||||
|
||||
#if NET_2_0
|
||||
if (!Socket.OSSupportsIPv6)
|
||||
#else
|
||||
if (!Socket.SupportsIPv6)
|
||||
#endif
|
||||
Assert.Ignore ("IPv6 not enabled.");
|
||||
|
||||
client = new MyUdpClient (AddressFamily.InterNetworkV6);
|
||||
s = client.Client;
|
||||
Assert.IsNotNull (s, "#B:Client");
|
||||
@@ -297,6 +304,13 @@ namespace MonoTests.System.Net.Sockets {
|
||||
Assert.AreEqual (AddressFamily.InterNetwork, localEP.AddressFamily, "#A:Client:LocalEndPoint/AddressFamily");
|
||||
}
|
||||
|
||||
#if NET_2_0
|
||||
if (!Socket.OSSupportsIPv6)
|
||||
#else
|
||||
if (!Socket.SupportsIPv6)
|
||||
#endif
|
||||
Assert.Ignore ("IPv6 not enabled.");
|
||||
|
||||
using (MyUdpClient client = new MyUdpClient (IPEndPoint.MaxPort, AddressFamily.InterNetworkV6))
|
||||
{
|
||||
s = client.Client;
|
||||
@@ -656,6 +670,13 @@ namespace MonoTests.System.Net.Sockets {
|
||||
[Test] // JoinMulticastGroup (Int32, IPAddress)
|
||||
public void JoinMulticastGroup2_Socket_Closed ()
|
||||
{
|
||||
#if NET_2_0
|
||||
if (!Socket.OSSupportsIPv6)
|
||||
#else
|
||||
if (!Socket.SupportsIPv6)
|
||||
#endif
|
||||
Assert.Ignore ("IPv6 not enabled.");
|
||||
|
||||
IPAddress mcast_addr = null;
|
||||
|
||||
UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 1234));
|
||||
|
||||
@@ -28,8 +28,8 @@ namespace MonoTests.System.Net
|
||||
[TestFixture]
|
||||
public class DnsTest
|
||||
{
|
||||
private String site1Name = "mono-project.com",
|
||||
site1Dot = "96.126.105.110",
|
||||
private String site1Name = "xamarin.com",
|
||||
site1Dot = "50.19.126.231",
|
||||
site2Name = "info.diku.dk",
|
||||
site2Dot = "130.225.96.4",
|
||||
noneExistingSite = "unlikely.xamarin.com";
|
||||
@@ -44,7 +44,7 @@ namespace MonoTests.System.Net
|
||||
IAsyncResult async = Dns.BeginGetHostByName (site1Name, null, null);
|
||||
IPHostEntry entry = Dns.EndGetHostByName (async);
|
||||
SubTestValidIPHostEntry (entry);
|
||||
Assert.IsTrue (entry.HostName == "www.mono-project.com" || entry.HostName == "mono-project.com");
|
||||
Assert.IsTrue (entry.HostName == "www.xamarin.com" || entry.HostName == "xamarin.com");
|
||||
}
|
||||
|
||||
void GetHostByNameCallback (IAsyncResult ar)
|
||||
@@ -191,7 +191,7 @@ namespace MonoTests.System.Net
|
||||
[Test]
|
||||
public void GetHostByName ()
|
||||
{
|
||||
SubTestGetHostByName ("www.mono-project.com", site1Dot);
|
||||
SubTestGetHostByName ("www.xamarin.com", site1Dot);
|
||||
SubTestGetHostByName (site2Name, site2Dot);
|
||||
try {
|
||||
var entry = Dns.GetHostByName (noneExistingSite);
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace MonoTests.System.Net {
|
||||
Send (ns, "GET / HTTP/1.1\r\n\r\n"); // No host
|
||||
string response = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
Assert.IsTrue (response.StartsWith ("HTTP/1.1 400"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 400", response);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -155,7 +155,7 @@ 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 ();
|
||||
Assert.IsTrue (response.StartsWith ("HTTP/1.1 400"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 400", response);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -192,7 +192,7 @@ namespace MonoTests.System.Net {
|
||||
string response = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
listener.Close ();
|
||||
Assert.AreEqual (true, response.StartsWith ("HTTP/1.1 400"), String.Format ("Failed on {0}", (int) b));
|
||||
StringAssert.StartsWith ("HTTP/1.1 400", response, String.Format ("Failed on {0}", (int) b));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ 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 ();
|
||||
Assert.IsTrue (response.StartsWith ("HTTP/1.1 411"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 411", response);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -215,7 +215,7 @@ 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 ();
|
||||
Assert.IsTrue (response.StartsWith ("HTTP/1.1 501"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 501", response);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -227,7 +227,7 @@ 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 ();
|
||||
Assert.IsTrue (response.StartsWith ("HTTP/1.1 501"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 501", response);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -241,8 +241,8 @@ namespace MonoTests.System.Net {
|
||||
ctx.Response.Close ();
|
||||
string response = Receive (ns, 1024);
|
||||
ns.Close ();
|
||||
Assert.IsTrue (response.StartsWith ("HTTP/1.1 200"));
|
||||
Assert.IsTrue (-1 != response.IndexOf ("Transfer-Encoding: chunked"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 200", response);
|
||||
StringAssert.Contains ("Transfer-Encoding: chunked", response);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -257,7 +257,7 @@ namespace MonoTests.System.Net {
|
||||
ctx.Response.Close ();
|
||||
string response = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
Assert.IsTrue (response.StartsWith ("HTTP/1.1 200"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 200", response);
|
||||
Assert.IsTrue (-1 == response.IndexOf ("Transfer-Encoding: chunked"));
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ namespace MonoTests.System.Net {
|
||||
string response = ReceiveWithTimeout (ns, 512, 1000, out timeout);
|
||||
ns.Close ();
|
||||
Assert.IsFalse (timeout);
|
||||
Assert.IsTrue (response.StartsWith ("HTTP/1.1 411"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 411", response);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -287,7 +287,7 @@ namespace MonoTests.System.Net {
|
||||
string response = ReceiveWithTimeout (ns, 512, 1000, out timeout);
|
||||
ns.Close ();
|
||||
Assert.IsFalse (timeout);
|
||||
Assert.IsTrue (response.StartsWith ("HTTP/1.1 411"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 411", response);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -300,7 +300,7 @@ namespace MonoTests.System.Net {
|
||||
ns.GetSocket ().Shutdown (SocketShutdown.Send);
|
||||
string input = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
Assert.IsTrue (input.StartsWith ("HTTP/1.1 400"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 400", input);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -313,7 +313,7 @@ namespace MonoTests.System.Net {
|
||||
ns.GetSocket ().Shutdown (SocketShutdown.Send);
|
||||
string input = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
Assert.IsTrue (input.StartsWith ("HTTP/1.1 400"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 400", input);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -326,7 +326,7 @@ namespace MonoTests.System.Net {
|
||||
ns.GetSocket ().Shutdown (SocketShutdown.Send);
|
||||
string input = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
Assert.IsTrue (input.StartsWith ("HTTP/1.1 400"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 400", input);
|
||||
}
|
||||
|
||||
HttpListenerRequest test14_request;
|
||||
@@ -418,8 +418,8 @@ namespace MonoTests.System.Net {
|
||||
ctx.Response.Close ();
|
||||
string response = Receive (ns, 1024);
|
||||
ns.Close ();
|
||||
Assert.IsTrue (response.StartsWith ("HTTP/1.1 200"));
|
||||
Assert.IsTrue (-1 != response.IndexOf ("Transfer-Encoding: chunked"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 200", response);
|
||||
StringAssert.Contains ("Transfer-Encoding: chunked", response);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -723,11 +723,11 @@ namespace MonoTests.System.Net {
|
||||
public void ClosePort ()
|
||||
{
|
||||
var h = new HttpListener ();
|
||||
h.Prefixes.Add ("http://127.0.0.1:8080/");
|
||||
h.Prefixes.Add ("http://127.0.0.1:30158/");
|
||||
h.Start ();
|
||||
h.BeginGetContext (null, null);
|
||||
h.Stop ();
|
||||
TcpListener t = new TcpListener (IPAddress.Parse ("127.0.0.1"), 8080);
|
||||
TcpListener t = new TcpListener (IPAddress.Parse ("127.0.0.1"), 30158);
|
||||
t.Start ();
|
||||
t.Stop ();
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user