From dbd084cb2cb365b0b53fde3498ec6a92e803347a Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Tue, 4 Mar 2014 21:09:12 -0800 Subject: [PATCH 001/453] Initial WebSocket projects, handshake, framing. --- .gitignore | 21 ++ WebSockets.sln | 28 ++ .../ClientWebSocket.cs | 209 +++++++++++++ src/Microsoft.Net.WebSockets/Constants.cs | 26 ++ src/Microsoft.Net.WebSockets/FrameHeader.cs | 235 +++++++++++++++ .../Microsoft.Net.WebSockets.csproj | 56 ++++ .../Properties/AssemblyInfo.cs | 36 +++ .../WebSocketClient.cs | 55 ++++ .../Microsoft.Net.WebSockets.Test.csproj | 71 +++++ .../Properties/AssemblyInfo.cs | 36 +++ .../WebSocketClientTests.cs | 284 ++++++++++++++++++ .../packages.config | 5 + 12 files changed, 1062 insertions(+) create mode 100644 .gitignore create mode 100644 WebSockets.sln create mode 100644 src/Microsoft.Net.WebSockets/ClientWebSocket.cs create mode 100644 src/Microsoft.Net.WebSockets/Constants.cs create mode 100644 src/Microsoft.Net.WebSockets/FrameHeader.cs create mode 100644 src/Microsoft.Net.WebSockets/Microsoft.Net.WebSockets.csproj create mode 100644 src/Microsoft.Net.WebSockets/Properties/AssemblyInfo.cs create mode 100644 src/Microsoft.Net.WebSockets/WebSocketClient.cs create mode 100644 test/Microsoft.Net.WebSockets.Test/Microsoft.Net.WebSockets.Test.csproj create mode 100644 test/Microsoft.Net.WebSockets.Test/Properties/AssemblyInfo.cs create mode 100644 test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs create mode 100644 test/Microsoft.Net.WebSockets.Test/packages.config diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..cb3474e72b --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +bin +obj +*.suo +*.user +_ReSharper.* +*.DS_Store +*.userprefs +*.pidb +*.vspx +*.psess +TestResults/* +TestResult.xml +nugetkey +packages +target +artifacts +StyleCop.Cache +node_modules +*.snk +.nuget/NuGet.exe +docs/build diff --git a/WebSockets.sln b/WebSockets.sln new file mode 100644 index 0000000000..98f957f7e5 --- /dev/null +++ b/WebSockets.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30203.2 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Net.WebSockets", "src\Microsoft.Net.WebSockets\Microsoft.Net.WebSockets.csproj", "{6C1D09CA-F799-44AE-8EC8-9D19C76080C1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Net.WebSockets.Test", "test\Microsoft.Net.WebSockets.Test\Microsoft.Net.WebSockets.Test.csproj", "{EF1FE910-6E0C-4DE8-8CC1-6118B726A59E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6C1D09CA-F799-44AE-8EC8-9D19C76080C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6C1D09CA-F799-44AE-8EC8-9D19C76080C1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6C1D09CA-F799-44AE-8EC8-9D19C76080C1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6C1D09CA-F799-44AE-8EC8-9D19C76080C1}.Release|Any CPU.Build.0 = Release|Any CPU + {EF1FE910-6E0C-4DE8-8CC1-6118B726A59E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EF1FE910-6E0C-4DE8-8CC1-6118B726A59E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EF1FE910-6E0C-4DE8-8CC1-6118B726A59E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EF1FE910-6E0C-4DE8-8CC1-6118B726A59E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/Microsoft.Net.WebSockets/ClientWebSocket.cs b/src/Microsoft.Net.WebSockets/ClientWebSocket.cs new file mode 100644 index 0000000000..3334508bbd --- /dev/null +++ b/src/Microsoft.Net.WebSockets/ClientWebSocket.cs @@ -0,0 +1,209 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net.WebSockets; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace Microsoft.Net.WebSockets +{ + public class ClientWebSocket : WebSocket + { + private readonly Stream _stream; + private readonly string _subProtocl; + private WebSocketState _state; + + private byte[] _receiveBuffer; + private int _receiveOffset; + private int _receiveCount; + + private FrameHeader _frameInProgress; + private long _frameBytesRemaining = 0; + + public ClientWebSocket(Stream stream, string subProtocol, int receiveBufferSize) + { + _stream = stream; + _subProtocl = subProtocol; + _state = WebSocketState.Open; + _receiveBuffer = new byte[receiveBufferSize]; + } + + public override WebSocketCloseStatus? CloseStatus + { + get { throw new NotImplementedException(); } + } + + public override string CloseStatusDescription + { + get { throw new NotImplementedException(); } + } + + public override WebSocketState State + { + get { return _state; } + } + + public override string SubProtocol + { + get { return _subProtocl; } + } + + public override async Task SendAsync(ArraySegment buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken) + { + // TODO: Validate arguments + // TODO: Check state + // TODO: Check concurrent writes + // TODO: Check ping/pong state + // TODO: Masking + FrameHeader frameHeader = new FrameHeader(endOfMessage, GetOpCode(messageType), true, 0, buffer.Count); + ArraySegment segment = frameHeader.Buffer; + await _stream.WriteAsync(segment.Array, segment.Offset, segment.Count, cancellationToken); + await _stream.WriteAsync(buffer.Array, buffer.Offset, buffer.Count, cancellationToken); + } + + private int GetOpCode(WebSocketMessageType messageType) + { + switch (messageType) + { + case WebSocketMessageType.Text: return Constants.OpCodes.TextFrame; + case WebSocketMessageType.Binary: return Constants.OpCodes.BinaryFrame; + case WebSocketMessageType.Close: return Constants.OpCodes.CloseFrame; + default: throw new NotImplementedException(messageType.ToString()); + } + } + + public async override Task ReceiveAsync(ArraySegment buffer, CancellationToken cancellationToken) + { + // TODO: Validate arguments + // TODO: Check state + // TODO: Check concurrent reads + // TODO: Check ping/pong state + + // No active frame + if (_frameInProgress == null) + { + await EnsureDataAvailableOrReadAsync(2, cancellationToken); + int frameHeaderSize = FrameHeader.CalculateFrameHeaderSize(_receiveBuffer[_receiveOffset + 1]); + await EnsureDataAvailableOrReadAsync(frameHeaderSize, cancellationToken); + _frameInProgress = new FrameHeader(new ArraySegment(_receiveBuffer, _receiveOffset, frameHeaderSize)); + _receiveOffset += frameHeaderSize; + _receiveCount -= frameHeaderSize; + _frameBytesRemaining = _frameInProgress.DataLength; + } + + WebSocketReceiveResult result; + // TODO: Close frame + // TODO: Ping or Pong frames + + // Make sure there's at least some data in the buffer + if (_frameBytesRemaining > 0) + { + await EnsureDataAvailableOrReadAsync(1, cancellationToken); + } + + // Copy buffered data to the users buffer + int bytesToRead = (int)Math.Min((long)buffer.Count, _frameBytesRemaining); + if (_receiveCount > 0) + { + int bytesToCopy = Math.Min(bytesToRead, _receiveCount); + Array.Copy(_receiveBuffer, _receiveOffset, buffer.Array, buffer.Offset, bytesToCopy); + if (bytesToCopy == _frameBytesRemaining) + { + result = new WebSocketReceiveResult(bytesToCopy, GetMessageType(_frameInProgress.OpCode), _frameInProgress.Fin); + _frameInProgress = null; + } + else + { + result = new WebSocketReceiveResult(bytesToCopy, GetMessageType(_frameInProgress.OpCode), false); + } + _frameBytesRemaining -= bytesToCopy; + _receiveCount -= bytesToCopy; + _receiveOffset += bytesToCopy; + } + else + { + // End of an empty frame? + result = new WebSocketReceiveResult(0, GetMessageType(_frameInProgress.OpCode), true); + } + + return result; + } + + private async Task EnsureDataAvailableOrReadAsync(int bytes, CancellationToken cancellationToken) + { + // Insufficient data + while (_receiveCount < bytes && bytes <= _receiveBuffer.Length) + { + // Some data in the buffer, shift down to make room + if (_receiveCount > 0 && _receiveOffset > 0) + { + Array.Copy(_receiveBuffer, _receiveOffset, _receiveBuffer, 0, _receiveCount); + } + _receiveOffset = 0; + // Add to the end + int read = await _stream.ReadAsync(_receiveBuffer, _receiveCount, _receiveBuffer.Length - (_receiveCount), cancellationToken); + if (read == 0) + { + throw new IOException("Unexpected end of stream"); + } + _receiveCount += read; + } + } + + private WebSocketMessageType GetMessageType(int opCode) + { + switch (opCode) + { + case Constants.OpCodes.TextFrame: return WebSocketMessageType.Text; + case Constants.OpCodes.BinaryFrame: return WebSocketMessageType.Binary; + case Constants.OpCodes.CloseFrame: return WebSocketMessageType.Close; + default: throw new NotImplementedException(opCode.ToString()); + } + } + + public override Task CloseAsync(WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken) + { + throw new NotImplementedException(); + } + + public override async Task CloseOutputAsync(WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken) + { + // TODO: Validate arguments + // TODO: Check state + // TODO: Check concurrent writes + // TODO: Check ping/pong state + _state = WebSocketState.CloseSent; + + // TODO: Masking + byte[] buffer = Encoding.UTF8.GetBytes(statusDescription); + FrameHeader frameHeader = new FrameHeader(true, Constants.OpCodes.CloseFrame, true, 0, buffer.Length); + ArraySegment segment = frameHeader.Buffer; + await _stream.WriteAsync(segment.Array, segment.Offset, segment.Count, cancellationToken); + await _stream.WriteAsync(buffer, 0, buffer.Length, cancellationToken); + } + + public override void Abort() + { + if (_state >= WebSocketState.Closed) // or Aborted + { + return; + } + + _state = WebSocketState.Aborted; + _stream.Dispose(); + } + + public override void Dispose() + { + if (_state >= WebSocketState.Closed) // or Aborted + { + return; + } + + _state = WebSocketState.Closed; + _stream.Dispose(); + } + } +} diff --git a/src/Microsoft.Net.WebSockets/Constants.cs b/src/Microsoft.Net.WebSockets/Constants.cs new file mode 100644 index 0000000000..c7ebabaab7 --- /dev/null +++ b/src/Microsoft.Net.WebSockets/Constants.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Microsoft.Net.WebSockets +{ + public static class Constants + { + public static class Headers + { + public const string WebSocketVersion = "Sec-WebSocket-Version"; + public const string SupportedVersion = "13"; + } + + public static class OpCodes + { + public const int TextFrame = 0x1; + public const int BinaryFrame = 0x2; + public const int CloseFrame = 0x8; + public const int PingFrame = 0x8; + public const int PongFrame = 0xA; + } + } +} diff --git a/src/Microsoft.Net.WebSockets/FrameHeader.cs b/src/Microsoft.Net.WebSockets/FrameHeader.cs new file mode 100644 index 0000000000..54d53fc1c7 --- /dev/null +++ b/src/Microsoft.Net.WebSockets/FrameHeader.cs @@ -0,0 +1,235 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.WebSockets; +using System.Text; +using System.Threading.Tasks; + +namespace Microsoft.Net.WebSockets +{ + public class FrameHeader + { + private byte[] _header; + + public FrameHeader(ArraySegment header) + { + _header = new byte[header.Count]; + Array.Copy(header.Array, header.Offset, _header, 0, _header.Length); + } + + public FrameHeader(bool final, int opCode, bool masked, int maskKey, long dataLength) + { + int headerLength = 2; + if (masked) + { + headerLength += 4; + } + + if (dataLength <= 125) + { + } + else if (125 < dataLength && dataLength <= 0xFFFF) + { + headerLength += 2; + } + else + { + headerLength += 8; + } + _header = new byte[headerLength]; + + Fin = final; + OpCode = opCode; + Masked = masked; + if (masked) + { + MaskKey = maskKey; + } + DataLength = dataLength; + } + + public bool Fin + { + get + { + return (_header[0] & 0x80) == 0x80; + } + private set + { + if (value) + { + _header[0] |= 0x80; + } + else + { + _header[0] &= 0x7F; + } + } + } + + public int OpCode + { + get + { + return (_header[0] & 0xF); + } + private set + { + // TODO: Clear out a prior value? + _header[0] |= (byte)(value & 0xF); + } + } + + public bool Masked + { + get + { + return (_header[1] & 0x80) == 0x80; + } + private set + { + if (value) + { + _header[1] |= 0x80; + } + else + { + _header[1] &= 0x7F; + } + } + } + + public int MaskKey + { + get + { + if (!Masked) + { + return 0; + } + int offset = ExtendedLengthFieldSize + 2; + return (_header[offset] << 24) + (_header[offset + 1] << 16) + + (_header[offset + 2] << 8) + _header[offset + 4]; + } + private set + { + int offset = ExtendedLengthFieldSize + 2; + _header[offset] = (byte)(value >> 24); + _header[offset + 1] = (byte)(value >> 16); + _header[offset + 2] = (byte)(value >> 8); + _header[offset + 3] = (byte)value; + } + } + + public int PayloadField + { + get + { + return (_header[1] & 0x7F); + } + private set + { + // TODO: Clear out a prior value? + _header[1] |= (byte)(value & 0x7F); + } + } + + public int ExtendedLengthFieldSize + { + get + { + int payloadField = PayloadField; + if (payloadField <= 125) + { + return 0; + } + if (payloadField == 126) + { + return 2; + } + return 8; + } + } + + public long DataLength + { + get + { + int extendedFieldSize = ExtendedLengthFieldSize; + if (extendedFieldSize == 0) + { + return PayloadField; + } + if (extendedFieldSize == 2) + { + return (_header[2] << 8) + _header[3]; + } + return (_header[2] << 56) + (_header[3] << 48) + + (_header[4] << 40) + (_header[5] << 32) + + (_header[6] << 24) + (_header[7] << 16) + + (_header[8] << 8) + _header[9]; + } + private set + { + if (value <= 125) + { + PayloadField = (int)value; + } + else if (125 < value && value <= 0xFFFF) + { + PayloadField = 0x7E; + + _header[2] = (byte)(value >> 8); + _header[3] = (byte)value; + } + else + { + PayloadField = 0x7F; + + _header[2] = (byte)(value >> 56); + _header[3] = (byte)(value >> 48); + _header[4] = (byte)(value >> 40); + _header[5] = (byte)(value >> 32); + _header[6] = (byte)(value >> 24); + _header[7] = (byte)(value >> 16); + _header[8] = (byte)(value >> 8); + _header[9] = (byte)value; + } + } + } + + public ArraySegment Buffer + { + get + { + return new ArraySegment(_header); + } + } + + // Given the second bytes of a frame, calculate how long the whole frame header should be. + // Range 2-12 bytes + public static int CalculateFrameHeaderSize(byte b2) + { + int headerLength = 2; + if ((b2 & 0x80) == 0x80) // Masked + { + headerLength += 4; + } + + int payloadField = (b2 & 0x7F); + if (payloadField <= 125) + { + // headerLength += 0 + } + else if (payloadField == 126) + { + headerLength += 2; + } + else + { + headerLength += 8; + } + return headerLength; + } + } +} diff --git a/src/Microsoft.Net.WebSockets/Microsoft.Net.WebSockets.csproj b/src/Microsoft.Net.WebSockets/Microsoft.Net.WebSockets.csproj new file mode 100644 index 0000000000..c0283932c2 --- /dev/null +++ b/src/Microsoft.Net.WebSockets/Microsoft.Net.WebSockets.csproj @@ -0,0 +1,56 @@ + + + + + Debug + AnyCPU + {6C1D09CA-F799-44AE-8EC8-9D19C76080C1} + Library + Properties + Microsoft.Net.WebSockets + Microsoft.Net.WebSockets + v4.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Microsoft.Net.WebSockets/Properties/AssemblyInfo.cs b/src/Microsoft.Net.WebSockets/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..b8a0860d30 --- /dev/null +++ b/src/Microsoft.Net.WebSockets/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Microsoft.Net.WebSockets")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Microsoft.Net.WebSockets")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("9a9e41ae-1494-4d87-a66f-a4019ff68ce5")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Microsoft.Net.WebSockets/WebSocketClient.cs b/src/Microsoft.Net.WebSockets/WebSocketClient.cs new file mode 100644 index 0000000000..3cac40fe79 --- /dev/null +++ b/src/Microsoft.Net.WebSockets/WebSocketClient.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.WebSockets; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace Microsoft.Net.WebSockets.Client +{ + public class WebSocketClient + { + static WebSocketClient() + { + try + { + // Only call once + WebSocket.RegisterPrefixes(); + } + catch (Exception) + { + // Already registered + } + } + + public WebSocketClient() + { + ReceiveBufferSize = 1024; + } + + public int ReceiveBufferSize + { + get; + set; + } + + public async Task ConnectAsync(Uri uri, CancellationToken cancellationToken) + { + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); + + request.Headers[Constants.Headers.WebSocketVersion] = Constants.Headers.SupportedVersion; + // TODO: Sub-protocols + + WebResponse response = await request.GetResponseAsync(); + // TODO: Validate handshake + + Stream stream = response.GetResponseStream(); + // Console.WriteLine(stream.CanWrite + " " + stream.CanRead); + + return new ClientWebSocket(stream, null, ReceiveBufferSize); + } + } +} diff --git a/test/Microsoft.Net.WebSockets.Test/Microsoft.Net.WebSockets.Test.csproj b/test/Microsoft.Net.WebSockets.Test/Microsoft.Net.WebSockets.Test.csproj new file mode 100644 index 0000000000..23b2f9f0f3 --- /dev/null +++ b/test/Microsoft.Net.WebSockets.Test/Microsoft.Net.WebSockets.Test.csproj @@ -0,0 +1,71 @@ + + + + + Debug + AnyCPU + {EF1FE910-6E0C-4DE8-8CC1-6118B726A59E} + Library + Properties + Microsoft.Net.WebSockets.Test + Microsoft.Net.WebSockets.Test + v4.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + ..\..\packages\xunit.1.9.2\lib\net20\xunit.dll + + + ..\..\packages\xunit.extensions.1.9.2\lib\net20\xunit.extensions.dll + + + + + + + + + {6c1d09ca-f799-44ae-8ec8-9d19c76080c1} + Microsoft.Net.WebSockets + + + + + + + + + + + \ No newline at end of file diff --git a/test/Microsoft.Net.WebSockets.Test/Properties/AssemblyInfo.cs b/test/Microsoft.Net.WebSockets.Test/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..f30741c6b2 --- /dev/null +++ b/test/Microsoft.Net.WebSockets.Test/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Microsoft.Net.WebSockets.Test")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Microsoft.Net.WebSockets.Test")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("237d6e8f-6e5e-4c3f-96b4-b19cf3bf4d80")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs b/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs new file mode 100644 index 0000000000..7ac37e8bc3 --- /dev/null +++ b/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs @@ -0,0 +1,284 @@ +using Microsoft.Net.WebSockets.Client; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.WebSockets; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Microsoft.Net.WebSockets.Test +{ + public class WebSocketClientTests + { + private static string ClientAddress = "ws://localhost:8080/"; + private static string ServerAddress = "http://localhost:8080/"; + + [Fact] + public async Task Connect_Success() + { + using (HttpListener listener = new HttpListener()) + { + listener.Prefixes.Add(ServerAddress); + listener.Start(); + Task serverAccept = listener.GetContextAsync(); + + WebSocketClient client = new WebSocketClient(); + Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + + HttpListenerContext serverContext = await serverAccept; + Assert.True(serverContext.Request.IsWebSocketRequest); + HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); + + WebSocket clientSocket = await clientConnect; + clientSocket.Dispose(); + } + } + + [Fact] + public async Task SendShortData_Success() + { + using (HttpListener listener = new HttpListener()) + { + listener.Prefixes.Add(ServerAddress); + listener.Start(); + Task serverAccept = listener.GetContextAsync(); + + WebSocketClient client = new WebSocketClient(); + Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + + HttpListenerContext serverContext = await serverAccept; + Assert.True(serverContext.Request.IsWebSocketRequest); + HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); + + WebSocket clientSocket = await clientConnect; + + byte[] orriginalData = Encoding.UTF8.GetBytes("Hello World"); + await clientSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + + byte[] serverBuffer = new byte[orriginalData.Length]; + WebSocketReceiveResult result = await serverWebSocketContext.WebSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, serverBuffer); + + clientSocket.Dispose(); + } + } + + [Fact] + public async Task SendMediumData_Success() + { + using (HttpListener listener = new HttpListener()) + { + listener.Prefixes.Add(ServerAddress); + listener.Start(); + Task serverAccept = listener.GetContextAsync(); + + WebSocketClient client = new WebSocketClient(); + Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + + HttpListenerContext serverContext = await serverAccept; + Assert.True(serverContext.Request.IsWebSocketRequest); + HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); + + WebSocket clientSocket = await clientConnect; + + byte[] orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); + await clientSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Text, true, CancellationToken.None); + + byte[] serverBuffer = new byte[orriginalData.Length]; + WebSocketReceiveResult result = await serverWebSocketContext.WebSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, result.Count); + Assert.Equal(WebSocketMessageType.Text, result.MessageType); + Assert.Equal(orriginalData, serverBuffer); + + clientSocket.Dispose(); + } + } + + [Fact] + public async Task SendLongData_Success() + { + using (HttpListener listener = new HttpListener()) + { + listener.Prefixes.Add(ServerAddress); + listener.Start(); + Task serverAccept = listener.GetContextAsync(); + + WebSocketClient client = new WebSocketClient(); + Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + + HttpListenerContext serverContext = await serverAccept; + Assert.True(serverContext.Request.IsWebSocketRequest); + HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null, 0xFFFF, TimeSpan.FromMinutes(100)); + + WebSocket clientSocket = await clientConnect; + + byte[] orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); + await clientSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Text, true, CancellationToken.None); + + byte[] serverBuffer = new byte[orriginalData.Length]; + WebSocketReceiveResult result = await serverWebSocketContext.WebSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + int intermediateCount = result.Count; + Assert.False(result.EndOfMessage); + Assert.Equal(WebSocketMessageType.Text, result.MessageType); + + result = await serverWebSocketContext.WebSocket.ReceiveAsync(new ArraySegment(serverBuffer, intermediateCount, orriginalData.Length - intermediateCount), CancellationToken.None); + intermediateCount += result.Count; + Assert.False(result.EndOfMessage); + Assert.Equal(WebSocketMessageType.Text, result.MessageType); + + result = await serverWebSocketContext.WebSocket.ReceiveAsync(new ArraySegment(serverBuffer, intermediateCount, orriginalData.Length - intermediateCount), CancellationToken.None); + intermediateCount += result.Count; + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, intermediateCount); + Assert.Equal(WebSocketMessageType.Text, result.MessageType); + + Assert.Equal(orriginalData, serverBuffer); + + clientSocket.Dispose(); + } + } + + [Fact] + public async Task ReceiveShortData_Success() + { + using (HttpListener listener = new HttpListener()) + { + listener.Prefixes.Add(ServerAddress); + listener.Start(); + Task serverAccept = listener.GetContextAsync(); + + WebSocketClient client = new WebSocketClient(); + Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + + HttpListenerContext serverContext = await serverAccept; + Assert.True(serverContext.Request.IsWebSocketRequest); + HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); + + WebSocket clientSocket = await clientConnect; + + byte[] orriginalData = Encoding.UTF8.GetBytes("Hello World"); + await serverWebSocketContext.WebSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + + byte[] clientBuffer = new byte[orriginalData.Length]; + WebSocketReceiveResult result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, clientBuffer); + + clientSocket.Dispose(); + } + } + + [Fact] + public async Task ReceiveMediumData_Success() + { + using (HttpListener listener = new HttpListener()) + { + listener.Prefixes.Add(ServerAddress); + listener.Start(); + Task serverAccept = listener.GetContextAsync(); + + WebSocketClient client = new WebSocketClient(); + Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + + HttpListenerContext serverContext = await serverAccept; + Assert.True(serverContext.Request.IsWebSocketRequest); + HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); + + WebSocket clientSocket = await clientConnect; + + byte[] orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); + await serverWebSocketContext.WebSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + + byte[] clientBuffer = new byte[orriginalData.Length]; + WebSocketReceiveResult result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, clientBuffer); + + clientSocket.Dispose(); + } + } + + [Fact] + public async Task ReceiveLongDataInSmallBuffer_Success() + { + using (HttpListener listener = new HttpListener()) + { + listener.Prefixes.Add(ServerAddress); + listener.Start(); + Task serverAccept = listener.GetContextAsync(); + + WebSocketClient client = new WebSocketClient(); + Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + + HttpListenerContext serverContext = await serverAccept; + Assert.True(serverContext.Request.IsWebSocketRequest); + HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); + + WebSocket clientSocket = await clientConnect; + + byte[] orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); + await serverWebSocketContext.WebSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + + byte[] clientBuffer = new byte[orriginalData.Length]; + WebSocketReceiveResult result; + int receivedCount = 0; + do + { + result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer, receivedCount, clientBuffer.Length - receivedCount), CancellationToken.None); + receivedCount += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + } + while (!result.EndOfMessage); + + Assert.Equal(orriginalData.Length, receivedCount); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, clientBuffer); + + clientSocket.Dispose(); + } + } + + [Fact] + public async Task ReceiveLongDataInLargeBuffer_Success() + { + using (HttpListener listener = new HttpListener()) + { + listener.Prefixes.Add(ServerAddress); + listener.Start(); + Task serverAccept = listener.GetContextAsync(); + + WebSocketClient client = new WebSocketClient() { ReceiveBufferSize = 0xFFFFFF }; + Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + + HttpListenerContext serverContext = await serverAccept; + Assert.True(serverContext.Request.IsWebSocketRequest); + HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); + + WebSocket clientSocket = await clientConnect; + + byte[] orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); + await serverWebSocketContext.WebSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + + byte[] clientBuffer = new byte[orriginalData.Length]; + WebSocketReceiveResult result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, clientBuffer); + + clientSocket.Dispose(); + } + } + } +} diff --git a/test/Microsoft.Net.WebSockets.Test/packages.config b/test/Microsoft.Net.WebSockets.Test/packages.config new file mode 100644 index 0000000000..67a23e70da --- /dev/null +++ b/test/Microsoft.Net.WebSockets.Test/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file From 7004026b5e63ed73f2dec1967b1378864598a1aa Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Wed, 5 Mar 2014 09:28:09 -0800 Subject: [PATCH 002/453] Implement Close. --- .../ClientWebSocket.cs | 93 ++++++++- .../WebSocketClientTests.cs | 188 ++++++++++++++++++ 2 files changed, 272 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.Net.WebSockets/ClientWebSocket.cs b/src/Microsoft.Net.WebSockets/ClientWebSocket.cs index 3334508bbd..d91bf1cffd 100644 --- a/src/Microsoft.Net.WebSockets/ClientWebSocket.cs +++ b/src/Microsoft.Net.WebSockets/ClientWebSocket.cs @@ -15,6 +15,9 @@ namespace Microsoft.Net.WebSockets private readonly string _subProtocl; private WebSocketState _state; + private WebSocketCloseStatus? _closeStatus; + private string _closeStatusDescription; + private byte[] _receiveBuffer; private int _receiveOffset; private int _receiveCount; @@ -32,12 +35,12 @@ namespace Microsoft.Net.WebSockets public override WebSocketCloseStatus? CloseStatus { - get { throw new NotImplementedException(); } + get { return _closeStatus; } } public override string CloseStatusDescription { - get { throw new NotImplementedException(); } + get { return _closeStatusDescription; } } public override WebSocketState State @@ -94,9 +97,31 @@ namespace Microsoft.Net.WebSockets } WebSocketReceiveResult result; - // TODO: Close frame + // TODO: Ping or Pong frames + if (_frameInProgress.OpCode == Constants.OpCodes.CloseFrame) + { + // TOOD: This assumes the close message fits in the buffer. + // TODO: Assert at least two bytes remaining for the close status code. + await EnsureDataAvailableOrReadAsync((int)_frameBytesRemaining, CancellationToken.None); + + _closeStatus = (WebSocketCloseStatus)((_receiveBuffer[_receiveOffset] << 8) | _receiveBuffer[_receiveOffset + 1]); + _closeStatusDescription = Encoding.UTF8.GetString(_receiveBuffer, _receiveOffset + 2, _receiveCount - 2) ?? string.Empty; + result = new WebSocketReceiveResult(0, WebSocketMessageType.Close, true, (WebSocketCloseStatus)_closeStatus, _closeStatusDescription); + + if (State == WebSocketState.Open) + { + _state = WebSocketState.CloseReceived; + } + else if (State == WebSocketState.CloseSent) + { + _state = WebSocketState.Closed; + _stream.Dispose(); + } + return result; + } + // Make sure there's at least some data in the buffer if (_frameBytesRemaining > 0) { @@ -163,9 +188,41 @@ namespace Microsoft.Net.WebSockets } } - public override Task CloseAsync(WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken) + public async override Task CloseAsync(WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken) { - throw new NotImplementedException(); + // TODO: Validate arguments + // TODO: Check state + // TODO: Check concurrent writes + // TODO: Check ping/pong state + + if (State >= WebSocketState.Closed) + { + throw new InvalidOperationException("Already closed."); + } + + if (State == WebSocketState.Open || State == WebSocketState.CloseReceived) + { + // Send a close message. + await CloseOutputAsync(closeStatus, statusDescription, cancellationToken); + } + + if (State == WebSocketState.CloseSent) + { + // Do a receiving drain + byte[] data = new byte[1024]; + WebSocketReceiveResult result; + do + { + result = await ReceiveAsync(new ArraySegment(data), cancellationToken); + } + while (result.MessageType != WebSocketMessageType.Close); + + _closeStatus = result.CloseStatus; + _closeStatusDescription = result.CloseStatusDescription; + } + + _state = WebSocketState.Closed; + _stream.Dispose(); } public override async Task CloseOutputAsync(WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken) @@ -174,14 +231,32 @@ namespace Microsoft.Net.WebSockets // TODO: Check state // TODO: Check concurrent writes // TODO: Check ping/pong state - _state = WebSocketState.CloseSent; + + if (State == WebSocketState.CloseSent || State >= WebSocketState.Closed) + { + throw new InvalidOperationException("Already closed."); + } + + if (State == WebSocketState.Open) + { + _state = WebSocketState.CloseSent; + } + else if (State == WebSocketState.CloseReceived) + { + _state = WebSocketState.Closed; + } + + byte[] descriptionBytes = Encoding.UTF8.GetBytes(statusDescription ?? string.Empty); + byte[] fullData = new byte[descriptionBytes.Length + 2]; + fullData[0] = (byte)((int)closeStatus >> 8); + fullData[1] = (byte)closeStatus; + Array.Copy(descriptionBytes, 0, fullData, 2, descriptionBytes.Length); // TODO: Masking - byte[] buffer = Encoding.UTF8.GetBytes(statusDescription); - FrameHeader frameHeader = new FrameHeader(true, Constants.OpCodes.CloseFrame, true, 0, buffer.Length); + FrameHeader frameHeader = new FrameHeader(true, Constants.OpCodes.CloseFrame, true, 0, fullData.Length); ArraySegment segment = frameHeader.Buffer; await _stream.WriteAsync(segment.Array, segment.Offset, segment.Count, cancellationToken); - await _stream.WriteAsync(buffer, 0, buffer.Length, cancellationToken); + await _stream.WriteAsync(fullData, 0, fullData.Length, cancellationToken); } public override void Abort() diff --git a/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs b/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs index 7ac37e8bc3..7443cc0c7b 100644 --- a/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs +++ b/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs @@ -280,5 +280,193 @@ namespace Microsoft.Net.WebSockets.Test clientSocket.Dispose(); } } + + [Fact] + public async Task SendClose_Success() + { + using (HttpListener listener = new HttpListener()) + { + listener.Prefixes.Add(ServerAddress); + listener.Start(); + Task serverAccept = listener.GetContextAsync(); + + WebSocketClient client = new WebSocketClient(); + Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + + HttpListenerContext serverContext = await serverAccept; + Assert.True(serverContext.Request.IsWebSocketRequest); + HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); + + WebSocket clientSocket = await clientConnect; + + string closeDescription = "Test Closed"; + await clientSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + + byte[] serverBuffer = new byte[1024]; + WebSocketReceiveResult result = await serverWebSocketContext.WebSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + + Assert.Equal(WebSocketState.CloseSent, clientSocket.State); + + clientSocket.Dispose(); + } + } + + [Fact] + public async Task ReceiveClose_Success() + { + using (HttpListener listener = new HttpListener()) + { + listener.Prefixes.Add(ServerAddress); + listener.Start(); + Task serverAccept = listener.GetContextAsync(); + + WebSocketClient client = new WebSocketClient(); + Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + + HttpListenerContext serverContext = await serverAccept; + Assert.True(serverContext.Request.IsWebSocketRequest); + HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); + + WebSocket clientSocket = await clientConnect; + + string closeDescription = "Test Closed"; + await serverWebSocketContext.WebSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + + byte[] serverBuffer = new byte[1024]; + WebSocketReceiveResult result = await clientSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + + Assert.Equal(WebSocketState.CloseReceived, clientSocket.State); + + clientSocket.Dispose(); + } + } + + [Fact] + public async Task CloseFromOpen_Success() + { + using (HttpListener listener = new HttpListener()) + { + listener.Prefixes.Add(ServerAddress); + listener.Start(); + Task serverAccept = listener.GetContextAsync(); + + WebSocketClient client = new WebSocketClient(); + Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + + HttpListenerContext serverContext = await serverAccept; + Assert.True(serverContext.Request.IsWebSocketRequest); + HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); + + WebSocket clientSocket = await clientConnect; + + string closeDescription = "Test Closed"; + Task closeTask = clientSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + + byte[] serverBuffer = new byte[1024]; + WebSocketReceiveResult result = await serverWebSocketContext.WebSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + + await serverWebSocketContext.WebSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + + await closeTask; + + Assert.Equal(WebSocketState.Closed, clientSocket.State); + + clientSocket.Dispose(); + } + } + + [Fact] + public async Task CloseFromCloseSent_Success() + { + using (HttpListener listener = new HttpListener()) + { + listener.Prefixes.Add(ServerAddress); + listener.Start(); + Task serverAccept = listener.GetContextAsync(); + + WebSocketClient client = new WebSocketClient(); + Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + + HttpListenerContext serverContext = await serverAccept; + Assert.True(serverContext.Request.IsWebSocketRequest); + HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); + + WebSocket clientSocket = await clientConnect; + + string closeDescription = "Test Closed"; + await clientSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + Assert.Equal(WebSocketState.CloseSent, clientSocket.State); + + byte[] serverBuffer = new byte[1024]; + WebSocketReceiveResult result = await serverWebSocketContext.WebSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + + await serverWebSocketContext.WebSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + + await clientSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + + Assert.Equal(WebSocketState.Closed, clientSocket.State); + + clientSocket.Dispose(); + } + } + + [Fact] + public async Task CloseFromCloseReceived_Success() + { + using (HttpListener listener = new HttpListener()) + { + listener.Prefixes.Add(ServerAddress); + listener.Start(); + Task serverAccept = listener.GetContextAsync(); + + WebSocketClient client = new WebSocketClient(); + Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + + HttpListenerContext serverContext = await serverAccept; + Assert.True(serverContext.Request.IsWebSocketRequest); + HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); + + WebSocket clientSocket = await clientConnect; + + string closeDescription = "Test Closed"; + await serverWebSocketContext.WebSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + + byte[] serverBuffer = new byte[1024]; + WebSocketReceiveResult result = await clientSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + + Assert.Equal(WebSocketState.CloseReceived, clientSocket.State); + + await clientSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + + Assert.Equal(WebSocketState.Closed, clientSocket.State); + + clientSocket.Dispose(); + } + } } } From 14685821a68c3c99fabb2ce51f8d71728d7950d5 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Wed, 5 Mar 2014 16:55:32 -0800 Subject: [PATCH 003/453] Implement client masking. --- ...{ClientWebSocket.cs => CommonWebSocket.cs} | 53 ++++++++++++++++--- src/Microsoft.Net.WebSockets/FrameHeader.cs | 4 +- .../Microsoft.Net.WebSockets.csproj | 3 +- src/Microsoft.Net.WebSockets/Utilities.cs | 41 ++++++++++++++ .../WebSocketClient.cs | 2 +- .../Microsoft.Net.WebSockets.Test.csproj | 1 + .../UtilitiesTests.cs | 22 ++++++++ 7 files changed, 116 insertions(+), 10 deletions(-) rename src/Microsoft.Net.WebSockets/{ClientWebSocket.cs => CommonWebSocket.cs} (81%) create mode 100644 src/Microsoft.Net.WebSockets/Utilities.cs create mode 100644 test/Microsoft.Net.WebSockets.Test/UtilitiesTests.cs diff --git a/src/Microsoft.Net.WebSockets/ClientWebSocket.cs b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs similarity index 81% rename from src/Microsoft.Net.WebSockets/ClientWebSocket.cs rename to src/Microsoft.Net.WebSockets/CommonWebSocket.cs index d91bf1cffd..6e3f19d41e 100644 --- a/src/Microsoft.Net.WebSockets/ClientWebSocket.cs +++ b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs @@ -9,10 +9,15 @@ using System.Threading.Tasks; namespace Microsoft.Net.WebSockets { - public class ClientWebSocket : WebSocket + // https://tools.ietf.org/html/rfc6455 + public class CommonWebSocket : WebSocket { + private readonly static Random Random = new Random(); + private readonly Stream _stream; private readonly string _subProtocl; + private readonly bool _maskOutput; + private readonly bool _useZeroMask; private WebSocketState _state; private WebSocketCloseStatus? _closeStatus; @@ -25,12 +30,14 @@ namespace Microsoft.Net.WebSockets private FrameHeader _frameInProgress; private long _frameBytesRemaining = 0; - public ClientWebSocket(Stream stream, string subProtocol, int receiveBufferSize) + public CommonWebSocket(Stream stream, string subProtocol, int receiveBufferSize) { _stream = stream; _subProtocl = subProtocol; _state = WebSocketState.Open; _receiveBuffer = new byte[receiveBufferSize]; + _maskOutput = true; // TODO: make optional for client. Add option to block unmasking from server. + _useZeroMask = false; // TODO: make optional } public override WebSocketCloseStatus? CloseStatus @@ -53,6 +60,28 @@ namespace Microsoft.Net.WebSockets get { return _subProtocl; } } + // https://tools.ietf.org/html/rfc6455#section-5.3 + // The masking key is a 32-bit value chosen at random by the client. + // When preparing a masked frame, the client MUST pick a fresh masking + // key from the set of allowed 32-bit values. The masking key needs to + // be unpredictable; thus, the masking key MUST be derived from a strong + // source of entropy, and the masking key for a given frame MUST NOT + // make it simple for a server/proxy to predict the masking key for a + // subsequent frame. The unpredictability of the masking key is + // essential to prevent authors of malicious applications from selecting + // the bytes that appear on the wire. RFC 4086 [RFC4086] discusses what + // entails a suitable source of entropy for security-sensitive + // applications. + private int GetNextMask() + { + if (_useZeroMask) + { + return 0; + } + // TODO: Doesn't include negative numbers so it's only 31 bits, not 32. + return Random.Next(); + } + public override async Task SendAsync(ArraySegment buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken) { // TODO: Validate arguments @@ -60,10 +89,20 @@ namespace Microsoft.Net.WebSockets // TODO: Check concurrent writes // TODO: Check ping/pong state // TODO: Masking - FrameHeader frameHeader = new FrameHeader(endOfMessage, GetOpCode(messageType), true, 0, buffer.Count); + // TODO: Block close frame? + int mask = GetNextMask(); + FrameHeader frameHeader = new FrameHeader(endOfMessage, GetOpCode(messageType), _maskOutput, mask, buffer.Count); ArraySegment segment = frameHeader.Buffer; - await _stream.WriteAsync(segment.Array, segment.Offset, segment.Count, cancellationToken); - await _stream.WriteAsync(buffer.Array, buffer.Offset, buffer.Count, cancellationToken); + if (_maskOutput && mask != 0) + { + byte[] maskedFrame = Utilities.MergeAndMask(mask, segment, buffer); + await _stream.WriteAsync(maskedFrame, 0, maskedFrame.Length, cancellationToken); + } + else + { + await _stream.WriteAsync(segment.Array, segment.Offset, segment.Count, cancellationToken); + await _stream.WriteAsync(buffer.Array, buffer.Offset, buffer.Count, cancellationToken); + } } private int GetOpCode(WebSocketMessageType messageType) @@ -105,7 +144,8 @@ namespace Microsoft.Net.WebSockets // TOOD: This assumes the close message fits in the buffer. // TODO: Assert at least two bytes remaining for the close status code. await EnsureDataAvailableOrReadAsync((int)_frameBytesRemaining, CancellationToken.None); - + // TODO: Unmask (server only) + // TODO: Throw if the client detects an incoming masked frame. _closeStatus = (WebSocketCloseStatus)((_receiveBuffer[_receiveOffset] << 8) | _receiveBuffer[_receiveOffset + 1]); _closeStatusDescription = Encoding.UTF8.GetString(_receiveBuffer, _receiveOffset + 2, _receiveCount - 2) ?? string.Empty; result = new WebSocketReceiveResult(0, WebSocketMessageType.Close, true, (WebSocketCloseStatus)_closeStatus, _closeStatusDescription); @@ -132,6 +172,7 @@ namespace Microsoft.Net.WebSockets int bytesToRead = (int)Math.Min((long)buffer.Count, _frameBytesRemaining); if (_receiveCount > 0) { + // TODO: Unmask int bytesToCopy = Math.Min(bytesToRead, _receiveCount); Array.Copy(_receiveBuffer, _receiveOffset, buffer.Array, buffer.Offset, bytesToCopy); if (bytesToCopy == _frameBytesRemaining) diff --git a/src/Microsoft.Net.WebSockets/FrameHeader.cs b/src/Microsoft.Net.WebSockets/FrameHeader.cs index 54d53fc1c7..35e54c7233 100644 --- a/src/Microsoft.Net.WebSockets/FrameHeader.cs +++ b/src/Microsoft.Net.WebSockets/FrameHeader.cs @@ -41,11 +41,11 @@ namespace Microsoft.Net.WebSockets Fin = final; OpCode = opCode; Masked = masked; + DataLength = dataLength; if (masked) { MaskKey = maskKey; } - DataLength = dataLength; } public bool Fin @@ -109,7 +109,7 @@ namespace Microsoft.Net.WebSockets } int offset = ExtendedLengthFieldSize + 2; return (_header[offset] << 24) + (_header[offset + 1] << 16) - + (_header[offset + 2] << 8) + _header[offset + 4]; + + (_header[offset + 2] << 8) + _header[offset + 3]; } private set { diff --git a/src/Microsoft.Net.WebSockets/Microsoft.Net.WebSockets.csproj b/src/Microsoft.Net.WebSockets/Microsoft.Net.WebSockets.csproj index c0283932c2..dec92dc375 100644 --- a/src/Microsoft.Net.WebSockets/Microsoft.Net.WebSockets.csproj +++ b/src/Microsoft.Net.WebSockets/Microsoft.Net.WebSockets.csproj @@ -39,10 +39,11 @@ - + + diff --git a/src/Microsoft.Net.WebSockets/Utilities.cs b/src/Microsoft.Net.WebSockets/Utilities.cs new file mode 100644 index 0000000000..2293dbb328 --- /dev/null +++ b/src/Microsoft.Net.WebSockets/Utilities.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Microsoft.Net.WebSockets +{ + public static class Utilities + { + // Copies the header and data into a new buffer and masks the data. + public static byte[] MergeAndMask(int mask, ArraySegment header, ArraySegment data) + { + byte[] frame = new byte[header.Count + data.Count]; + Array.Copy(header.Array, header.Offset, frame, 0, header.Count); + Array.Copy(data.Array, data.Offset, frame, header.Count, data.Count); + + Mask(mask, new ArraySegment(frame, header.Count, data.Count)); + return frame; + } + + // Un/Masks the data in place + public static void Mask(int mask, ArraySegment data) + { + byte[] maskBytes = new byte[] + { + (byte)(mask >> 24), + (byte)(mask >> 16), + (byte)(mask >> 8), + (byte)mask, + }; + int maskOffset = 0; + + for (int i = data.Offset; i < data.Offset + data.Count; i++) + { + data.Array[i] = (byte)(data.Array[i] ^ maskBytes[maskOffset]); + maskOffset = (maskOffset + 1) % 4; + } + } + } +} diff --git a/src/Microsoft.Net.WebSockets/WebSocketClient.cs b/src/Microsoft.Net.WebSockets/WebSocketClient.cs index 3cac40fe79..1a32277d8f 100644 --- a/src/Microsoft.Net.WebSockets/WebSocketClient.cs +++ b/src/Microsoft.Net.WebSockets/WebSocketClient.cs @@ -49,7 +49,7 @@ namespace Microsoft.Net.WebSockets.Client Stream stream = response.GetResponseStream(); // Console.WriteLine(stream.CanWrite + " " + stream.CanRead); - return new ClientWebSocket(stream, null, ReceiveBufferSize); + return new CommonWebSocket(stream, null, ReceiveBufferSize); } } } diff --git a/test/Microsoft.Net.WebSockets.Test/Microsoft.Net.WebSockets.Test.csproj b/test/Microsoft.Net.WebSockets.Test/Microsoft.Net.WebSockets.Test.csproj index 23b2f9f0f3..fcfd99f1a4 100644 --- a/test/Microsoft.Net.WebSockets.Test/Microsoft.Net.WebSockets.Test.csproj +++ b/test/Microsoft.Net.WebSockets.Test/Microsoft.Net.WebSockets.Test.csproj @@ -45,6 +45,7 @@ + diff --git a/test/Microsoft.Net.WebSockets.Test/UtilitiesTests.cs b/test/Microsoft.Net.WebSockets.Test/UtilitiesTests.cs new file mode 100644 index 0000000000..ff9c8f4601 --- /dev/null +++ b/test/Microsoft.Net.WebSockets.Test/UtilitiesTests.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Xunit; + +namespace Microsoft.Net.WebSockets.Test +{ + public class UtilitiesTests + { + [Fact] + public void MaskDataRoundTrips() + { + byte[] data = Encoding.UTF8.GetBytes("Hello World"); + byte[] orriginal = Encoding.UTF8.GetBytes("Hello World"); + Utilities.Mask(16843009, new ArraySegment(data)); + Utilities.Mask(16843009, new ArraySegment(data)); + Assert.Equal(orriginal, data); + } + } +} From 2f770ca4d40421d001b497c05367f1dc0e410385 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Thu, 6 Mar 2014 10:29:54 -0800 Subject: [PATCH 004/453] Handle incoming pings and pongs. --- .../CommonWebSocket.cs | 92 ++++++++++++++++--- src/Microsoft.Net.WebSockets/Constants.cs | 2 +- src/Microsoft.Net.WebSockets/Utilities.cs | 5 + 3 files changed, 85 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs index 6e3f19d41e..cae096cc94 100644 --- a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs +++ b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs @@ -17,7 +17,10 @@ namespace Microsoft.Net.WebSockets private readonly Stream _stream; private readonly string _subProtocl; private readonly bool _maskOutput; + private readonly bool _unmaskInput; private readonly bool _useZeroMask; + private readonly SemaphoreSlim _writeLock; + private WebSocketState _state; private WebSocketCloseStatus? _closeStatus; @@ -36,8 +39,10 @@ namespace Microsoft.Net.WebSockets _subProtocl = subProtocol; _state = WebSocketState.Open; _receiveBuffer = new byte[receiveBufferSize]; - _maskOutput = true; // TODO: make optional for client. Add option to block unmasking from server. + _maskOutput = true; // TODO: client only. _useZeroMask = false; // TODO: make optional + _unmaskInput = false; // TODO: server only + _writeLock = new SemaphoreSlim(1); } public override WebSocketCloseStatus? CloseStatus @@ -90,18 +95,28 @@ namespace Microsoft.Net.WebSockets // TODO: Check ping/pong state // TODO: Masking // TODO: Block close frame? - int mask = GetNextMask(); - FrameHeader frameHeader = new FrameHeader(endOfMessage, GetOpCode(messageType), _maskOutput, mask, buffer.Count); - ArraySegment segment = frameHeader.Buffer; - if (_maskOutput && mask != 0) + + await _writeLock.WaitAsync(cancellationToken); + + try { - byte[] maskedFrame = Utilities.MergeAndMask(mask, segment, buffer); - await _stream.WriteAsync(maskedFrame, 0, maskedFrame.Length, cancellationToken); + int mask = GetNextMask(); + FrameHeader frameHeader = new FrameHeader(endOfMessage, GetOpCode(messageType), _maskOutput, mask, buffer.Count); + ArraySegment segment = frameHeader.Buffer; + if (_maskOutput && mask != 0) + { + byte[] maskedFrame = Utilities.MergeAndMask(mask, segment, buffer); + await _stream.WriteAsync(maskedFrame, 0, maskedFrame.Length, cancellationToken); + } + else + { + await _stream.WriteAsync(segment.Array, segment.Offset, segment.Count, cancellationToken); + await _stream.WriteAsync(buffer.Array, buffer.Offset, buffer.Count, cancellationToken); + } } - else + finally { - await _stream.WriteAsync(segment.Array, segment.Offset, segment.Count, cancellationToken); - await _stream.WriteAsync(buffer.Array, buffer.Offset, buffer.Count, cancellationToken); + _writeLock.Release(); } } @@ -124,7 +139,7 @@ namespace Microsoft.Net.WebSockets // TODO: Check ping/pong state // No active frame - if (_frameInProgress == null) + while (_frameInProgress == null) { await EnsureDataAvailableOrReadAsync(2, cancellationToken); int frameHeaderSize = FrameHeader.CalculateFrameHeaderSize(_receiveBuffer[_receiveOffset + 1]); @@ -133,12 +148,27 @@ namespace Microsoft.Net.WebSockets _receiveOffset += frameHeaderSize; _receiveCount -= frameHeaderSize; _frameBytesRemaining = _frameInProgress.DataLength; + + // Ping or Pong frames + if (_frameInProgress.OpCode == Constants.OpCodes.PingFrame || _frameInProgress.OpCode == Constants.OpCodes.PongFrame) + { + // Drain it, should be less than 125 bytes + await EnsureDataAvailableOrReadAsync((int)_frameBytesRemaining, cancellationToken); + + if (_frameInProgress.OpCode == Constants.OpCodes.PingFrame && State == WebSocketState.Open) + { + await SendPongReply(cancellationToken); + } + + _receiveOffset += (int)_frameBytesRemaining; + _receiveCount -= (int)_frameBytesRemaining; + _frameBytesRemaining = 0; + _frameInProgress = null; + } } WebSocketReceiveResult result; - // TODO: Ping or Pong frames - if (_frameInProgress.OpCode == Constants.OpCodes.CloseFrame) { // TOOD: This assumes the close message fits in the buffer. @@ -197,6 +227,42 @@ namespace Microsoft.Net.WebSockets return result; } + // We received a ping, send a pong in reply + private async Task SendPongReply(CancellationToken cancellationToken) + { + // TODO: Unmask data + if (_unmaskInput != _frameInProgress.Masked) + { + throw new InvalidOperationException("Unmasking settings out of sync with data."); + } + ArraySegment dataSegment = new ArraySegment(_receiveBuffer, _receiveOffset, (int)_frameBytesRemaining); + if (_unmaskInput) + { + // In place + Utilities.Mask(_frameInProgress.MaskKey, dataSegment); + } + + int mask = GetNextMask(); + FrameHeader header = new FrameHeader(true, Constants.OpCodes.PongFrame, _maskOutput, mask, _frameBytesRemaining); + if (_maskOutput) + { + // In place + Utilities.Mask(_frameInProgress.MaskKey, dataSegment); + } + + await _writeLock.WaitAsync(cancellationToken); + try + { + ArraySegment headerSegment = header.Buffer; + await _stream.WriteAsync(headerSegment.Array, headerSegment.Offset, headerSegment.Count, cancellationToken); + await _stream.WriteAsync(dataSegment.Array, dataSegment.Offset, dataSegment.Count, cancellationToken); + } + finally + { + _writeLock.Release(); + } + } + private async Task EnsureDataAvailableOrReadAsync(int bytes, CancellationToken cancellationToken) { // Insufficient data diff --git a/src/Microsoft.Net.WebSockets/Constants.cs b/src/Microsoft.Net.WebSockets/Constants.cs index c7ebabaab7..740ea9ab41 100644 --- a/src/Microsoft.Net.WebSockets/Constants.cs +++ b/src/Microsoft.Net.WebSockets/Constants.cs @@ -19,7 +19,7 @@ namespace Microsoft.Net.WebSockets public const int TextFrame = 0x1; public const int BinaryFrame = 0x2; public const int CloseFrame = 0x8; - public const int PingFrame = 0x8; + public const int PingFrame = 0x9; public const int PongFrame = 0xA; } } diff --git a/src/Microsoft.Net.WebSockets/Utilities.cs b/src/Microsoft.Net.WebSockets/Utilities.cs index 2293dbb328..6dbc83630a 100644 --- a/src/Microsoft.Net.WebSockets/Utilities.cs +++ b/src/Microsoft.Net.WebSockets/Utilities.cs @@ -22,6 +22,11 @@ namespace Microsoft.Net.WebSockets // Un/Masks the data in place public static void Mask(int mask, ArraySegment data) { + if (mask == 0) + { + return; + } + byte[] maskBytes = new byte[] { (byte)(mask >> 24), From c34001ee683b9cfa6e247e86a4c8a7a685ed67f9 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Thu, 6 Mar 2014 10:30:09 -0800 Subject: [PATCH 005/453] Add test client and server apps. --- WebSockets.sln | 12 ++++ test/TestClient/App.config | 6 ++ test/TestClient/Program.cs | 36 ++++++++++++ test/TestClient/Properties/AssemblyInfo.cs | 36 ++++++++++++ test/TestClient/TestClient.csproj | 64 ++++++++++++++++++++++ test/TestServer/App.config | 6 ++ test/TestServer/Program.cs | 58 ++++++++++++++++++++ test/TestServer/Properties/AssemblyInfo.cs | 36 ++++++++++++ test/TestServer/TestServer.csproj | 58 ++++++++++++++++++++ 9 files changed, 312 insertions(+) create mode 100644 test/TestClient/App.config create mode 100644 test/TestClient/Program.cs create mode 100644 test/TestClient/Properties/AssemblyInfo.cs create mode 100644 test/TestClient/TestClient.csproj create mode 100644 test/TestServer/App.config create mode 100644 test/TestServer/Program.cs create mode 100644 test/TestServer/Properties/AssemblyInfo.cs create mode 100644 test/TestServer/TestServer.csproj diff --git a/WebSockets.sln b/WebSockets.sln index 98f957f7e5..abcfa94b4f 100644 --- a/WebSockets.sln +++ b/WebSockets.sln @@ -7,6 +7,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Net.WebSockets", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Net.WebSockets.Test", "test\Microsoft.Net.WebSockets.Test\Microsoft.Net.WebSockets.Test.csproj", "{EF1FE910-6E0C-4DE8-8CC1-6118B726A59E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestClient", "test\TestClient\TestClient.csproj", "{22AB02E0-0346-4C4B-BBE7-C829A8D1C19E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestServer", "test\TestServer\TestServer.csproj", "{4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +25,14 @@ Global {EF1FE910-6E0C-4DE8-8CC1-6118B726A59E}.Debug|Any CPU.Build.0 = Debug|Any CPU {EF1FE910-6E0C-4DE8-8CC1-6118B726A59E}.Release|Any CPU.ActiveCfg = Release|Any CPU {EF1FE910-6E0C-4DE8-8CC1-6118B726A59E}.Release|Any CPU.Build.0 = Release|Any CPU + {22AB02E0-0346-4C4B-BBE7-C829A8D1C19E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {22AB02E0-0346-4C4B-BBE7-C829A8D1C19E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {22AB02E0-0346-4C4B-BBE7-C829A8D1C19E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {22AB02E0-0346-4C4B-BBE7-C829A8D1C19E}.Release|Any CPU.Build.0 = Release|Any CPU + {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/test/TestClient/App.config b/test/TestClient/App.config new file mode 100644 index 0000000000..8e15646352 --- /dev/null +++ b/test/TestClient/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/test/TestClient/Program.cs b/test/TestClient/Program.cs new file mode 100644 index 0000000000..2c16bc5576 --- /dev/null +++ b/test/TestClient/Program.cs @@ -0,0 +1,36 @@ +using Microsoft.Net.WebSockets.Client; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.WebSockets; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace TestClient +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Waiting to start"); + Console.ReadKey(); + RunTestAsync().Wait(); + } + + private static async Task RunTestAsync() + { + WebSocketClient client = new WebSocketClient(); + WebSocket socket = await client.ConnectAsync(new Uri("ws://chrross-togo:12345/"), CancellationToken.None); + byte[] data = Encoding.UTF8.GetBytes("Hello World"); + while (true) + { + await socket.SendAsync(new ArraySegment(data), WebSocketMessageType.Text, true, CancellationToken.None); + WebSocketReceiveResult result = await socket.ReceiveAsync(new ArraySegment(data), CancellationToken.None); + Console.WriteLine(result.MessageType + ", " + result.Count + ", " + result.EndOfMessage); + Console.WriteLine(Encoding.UTF8.GetString(data, 0, result.Count)); + } + await socket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Closing", CancellationToken.None); + } + } +} diff --git a/test/TestClient/Properties/AssemblyInfo.cs b/test/TestClient/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..1ef2184108 --- /dev/null +++ b/test/TestClient/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TestClient")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("TestClient")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("0a30acb8-eb32-43ad-ab6c-36c070d6ba51")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/test/TestClient/TestClient.csproj b/test/TestClient/TestClient.csproj new file mode 100644 index 0000000000..842f76c15d --- /dev/null +++ b/test/TestClient/TestClient.csproj @@ -0,0 +1,64 @@ + + + + + Debug + AnyCPU + {22AB02E0-0346-4C4B-BBE7-C829A8D1C19E} + Exe + Properties + TestClient + TestClient + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + {6c1d09ca-f799-44ae-8ec8-9d19c76080c1} + Microsoft.Net.WebSockets + + + + + \ No newline at end of file diff --git a/test/TestServer/App.config b/test/TestServer/App.config new file mode 100644 index 0000000000..8e15646352 --- /dev/null +++ b/test/TestServer/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/test/TestServer/Program.cs b/test/TestServer/Program.cs new file mode 100644 index 0000000000..59b5825b55 --- /dev/null +++ b/test/TestServer/Program.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.WebSockets; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace TestServer +{ + class Program + { + static void Main(string[] args) + { + RunEchoServer().Wait(); + } + + private static async Task RunEchoServer() + { + HttpListener listener = new HttpListener(); + listener.Prefixes.Add("http://*:12345/"); + listener.Start(); + Console.WriteLine("Started"); + + while (true) + { + HttpListenerContext context = listener.GetContext(); + if (!context.Request.IsWebSocketRequest) + { + context.Response.Close(); + continue; + } + Console.WriteLine("Accepted"); + + var wsContext = await context.AcceptWebSocketAsync(null); + var webSocket = wsContext.WebSocket; + + byte[] buffer = new byte[1024]; + WebSocketReceiveResult received = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); + + while (received.MessageType != WebSocketMessageType.Close) + { + Console.WriteLine("Echo"); + // Echo anything we receive + await webSocket.SendAsync(new ArraySegment(buffer, 0, received.Count), received.MessageType, received.EndOfMessage, CancellationToken.None); + + received = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); + } + + await webSocket.CloseAsync(received.CloseStatus.Value, received.CloseStatusDescription, CancellationToken.None); + + webSocket.Dispose(); + Console.WriteLine("Finished"); + } + } + } +} diff --git a/test/TestServer/Properties/AssemblyInfo.cs b/test/TestServer/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..1a5999f7d8 --- /dev/null +++ b/test/TestServer/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TestServer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("TestServer")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ffe69337-e3b4-4625-8244-36bd609742ba")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/test/TestServer/TestServer.csproj b/test/TestServer/TestServer.csproj new file mode 100644 index 0000000000..24d42de384 --- /dev/null +++ b/test/TestServer/TestServer.csproj @@ -0,0 +1,58 @@ + + + + + Debug + AnyCPU + {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B} + Exe + Properties + TestServer + TestServer + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 1d5b4582f1166d56fb696d3b4a1a64308240091d Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Thu, 6 Mar 2014 12:32:46 -0800 Subject: [PATCH 006/453] Cleanup, unmasking. --- .../CommonWebSocket.cs | 116 +++++++++++------- .../WebSocketClient.cs | 2 +- 2 files changed, 73 insertions(+), 45 deletions(-) diff --git a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs index cae096cc94..b5fceae352 100644 --- a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs +++ b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs @@ -33,18 +33,28 @@ namespace Microsoft.Net.WebSockets private FrameHeader _frameInProgress; private long _frameBytesRemaining = 0; - public CommonWebSocket(Stream stream, string subProtocol, int receiveBufferSize) + public CommonWebSocket(Stream stream, string subProtocol, int receiveBufferSize, bool maskOutput, bool useZeroMask, bool unmaskInput) { _stream = stream; _subProtocl = subProtocol; _state = WebSocketState.Open; _receiveBuffer = new byte[receiveBufferSize]; - _maskOutput = true; // TODO: client only. - _useZeroMask = false; // TODO: make optional - _unmaskInput = false; // TODO: server only + _maskOutput = maskOutput; + _useZeroMask = useZeroMask; + _unmaskInput = unmaskInput; _writeLock = new SemaphoreSlim(1); } + public static CommonWebSocket CreateClientWebSocket(Stream stream, string subProtocol, int receiveBufferSize, bool useZeroMask) + { + return new CommonWebSocket(stream, subProtocol, receiveBufferSize, maskOutput: true, useZeroMask: useZeroMask, unmaskInput: false); + } + + public static CommonWebSocket CreateServerWebSocket(Stream stream, string subProtocol, int receiveBufferSize) + { + return new CommonWebSocket(stream, subProtocol, receiveBufferSize, maskOutput: false, useZeroMask: false, unmaskInput: true); + } + public override WebSocketCloseStatus? CloseStatus { get { return _closeStatus; } @@ -149,6 +159,11 @@ namespace Microsoft.Net.WebSockets _receiveCount -= frameHeaderSize; _frameBytesRemaining = _frameInProgress.DataLength; + if (_unmaskInput != _frameInProgress.Masked) + { + throw new InvalidOperationException("Unmasking settings out of sync with data."); + } + // Ping or Pong frames if (_frameInProgress.OpCode == Constants.OpCodes.PingFrame || _frameInProgress.OpCode == Constants.OpCodes.PongFrame) { @@ -171,13 +186,26 @@ namespace Microsoft.Net.WebSockets if (_frameInProgress.OpCode == Constants.OpCodes.CloseFrame) { - // TOOD: This assumes the close message fits in the buffer. - // TODO: Assert at least two bytes remaining for the close status code. + // The close message should be less than 125 bytes and fit in the buffer. await EnsureDataAvailableOrReadAsync((int)_frameBytesRemaining, CancellationToken.None); - // TODO: Unmask (server only) - // TODO: Throw if the client detects an incoming masked frame. - _closeStatus = (WebSocketCloseStatus)((_receiveBuffer[_receiveOffset] << 8) | _receiveBuffer[_receiveOffset + 1]); - _closeStatusDescription = Encoding.UTF8.GetString(_receiveBuffer, _receiveOffset + 2, _receiveCount - 2) ?? string.Empty; + + // Status code and message are optional + if (_frameBytesRemaining >= 2) + { + ArraySegment dataSegment = new ArraySegment(_receiveBuffer, _receiveOffset + 2, (int)_frameBytesRemaining - 2); + if (_unmaskInput) + { + // In place + Utilities.Mask(_frameInProgress.MaskKey, dataSegment); + } + _closeStatus = (WebSocketCloseStatus)((_receiveBuffer[_receiveOffset] << 8) | _receiveBuffer[_receiveOffset + 1]); + _closeStatusDescription = Encoding.UTF8.GetString(dataSegment.Array, dataSegment.Offset, dataSegment.Count) ?? string.Empty; + } + else + { + _closeStatus = _closeStatus ?? WebSocketCloseStatus.NormalClosure; + _closeStatusDescription = _closeStatusDescription ?? string.Empty; + } result = new WebSocketReceiveResult(0, WebSocketMessageType.Close, true, (WebSocketCloseStatus)_closeStatus, _closeStatusDescription); if (State == WebSocketState.Open) @@ -192,49 +220,44 @@ namespace Microsoft.Net.WebSockets return result; } - // Make sure there's at least some data in the buffer - if (_frameBytesRemaining > 0) - { - await EnsureDataAvailableOrReadAsync(1, cancellationToken); - } - - // Copy buffered data to the users buffer - int bytesToRead = (int)Math.Min((long)buffer.Count, _frameBytesRemaining); - if (_receiveCount > 0) - { - // TODO: Unmask - int bytesToCopy = Math.Min(bytesToRead, _receiveCount); - Array.Copy(_receiveBuffer, _receiveOffset, buffer.Array, buffer.Offset, bytesToCopy); - if (bytesToCopy == _frameBytesRemaining) - { - result = new WebSocketReceiveResult(bytesToCopy, GetMessageType(_frameInProgress.OpCode), _frameInProgress.Fin); - _frameInProgress = null; - } - else - { - result = new WebSocketReceiveResult(bytesToCopy, GetMessageType(_frameInProgress.OpCode), false); - } - _frameBytesRemaining -= bytesToCopy; - _receiveCount -= bytesToCopy; - _receiveOffset += bytesToCopy; - } - else + if (_frameBytesRemaining == 0) { // End of an empty frame? result = new WebSocketReceiveResult(0, GetMessageType(_frameInProgress.OpCode), true); + _frameInProgress = null; + return result; } + // Make sure there's at least some data in the buffer + await EnsureDataAvailableOrReadAsync(1, cancellationToken); + // Copy buffered data to the users buffer + int bytesToRead = (int)Math.Min((long)buffer.Count, _frameBytesRemaining); + int bytesToCopy = Math.Min(bytesToRead, _receiveCount); + Array.Copy(_receiveBuffer, _receiveOffset, buffer.Array, buffer.Offset, bytesToCopy); + if (_unmaskInput) + { + // TODO: mask alignment may be off between reads. + Utilities.Mask(_frameInProgress.MaskKey, new ArraySegment(buffer.Array, buffer.Offset, bytesToCopy)); + } + if (bytesToCopy == _frameBytesRemaining) + { + result = new WebSocketReceiveResult(bytesToCopy, GetMessageType(_frameInProgress.OpCode), _frameInProgress.Fin); + _frameInProgress = null; + } + else + { + result = new WebSocketReceiveResult(bytesToCopy, GetMessageType(_frameInProgress.OpCode), false); + } + _frameBytesRemaining -= bytesToCopy; + _receiveCount -= bytesToCopy; + _receiveOffset += bytesToCopy; + return result; } // We received a ping, send a pong in reply private async Task SendPongReply(CancellationToken cancellationToken) { - // TODO: Unmask data - if (_unmaskInput != _frameInProgress.Masked) - { - throw new InvalidOperationException("Unmasking settings out of sync with data."); - } ArraySegment dataSegment = new ArraySegment(_receiveBuffer, _receiveOffset, (int)_frameBytesRemaining); if (_unmaskInput) { @@ -359,8 +382,13 @@ namespace Microsoft.Net.WebSockets fullData[1] = (byte)closeStatus; Array.Copy(descriptionBytes, 0, fullData, 2, descriptionBytes.Length); - // TODO: Masking - FrameHeader frameHeader = new FrameHeader(true, Constants.OpCodes.CloseFrame, true, 0, fullData.Length); + int mask = GetNextMask(); + if (_maskOutput) + { + Utilities.Mask(mask, new ArraySegment(fullData)); + } + + FrameHeader frameHeader = new FrameHeader(true, Constants.OpCodes.CloseFrame, _maskOutput, mask, fullData.Length); ArraySegment segment = frameHeader.Buffer; await _stream.WriteAsync(segment.Array, segment.Offset, segment.Count, cancellationToken); await _stream.WriteAsync(fullData, 0, fullData.Length, cancellationToken); diff --git a/src/Microsoft.Net.WebSockets/WebSocketClient.cs b/src/Microsoft.Net.WebSockets/WebSocketClient.cs index 1a32277d8f..a78b2f5e17 100644 --- a/src/Microsoft.Net.WebSockets/WebSocketClient.cs +++ b/src/Microsoft.Net.WebSockets/WebSocketClient.cs @@ -49,7 +49,7 @@ namespace Microsoft.Net.WebSockets.Client Stream stream = response.GetResponseStream(); // Console.WriteLine(stream.CanWrite + " " + stream.CanRead); - return new CommonWebSocket(stream, null, ReceiveBufferSize); + return CommonWebSocket.CreateClientWebSocket(stream, null, ReceiveBufferSize, useZeroMask: false); } } } From 1bd9bf1714aaa95deefd819b1d04840bb0cc7450 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Thu, 6 Mar 2014 13:50:04 -0800 Subject: [PATCH 007/453] Implement continuation frames. --- .../CommonWebSocket.cs | 37 ++++++- src/Microsoft.Net.WebSockets/Constants.cs | 1 + .../WebSocketClientTests.cs | 102 ++++++++++++++++++ 3 files changed, 135 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs index b5fceae352..ff6b9f44a9 100644 --- a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs +++ b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs @@ -26,12 +26,15 @@ namespace Microsoft.Net.WebSockets private WebSocketCloseStatus? _closeStatus; private string _closeStatusDescription; + private bool _outgoingMessageInProgress; + private byte[] _receiveBuffer; private int _receiveOffset; private int _receiveCount; private FrameHeader _frameInProgress; private long _frameBytesRemaining = 0; + private int? _firstDataOpCode; public CommonWebSocket(Stream stream, string subProtocol, int receiveBufferSize, bool maskOutput, bool useZeroMask, bool unmaskInput) { @@ -111,7 +114,7 @@ namespace Microsoft.Net.WebSockets try { int mask = GetNextMask(); - FrameHeader frameHeader = new FrameHeader(endOfMessage, GetOpCode(messageType), _maskOutput, mask, buffer.Count); + FrameHeader frameHeader = new FrameHeader(endOfMessage, _outgoingMessageInProgress ? Constants.OpCodes.ContinuationFrame : GetOpCode(messageType), _maskOutput, mask, buffer.Count); ArraySegment segment = frameHeader.Buffer; if (_maskOutput && mask != 0) { @@ -123,6 +126,7 @@ namespace Microsoft.Net.WebSockets await _stream.WriteAsync(segment.Array, segment.Offset, segment.Count, cancellationToken); await _stream.WriteAsync(buffer.Array, buffer.Offset, buffer.Count, cancellationToken); } + _outgoingMessageInProgress = !endOfMessage; } finally { @@ -182,9 +186,32 @@ namespace Microsoft.Net.WebSockets } } + // Handle fragmentation, remember the first frame type + int opCode = 0; + if (_frameInProgress.OpCode == Constants.OpCodes.BinaryFrame + || _frameInProgress.OpCode == Constants.OpCodes.TextFrame + || _frameInProgress.OpCode == Constants.OpCodes.CloseFrame) + { + opCode = _frameInProgress.OpCode; + _firstDataOpCode = opCode; + } + else if (_frameInProgress.OpCode == Constants.OpCodes.ContinuationFrame) + { + if (!_firstDataOpCode.HasValue) + { + throw new InvalidOperationException("A continuation can't be the first frame"); + } + opCode = _firstDataOpCode.Value; + } + + if (_frameInProgress.Fin) + { + _firstDataOpCode = null; + } + WebSocketReceiveResult result; - if (_frameInProgress.OpCode == Constants.OpCodes.CloseFrame) + if (opCode == Constants.OpCodes.CloseFrame) { // The close message should be less than 125 bytes and fit in the buffer. await EnsureDataAvailableOrReadAsync((int)_frameBytesRemaining, CancellationToken.None); @@ -223,7 +250,7 @@ namespace Microsoft.Net.WebSockets if (_frameBytesRemaining == 0) { // End of an empty frame? - result = new WebSocketReceiveResult(0, GetMessageType(_frameInProgress.OpCode), true); + result = new WebSocketReceiveResult(0, GetMessageType(opCode), _frameInProgress.Fin); _frameInProgress = null; return result; } @@ -241,12 +268,12 @@ namespace Microsoft.Net.WebSockets } if (bytesToCopy == _frameBytesRemaining) { - result = new WebSocketReceiveResult(bytesToCopy, GetMessageType(_frameInProgress.OpCode), _frameInProgress.Fin); + result = new WebSocketReceiveResult(bytesToCopy, GetMessageType(opCode), _frameInProgress.Fin); _frameInProgress = null; } else { - result = new WebSocketReceiveResult(bytesToCopy, GetMessageType(_frameInProgress.OpCode), false); + result = new WebSocketReceiveResult(bytesToCopy, GetMessageType(opCode), false); } _frameBytesRemaining -= bytesToCopy; _receiveCount -= bytesToCopy; diff --git a/src/Microsoft.Net.WebSockets/Constants.cs b/src/Microsoft.Net.WebSockets/Constants.cs index 740ea9ab41..8fb002913e 100644 --- a/src/Microsoft.Net.WebSockets/Constants.cs +++ b/src/Microsoft.Net.WebSockets/Constants.cs @@ -16,6 +16,7 @@ namespace Microsoft.Net.WebSockets public static class OpCodes { + public const int ContinuationFrame = 0x0; public const int TextFrame = 0x1; public const int BinaryFrame = 0x2; public const int CloseFrame = 0x8; diff --git a/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs b/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs index 7443cc0c7b..a466271278 100644 --- a/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs +++ b/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs @@ -145,6 +145,57 @@ namespace Microsoft.Net.WebSockets.Test } } + [Fact] + public async Task SendFragmentedData_Success() + { + using (HttpListener listener = new HttpListener()) + { + listener.Prefixes.Add(ServerAddress); + listener.Start(); + Task serverAccept = listener.GetContextAsync(); + + WebSocketClient client = new WebSocketClient(); + Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + + HttpListenerContext serverContext = await serverAccept; + Assert.True(serverContext.Request.IsWebSocketRequest); + HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); + WebSocket serverSocket = serverWebSocketContext.WebSocket; + + WebSocket clientSocket = await clientConnect; + + byte[] orriginalData = Encoding.UTF8.GetBytes("Hello World"); + await clientSocket.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); + await clientSocket.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); + await clientSocket.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); + + byte[] serverBuffer = new byte[orriginalData.Length]; + WebSocketReceiveResult result = await serverSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.False(result.EndOfMessage); + Assert.Equal(2, result.Count); + int totalReceived = result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + result = await serverSocket.ReceiveAsync( + new ArraySegment(serverBuffer, totalReceived, serverBuffer.Length - totalReceived), CancellationToken.None); + Assert.False(result.EndOfMessage); + Assert.Equal(2, result.Count); + totalReceived += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + result = await serverSocket.ReceiveAsync( + new ArraySegment(serverBuffer, totalReceived, serverBuffer.Length - totalReceived), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(7, result.Count); + totalReceived += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + Assert.Equal(orriginalData, serverBuffer); + + clientSocket.Dispose(); + } + } + [Fact] public async Task ReceiveShortData_Success() { @@ -281,6 +332,57 @@ namespace Microsoft.Net.WebSockets.Test } } + [Fact] + public async Task ReceiveFragmentedData_Success() + { + using (HttpListener listener = new HttpListener()) + { + listener.Prefixes.Add(ServerAddress); + listener.Start(); + Task serverAccept = listener.GetContextAsync(); + + WebSocketClient client = new WebSocketClient(); + Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + + HttpListenerContext serverContext = await serverAccept; + Assert.True(serverContext.Request.IsWebSocketRequest); + HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); + WebSocket serverSocket = serverWebSocketContext.WebSocket; + + WebSocket clientSocket = await clientConnect; + + byte[] orriginalData = Encoding.UTF8.GetBytes("Hello World"); + await serverSocket.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); + await serverSocket.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); + await serverSocket.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); + + byte[] serverBuffer = new byte[orriginalData.Length]; + WebSocketReceiveResult result = await clientSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.False(result.EndOfMessage); + Assert.Equal(2, result.Count); + int totalReceived = result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + result = await clientSocket.ReceiveAsync( + new ArraySegment(serverBuffer, totalReceived, serverBuffer.Length - totalReceived), CancellationToken.None); + Assert.False(result.EndOfMessage); + Assert.Equal(2, result.Count); + totalReceived += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + result = await clientSocket.ReceiveAsync( + new ArraySegment(serverBuffer, totalReceived, serverBuffer.Length - totalReceived), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(7, result.Count); + totalReceived += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + Assert.Equal(orriginalData, serverBuffer); + + clientSocket.Dispose(); + } + } + [Fact] public async Task SendClose_Success() { From 6ecc36de5ab7f297d8fb80baa3a1d013c9382ce6 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Fri, 7 Mar 2014 09:36:17 -0800 Subject: [PATCH 008/453] Cleanup, argument validation. --- .../CommonWebSocket.cs | 418 ++++++++++-------- src/Microsoft.Net.WebSockets/Utilities.cs | 31 +- .../WebSocketClient.cs | 48 +- .../UtilitiesTests.cs | 7 +- .../WebSocketClientTests.cs | 2 - 5 files changed, 297 insertions(+), 209 deletions(-) diff --git a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs index ff6b9f44a9..6930e38c4e 100644 --- a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs +++ b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs @@ -1,7 +1,6 @@ using System; -using System.Collections.Generic; +using System.Diagnostics.Contracts; using System.IO; -using System.Linq; using System.Net.WebSockets; using System.Text; using System.Threading; @@ -26,14 +25,14 @@ namespace Microsoft.Net.WebSockets private WebSocketCloseStatus? _closeStatus; private string _closeStatusDescription; - private bool _outgoingMessageInProgress; + private bool _isOutgoingMessageInProgress; private byte[] _receiveBuffer; - private int _receiveOffset; - private int _receiveCount; + private int _receiveBufferOffset; + private int _receiveBufferBytes; private FrameHeader _frameInProgress; - private long _frameBytesRemaining = 0; + private long _frameBytesRemaining; private int? _firstDataOpCode; public CommonWebSocket(Stream stream, string subProtocol, int receiveBufferSize, bool maskOutput, bool useZeroMask, bool unmaskInput) @@ -102,31 +101,38 @@ namespace Microsoft.Net.WebSockets public override async Task SendAsync(ArraySegment buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken) { - // TODO: Validate arguments - // TODO: Check state - // TODO: Check concurrent writes - // TODO: Check ping/pong state - // TODO: Masking - // TODO: Block close frame? + ValidateSegment(buffer); + if (messageType != WebSocketMessageType.Binary && messageType != WebSocketMessageType.Text) + { + // Block control frames + throw new ArgumentOutOfRangeException("messageType", messageType, string.Empty); + } + // Check concurrent writes, pings & pongs, or closes await _writeLock.WaitAsync(cancellationToken); - try { + ThrowIfDisposed(); + ThrowIfOutputClosed(); + int mask = GetNextMask(); - FrameHeader frameHeader = new FrameHeader(endOfMessage, _outgoingMessageInProgress ? Constants.OpCodes.ContinuationFrame : GetOpCode(messageType), _maskOutput, mask, buffer.Count); - ArraySegment segment = frameHeader.Buffer; + int opcode = _isOutgoingMessageInProgress ? Constants.OpCodes.ContinuationFrame : Utilities.GetOpCode(messageType); + FrameHeader frameHeader = new FrameHeader(endOfMessage, opcode, _maskOutput, mask, buffer.Count); + ArraySegment headerSegment = frameHeader.Buffer; + if (_maskOutput && mask != 0) { - byte[] maskedFrame = Utilities.MergeAndMask(mask, segment, buffer); + // TODO: For larger messages consider using a limited size buffer and masking & sending in segments. + byte[] maskedFrame = Utilities.MergeAndMask(mask, headerSegment, buffer); await _stream.WriteAsync(maskedFrame, 0, maskedFrame.Length, cancellationToken); } else { - await _stream.WriteAsync(segment.Array, segment.Offset, segment.Count, cancellationToken); + await _stream.WriteAsync(headerSegment.Array, headerSegment.Offset, headerSegment.Count, cancellationToken); await _stream.WriteAsync(buffer.Array, buffer.Offset, buffer.Count, cancellationToken); } - _outgoingMessageInProgress = !endOfMessage; + + _isOutgoingMessageInProgress = !endOfMessage; } finally { @@ -134,60 +140,21 @@ namespace Microsoft.Net.WebSockets } } - private int GetOpCode(WebSocketMessageType messageType) - { - switch (messageType) - { - case WebSocketMessageType.Text: return Constants.OpCodes.TextFrame; - case WebSocketMessageType.Binary: return Constants.OpCodes.BinaryFrame; - case WebSocketMessageType.Close: return Constants.OpCodes.CloseFrame; - default: throw new NotImplementedException(messageType.ToString()); - } - } - public async override Task ReceiveAsync(ArraySegment buffer, CancellationToken cancellationToken) { - // TODO: Validate arguments - // TODO: Check state - // TODO: Check concurrent reads - // TODO: Check ping/pong state + ThrowIfDisposed(); + ThrowIfInputClosed(); + ValidateSegment(buffer); + // TODO: InvalidOperationException if any receives are currently in progress. - // No active frame + // No active frame. Loop because we may be discarding ping/pong frames. while (_frameInProgress == null) { - await EnsureDataAvailableOrReadAsync(2, cancellationToken); - int frameHeaderSize = FrameHeader.CalculateFrameHeaderSize(_receiveBuffer[_receiveOffset + 1]); - await EnsureDataAvailableOrReadAsync(frameHeaderSize, cancellationToken); - _frameInProgress = new FrameHeader(new ArraySegment(_receiveBuffer, _receiveOffset, frameHeaderSize)); - _receiveOffset += frameHeaderSize; - _receiveCount -= frameHeaderSize; - _frameBytesRemaining = _frameInProgress.DataLength; - - if (_unmaskInput != _frameInProgress.Masked) - { - throw new InvalidOperationException("Unmasking settings out of sync with data."); - } - - // Ping or Pong frames - if (_frameInProgress.OpCode == Constants.OpCodes.PingFrame || _frameInProgress.OpCode == Constants.OpCodes.PongFrame) - { - // Drain it, should be less than 125 bytes - await EnsureDataAvailableOrReadAsync((int)_frameBytesRemaining, cancellationToken); - - if (_frameInProgress.OpCode == Constants.OpCodes.PingFrame && State == WebSocketState.Open) - { - await SendPongReply(cancellationToken); - } - - _receiveOffset += (int)_frameBytesRemaining; - _receiveCount -= (int)_frameBytesRemaining; - _frameBytesRemaining = 0; - _frameInProgress = null; - } + await ReadNextFrameAsync(cancellationToken); } // Handle fragmentation, remember the first frame type - int opCode = 0; + int opCode = Constants.OpCodes.ContinuationFrame; if (_frameInProgress.OpCode == Constants.OpCodes.BinaryFrame || _frameInProgress.OpCode == Constants.OpCodes.TextFrame || _frameInProgress.OpCode == Constants.OpCodes.CloseFrame) @@ -209,48 +176,18 @@ namespace Microsoft.Net.WebSockets _firstDataOpCode = null; } - WebSocketReceiveResult result; - if (opCode == Constants.OpCodes.CloseFrame) { - // The close message should be less than 125 bytes and fit in the buffer. - await EnsureDataAvailableOrReadAsync((int)_frameBytesRemaining, CancellationToken.None); - - // Status code and message are optional - if (_frameBytesRemaining >= 2) - { - ArraySegment dataSegment = new ArraySegment(_receiveBuffer, _receiveOffset + 2, (int)_frameBytesRemaining - 2); - if (_unmaskInput) - { - // In place - Utilities.Mask(_frameInProgress.MaskKey, dataSegment); - } - _closeStatus = (WebSocketCloseStatus)((_receiveBuffer[_receiveOffset] << 8) | _receiveBuffer[_receiveOffset + 1]); - _closeStatusDescription = Encoding.UTF8.GetString(dataSegment.Array, dataSegment.Offset, dataSegment.Count) ?? string.Empty; - } - else - { - _closeStatus = _closeStatus ?? WebSocketCloseStatus.NormalClosure; - _closeStatusDescription = _closeStatusDescription ?? string.Empty; - } - result = new WebSocketReceiveResult(0, WebSocketMessageType.Close, true, (WebSocketCloseStatus)_closeStatus, _closeStatusDescription); - - if (State == WebSocketState.Open) - { - _state = WebSocketState.CloseReceived; - } - else if (State == WebSocketState.CloseSent) - { - _state = WebSocketState.Closed; - _stream.Dispose(); - } - return result; + return await ProcessCloseFrameAsync(cancellationToken); } + WebSocketReceiveResult result; + + WebSocketMessageType messageType = Utilities.GetMessageType(opCode); if (_frameBytesRemaining == 0) { // End of an empty frame? - result = new WebSocketReceiveResult(0, GetMessageType(opCode), _frameInProgress.Fin); + result = new WebSocketReceiveResult(0, messageType, _frameInProgress.Fin); _frameInProgress = null; return result; } @@ -259,50 +196,116 @@ namespace Microsoft.Net.WebSockets await EnsureDataAvailableOrReadAsync(1, cancellationToken); // Copy buffered data to the users buffer int bytesToRead = (int)Math.Min((long)buffer.Count, _frameBytesRemaining); - int bytesToCopy = Math.Min(bytesToRead, _receiveCount); - Array.Copy(_receiveBuffer, _receiveOffset, buffer.Array, buffer.Offset, bytesToCopy); + int bytesToCopy = Math.Min(bytesToRead, _receiveBufferBytes); + Array.Copy(_receiveBuffer, _receiveBufferOffset, buffer.Array, buffer.Offset, bytesToCopy); if (_unmaskInput) { // TODO: mask alignment may be off between reads. - Utilities.Mask(_frameInProgress.MaskKey, new ArraySegment(buffer.Array, buffer.Offset, bytesToCopy)); + // _frameInProgress.Masked == _unmaskInput already verified + Utilities.MaskInPlace(_frameInProgress.MaskKey, new ArraySegment(buffer.Array, buffer.Offset, bytesToCopy)); } if (bytesToCopy == _frameBytesRemaining) { - result = new WebSocketReceiveResult(bytesToCopy, GetMessageType(opCode), _frameInProgress.Fin); + result = new WebSocketReceiveResult(bytesToCopy, messageType, _frameInProgress.Fin); _frameInProgress = null; } else { - result = new WebSocketReceiveResult(bytesToCopy, GetMessageType(opCode), false); + result = new WebSocketReceiveResult(bytesToCopy, messageType, false); } _frameBytesRemaining -= bytesToCopy; - _receiveCount -= bytesToCopy; - _receiveOffset += bytesToCopy; + _receiveBufferBytes -= bytesToCopy; + _receiveBufferOffset += bytesToCopy; return result; } - // We received a ping, send a pong in reply - private async Task SendPongReply(CancellationToken cancellationToken) + private async Task ReadNextFrameAsync(CancellationToken cancellationToken) { - ArraySegment dataSegment = new ArraySegment(_receiveBuffer, _receiveOffset, (int)_frameBytesRemaining); - if (_unmaskInput) + await EnsureDataAvailableOrReadAsync(2, cancellationToken); + int frameHeaderSize = FrameHeader.CalculateFrameHeaderSize(_receiveBuffer[_receiveBufferOffset + 1]); + await EnsureDataAvailableOrReadAsync(frameHeaderSize, cancellationToken); + _frameInProgress = new FrameHeader(new ArraySegment(_receiveBuffer, _receiveBufferOffset, frameHeaderSize)); + _receiveBufferOffset += frameHeaderSize; + _receiveBufferBytes -= frameHeaderSize; + _frameBytesRemaining = _frameInProgress.DataLength; + + if (_unmaskInput != _frameInProgress.Masked) { - // In place - Utilities.Mask(_frameInProgress.MaskKey, dataSegment); + throw new InvalidOperationException("Unmasking settings out of sync with data."); } - int mask = GetNextMask(); - FrameHeader header = new FrameHeader(true, Constants.OpCodes.PongFrame, _maskOutput, mask, _frameBytesRemaining); - if (_maskOutput) + if (_frameInProgress.OpCode == Constants.OpCodes.PingFrame || _frameInProgress.OpCode == Constants.OpCodes.PongFrame) { - // In place - Utilities.Mask(_frameInProgress.MaskKey, dataSegment); - } + // Drain it, should be less than 125 bytes + await EnsureDataAvailableOrReadAsync((int)_frameBytesRemaining, cancellationToken); + if (_frameInProgress.OpCode == Constants.OpCodes.PingFrame) + { + await SendPongReplyAsync(cancellationToken); + } + + _receiveBufferOffset += (int)_frameBytesRemaining; + _receiveBufferBytes -= (int)_frameBytesRemaining; + _frameBytesRemaining = 0; + _frameInProgress = null; + } + } + + private async Task EnsureDataAvailableOrReadAsync(int bytesNeeded, CancellationToken cancellationToken) + { + // Adequate buffer space? + Contract.Assert(bytesNeeded <= _receiveBuffer.Length); + + // Insufficient buffered data + while (_receiveBufferBytes < bytesNeeded) + { + cancellationToken.ThrowIfCancellationRequested(); + + int spaceRemaining = _receiveBuffer.Length - (_receiveBufferOffset + _receiveBufferBytes); + if (_receiveBufferOffset > 0 && bytesNeeded > spaceRemaining) + { + // Some data in the buffer, shift down to make room + Array.Copy(_receiveBuffer, _receiveBufferOffset, _receiveBuffer, 0, _receiveBufferBytes); + _receiveBufferOffset = 0; + spaceRemaining = _receiveBuffer.Length - _receiveBufferBytes; + } + // Add to the end + int read = await _stream.ReadAsync(_receiveBuffer, _receiveBufferOffset + _receiveBufferBytes, spaceRemaining, cancellationToken); + if (read == 0) + { + throw new IOException("Unexpected end of stream"); + } + _receiveBufferBytes += read; + } + } + + // We received a ping, send a pong in reply + private async Task SendPongReplyAsync(CancellationToken cancellationToken) + { await _writeLock.WaitAsync(cancellationToken); try { + if (State != WebSocketState.Open) + { + // Output closed, discard the pong. + return; + } + + ArraySegment dataSegment = new ArraySegment(_receiveBuffer, _receiveBufferOffset, (int)_frameBytesRemaining); + if (_unmaskInput) + { + // _frameInProgress.Masked == _unmaskInput already verified + Utilities.MaskInPlace(_frameInProgress.MaskKey, dataSegment); + } + + int mask = GetNextMask(); + FrameHeader header = new FrameHeader(true, Constants.OpCodes.PongFrame, _maskOutput, mask, _frameBytesRemaining); + if (_maskOutput) + { + Utilities.MaskInPlace(mask, dataSegment); + } + ArraySegment headerSegment = header.Buffer; await _stream.WriteAsync(headerSegment.Array, headerSegment.Offset, headerSegment.Count, cancellationToken); await _stream.WriteAsync(dataSegment.Array, dataSegment.Offset, dataSegment.Count, cancellationToken); @@ -313,49 +316,47 @@ namespace Microsoft.Net.WebSockets } } - private async Task EnsureDataAvailableOrReadAsync(int bytes, CancellationToken cancellationToken) + private async Task ProcessCloseFrameAsync(CancellationToken cancellationToken) { - // Insufficient data - while (_receiveCount < bytes && bytes <= _receiveBuffer.Length) - { - // Some data in the buffer, shift down to make room - if (_receiveCount > 0 && _receiveOffset > 0) - { - Array.Copy(_receiveBuffer, _receiveOffset, _receiveBuffer, 0, _receiveCount); - } - _receiveOffset = 0; - // Add to the end - int read = await _stream.ReadAsync(_receiveBuffer, _receiveCount, _receiveBuffer.Length - (_receiveCount), cancellationToken); - if (read == 0) - { - throw new IOException("Unexpected end of stream"); - } - _receiveCount += read; - } - } + // The close message should be less than 125 bytes and fit in the buffer. + await EnsureDataAvailableOrReadAsync((int)_frameBytesRemaining, CancellationToken.None); - private WebSocketMessageType GetMessageType(int opCode) - { - switch (opCode) + // Status code and message are optional + if (_frameBytesRemaining >= 2) { - case Constants.OpCodes.TextFrame: return WebSocketMessageType.Text; - case Constants.OpCodes.BinaryFrame: return WebSocketMessageType.Binary; - case Constants.OpCodes.CloseFrame: return WebSocketMessageType.Close; - default: throw new NotImplementedException(opCode.ToString()); + if (_unmaskInput) + { + Utilities.MaskInPlace(_frameInProgress.MaskKey, new ArraySegment(_receiveBuffer, _receiveBufferOffset, (int)_frameBytesRemaining)); + } + _closeStatus = (WebSocketCloseStatus)((_receiveBuffer[_receiveBufferOffset] << 8) | _receiveBuffer[_receiveBufferOffset + 1]); + _closeStatusDescription = Encoding.UTF8.GetString(_receiveBuffer, _receiveBufferOffset + 2, (int)_frameBytesRemaining - 2) ?? string.Empty; } + else + { + _closeStatus = _closeStatus ?? WebSocketCloseStatus.NormalClosure; + _closeStatusDescription = _closeStatusDescription ?? string.Empty; + } + + Contract.Assert(_frameInProgress.Fin); + WebSocketReceiveResult result = new WebSocketReceiveResult(0, WebSocketMessageType.Close, _frameInProgress.Fin, + _closeStatus.Value, _closeStatusDescription); + + if (State == WebSocketState.Open) + { + _state = WebSocketState.CloseReceived; + } + else if (State == WebSocketState.CloseSent) + { + _state = WebSocketState.Closed; + _stream.Dispose(); + } + + return result; } public async override Task CloseAsync(WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken) { - // TODO: Validate arguments - // TODO: Check state - // TODO: Check concurrent writes - // TODO: Check ping/pong state - - if (State >= WebSocketState.Closed) - { - throw new InvalidOperationException("Already closed."); - } + ThrowIfDisposed(); if (State == WebSocketState.Open || State == WebSocketState.CloseReceived) { @@ -373,52 +374,49 @@ namespace Microsoft.Net.WebSockets result = await ReceiveAsync(new ArraySegment(data), cancellationToken); } while (result.MessageType != WebSocketMessageType.Close); - - _closeStatus = result.CloseStatus; - _closeStatusDescription = result.CloseStatusDescription; } - - _state = WebSocketState.Closed; - _stream.Dispose(); } public override async Task CloseOutputAsync(WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken) { - // TODO: Validate arguments - // TODO: Check state - // TODO: Check concurrent writes - // TODO: Check ping/pong state - - if (State == WebSocketState.CloseSent || State >= WebSocketState.Closed) + await _writeLock.WaitAsync(cancellationToken); + try { - throw new InvalidOperationException("Already closed."); - } + ThrowIfDisposed(); + ThrowIfOutputClosed(); - if (State == WebSocketState.Open) + byte[] descriptionBytes = Encoding.UTF8.GetBytes(statusDescription ?? string.Empty); + byte[] fullData = new byte[descriptionBytes.Length + 2]; + fullData[0] = (byte)((int)closeStatus >> 8); + fullData[1] = (byte)closeStatus; + Array.Copy(descriptionBytes, 0, fullData, 2, descriptionBytes.Length); + + int mask = GetNextMask(); + if (_maskOutput) + { + Utilities.MaskInPlace(mask, new ArraySegment(fullData)); + } + + FrameHeader frameHeader = new FrameHeader(true, Constants.OpCodes.CloseFrame, _maskOutput, mask, fullData.Length); + + ArraySegment segment = frameHeader.Buffer; + await _stream.WriteAsync(segment.Array, segment.Offset, segment.Count, cancellationToken); + await _stream.WriteAsync(fullData, 0, fullData.Length, cancellationToken); + + if (State == WebSocketState.Open) + { + _state = WebSocketState.CloseSent; + } + else if (State == WebSocketState.CloseReceived) + { + _state = WebSocketState.Closed; + _stream.Dispose(); + } + } + finally { - _state = WebSocketState.CloseSent; + _writeLock.Release(); } - else if (State == WebSocketState.CloseReceived) - { - _state = WebSocketState.Closed; - } - - byte[] descriptionBytes = Encoding.UTF8.GetBytes(statusDescription ?? string.Empty); - byte[] fullData = new byte[descriptionBytes.Length + 2]; - fullData[0] = (byte)((int)closeStatus >> 8); - fullData[1] = (byte)closeStatus; - Array.Copy(descriptionBytes, 0, fullData, 2, descriptionBytes.Length); - - int mask = GetNextMask(); - if (_maskOutput) - { - Utilities.Mask(mask, new ArraySegment(fullData)); - } - - FrameHeader frameHeader = new FrameHeader(true, Constants.OpCodes.CloseFrame, _maskOutput, mask, fullData.Length); - ArraySegment segment = frameHeader.Buffer; - await _stream.WriteAsync(segment.Array, segment.Offset, segment.Count, cancellationToken); - await _stream.WriteAsync(fullData, 0, fullData.Length, cancellationToken); } public override void Abort() @@ -442,5 +440,45 @@ namespace Microsoft.Net.WebSockets _state = WebSocketState.Closed; _stream.Dispose(); } + + private void ThrowIfDisposed() + { + if (_state >= WebSocketState.Closed) // or Aborted + { + throw new ObjectDisposedException(typeof(CommonWebSocket).FullName); + } + } + + private void ThrowIfOutputClosed() + { + if (State == WebSocketState.CloseSent) + { + throw new InvalidOperationException("Close already sent."); + } + } + + private void ThrowIfInputClosed() + { + if (State == WebSocketState.CloseReceived) + { + throw new InvalidOperationException("Close already received."); + } + } + + private void ValidateSegment(ArraySegment buffer) + { + if (buffer.Array == null) + { + throw new ArgumentNullException("buffer"); + } + if (buffer.Offset < 0 || buffer.Offset >= buffer.Array.Length) + { + throw new ArgumentOutOfRangeException("buffer.Offset", buffer.Offset, string.Empty); + } + if (buffer.Count <= 0 || buffer.Count > buffer.Array.Length - buffer.Offset) + { + throw new ArgumentOutOfRangeException("buffer.Count", buffer.Count, string.Empty); + } + } } } diff --git a/src/Microsoft.Net.WebSockets/Utilities.cs b/src/Microsoft.Net.WebSockets/Utilities.cs index 6dbc83630a..35be77a857 100644 --- a/src/Microsoft.Net.WebSockets/Utilities.cs +++ b/src/Microsoft.Net.WebSockets/Utilities.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Net.WebSockets; namespace Microsoft.Net.WebSockets { @@ -15,12 +12,12 @@ namespace Microsoft.Net.WebSockets Array.Copy(header.Array, header.Offset, frame, 0, header.Count); Array.Copy(data.Array, data.Offset, frame, header.Count, data.Count); - Mask(mask, new ArraySegment(frame, header.Count, data.Count)); + MaskInPlace(mask, new ArraySegment(frame, header.Count, data.Count)); return frame; } // Un/Masks the data in place - public static void Mask(int mask, ArraySegment data) + public static void MaskInPlace(int mask, ArraySegment data) { if (mask == 0) { @@ -42,5 +39,27 @@ namespace Microsoft.Net.WebSockets maskOffset = (maskOffset + 1) % 4; } } + + public static int GetOpCode(WebSocketMessageType messageType) + { + switch (messageType) + { + case WebSocketMessageType.Text: return Constants.OpCodes.TextFrame; + case WebSocketMessageType.Binary: return Constants.OpCodes.BinaryFrame; + case WebSocketMessageType.Close: return Constants.OpCodes.CloseFrame; + default: throw new NotImplementedException(messageType.ToString()); + } + } + + public static WebSocketMessageType GetMessageType(int opCode) + { + switch (opCode) + { + case Constants.OpCodes.TextFrame: return WebSocketMessageType.Text; + case Constants.OpCodes.BinaryFrame: return WebSocketMessageType.Binary; + case Constants.OpCodes.CloseFrame: return WebSocketMessageType.Close; + default: throw new NotImplementedException(opCode.ToString()); + } + } } } diff --git a/src/Microsoft.Net.WebSockets/WebSocketClient.cs b/src/Microsoft.Net.WebSockets/WebSocketClient.cs index a78b2f5e17..d1ec49b4d5 100644 --- a/src/Microsoft.Net.WebSockets/WebSocketClient.cs +++ b/src/Microsoft.Net.WebSockets/WebSocketClient.cs @@ -1,10 +1,7 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Net; using System.Net.WebSockets; -using System.Text; using System.Threading; using System.Threading.Tasks; @@ -36,20 +33,59 @@ namespace Microsoft.Net.WebSockets.Client set; } + public bool UseZeroMask + { + get; + set; + } + + public Action ConfigureRequest + { + get; + set; + } + + public Action InspectResponse + { + get; + set; + } + public async Task ConnectAsync(Uri uri, CancellationToken cancellationToken) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); + CancellationTokenRegistration cancellation = cancellationToken.Register(() => request.Abort()); + request.Headers[Constants.Headers.WebSocketVersion] = Constants.Headers.SupportedVersion; // TODO: Sub-protocols - WebResponse response = await request.GetResponseAsync(); + if (ConfigureRequest != null) + { + ConfigureRequest(request); + } + + HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync(); + + cancellation.Dispose(); + + if (InspectResponse != null) + { + InspectResponse(response); + } + // TODO: Validate handshake + if (response.StatusCode != HttpStatusCode.SwitchingProtocols) + { + response.Dispose(); + throw new InvalidOperationException("Incomplete handshake"); + } + + // TODO: Sub protocol Stream stream = response.GetResponseStream(); - // Console.WriteLine(stream.CanWrite + " " + stream.CanRead); - return CommonWebSocket.CreateClientWebSocket(stream, null, ReceiveBufferSize, useZeroMask: false); + return CommonWebSocket.CreateClientWebSocket(stream, null, ReceiveBufferSize, useZeroMask: UseZeroMask); } } } diff --git a/test/Microsoft.Net.WebSockets.Test/UtilitiesTests.cs b/test/Microsoft.Net.WebSockets.Test/UtilitiesTests.cs index ff9c8f4601..0a218308c8 100644 --- a/test/Microsoft.Net.WebSockets.Test/UtilitiesTests.cs +++ b/test/Microsoft.Net.WebSockets.Test/UtilitiesTests.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Text; -using System.Threading.Tasks; using Xunit; namespace Microsoft.Net.WebSockets.Test @@ -14,8 +11,8 @@ namespace Microsoft.Net.WebSockets.Test { byte[] data = Encoding.UTF8.GetBytes("Hello World"); byte[] orriginal = Encoding.UTF8.GetBytes("Hello World"); - Utilities.Mask(16843009, new ArraySegment(data)); - Utilities.Mask(16843009, new ArraySegment(data)); + Utilities.MaskInPlace(16843009, new ArraySegment(data)); + Utilities.MaskInPlace(16843009, new ArraySegment(data)); Assert.Equal(orriginal, data); } } diff --git a/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs b/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs index a466271278..91d1045e4c 100644 --- a/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs +++ b/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs @@ -1,7 +1,5 @@ using Microsoft.Net.WebSockets.Client; using System; -using System.Collections.Generic; -using System.Linq; using System.Net; using System.Net.WebSockets; using System.Text; From 9ba9f666bbfd636da8580717e98a0ada17ec8f9e Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Fri, 7 Mar 2014 22:25:21 -0800 Subject: [PATCH 009/453] Fix continuation frame bug. --- src/Microsoft.Net.WebSockets/CommonWebSocket.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs index 6930e38c4e..2f4c405c36 100644 --- a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs +++ b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs @@ -171,11 +171,6 @@ namespace Microsoft.Net.WebSockets opCode = _firstDataOpCode.Value; } - if (_frameInProgress.Fin) - { - _firstDataOpCode = null; - } - if (opCode == Constants.OpCodes.CloseFrame) { return await ProcessCloseFrameAsync(cancellationToken); @@ -188,6 +183,10 @@ namespace Microsoft.Net.WebSockets { // End of an empty frame? result = new WebSocketReceiveResult(0, messageType, _frameInProgress.Fin); + if (_frameInProgress.Fin) + { + _firstDataOpCode = null; + } _frameInProgress = null; return result; } @@ -207,6 +206,10 @@ namespace Microsoft.Net.WebSockets if (bytesToCopy == _frameBytesRemaining) { result = new WebSocketReceiveResult(bytesToCopy, messageType, _frameInProgress.Fin); + if (_frameInProgress.Fin) + { + _firstDataOpCode = null; + } _frameInProgress = null; } else From 30ca12933e08d884ed388970afc737c239e48d17 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Sat, 8 Mar 2014 10:35:56 -0800 Subject: [PATCH 010/453] Cleanup, simple perf. --- .../CommonWebSocket.cs | 41 +++++++------------ src/Microsoft.Net.WebSockets/Utilities.cs | 7 ++-- .../WebSocketClient.cs | 2 +- test/TestClient/Program.cs | 18 ++++++-- test/TestServer/Program.cs | 2 +- 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs index 2f4c405c36..979ae18606 100644 --- a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs +++ b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs @@ -154,15 +154,8 @@ namespace Microsoft.Net.WebSockets } // Handle fragmentation, remember the first frame type - int opCode = Constants.OpCodes.ContinuationFrame; - if (_frameInProgress.OpCode == Constants.OpCodes.BinaryFrame - || _frameInProgress.OpCode == Constants.OpCodes.TextFrame - || _frameInProgress.OpCode == Constants.OpCodes.CloseFrame) - { - opCode = _frameInProgress.OpCode; - _firstDataOpCode = opCode; - } - else if (_frameInProgress.OpCode == Constants.OpCodes.ContinuationFrame) + int opCode = _frameInProgress.OpCode; + if (opCode == Constants.OpCodes.ContinuationFrame) { if (!_firstDataOpCode.HasValue) { @@ -170,39 +163,34 @@ namespace Microsoft.Net.WebSockets } opCode = _firstDataOpCode.Value; } + else + { + _firstDataOpCode = opCode; + } if (opCode == Constants.OpCodes.CloseFrame) { return await ProcessCloseFrameAsync(cancellationToken); } - WebSocketReceiveResult result; - - WebSocketMessageType messageType = Utilities.GetMessageType(opCode); - if (_frameBytesRemaining == 0) - { - // End of an empty frame? - result = new WebSocketReceiveResult(0, messageType, _frameInProgress.Fin); - if (_frameInProgress.Fin) - { - _firstDataOpCode = null; - } - _frameInProgress = null; - return result; - } - // Make sure there's at least some data in the buffer - await EnsureDataAvailableOrReadAsync(1, cancellationToken); + int bytesToBuffer = (int)Math.Min((long)_receiveBuffer.Length, _frameBytesRemaining); + await EnsureDataAvailableOrReadAsync(bytesToBuffer, cancellationToken); + // Copy buffered data to the users buffer int bytesToRead = (int)Math.Min((long)buffer.Count, _frameBytesRemaining); int bytesToCopy = Math.Min(bytesToRead, _receiveBufferBytes); Array.Copy(_receiveBuffer, _receiveBufferOffset, buffer.Array, buffer.Offset, bytesToCopy); + if (_unmaskInput) { // TODO: mask alignment may be off between reads. // _frameInProgress.Masked == _unmaskInput already verified Utilities.MaskInPlace(_frameInProgress.MaskKey, new ArraySegment(buffer.Array, buffer.Offset, bytesToCopy)); } + + WebSocketReceiveResult result; + WebSocketMessageType messageType = Utilities.GetMessageType(opCode); if (bytesToCopy == _frameBytesRemaining) { result = new WebSocketReceiveResult(bytesToCopy, messageType, _frameInProgress.Fin); @@ -216,6 +204,7 @@ namespace Microsoft.Net.WebSockets { result = new WebSocketReceiveResult(bytesToCopy, messageType, false); } + _frameBytesRemaining -= bytesToCopy; _receiveBufferBytes -= bytesToCopy; _receiveBufferOffset += bytesToCopy; @@ -370,7 +359,7 @@ namespace Microsoft.Net.WebSockets if (State == WebSocketState.CloseSent) { // Do a receiving drain - byte[] data = new byte[1024]; + byte[] data = new byte[_receiveBuffer.Length]; WebSocketReceiveResult result; do { diff --git a/src/Microsoft.Net.WebSockets/Utilities.cs b/src/Microsoft.Net.WebSockets/Utilities.cs index 35be77a857..a4fdcfda4b 100644 --- a/src/Microsoft.Net.WebSockets/Utilities.cs +++ b/src/Microsoft.Net.WebSockets/Utilities.cs @@ -33,10 +33,11 @@ namespace Microsoft.Net.WebSockets }; int maskOffset = 0; - for (int i = data.Offset; i < data.Offset + data.Count; i++) + int end = data.Offset + data.Count; + for (int i = data.Offset; i < end; i++) { - data.Array[i] = (byte)(data.Array[i] ^ maskBytes[maskOffset]); - maskOffset = (maskOffset + 1) % 4; + data.Array[i] ^= maskBytes[maskOffset]; + maskOffset = (maskOffset + 1) & 0x3; // fast % 4; } } diff --git a/src/Microsoft.Net.WebSockets/WebSocketClient.cs b/src/Microsoft.Net.WebSockets/WebSocketClient.cs index d1ec49b4d5..a5c5c666a4 100644 --- a/src/Microsoft.Net.WebSockets/WebSocketClient.cs +++ b/src/Microsoft.Net.WebSockets/WebSocketClient.cs @@ -24,7 +24,7 @@ namespace Microsoft.Net.WebSockets.Client public WebSocketClient() { - ReceiveBufferSize = 1024; + ReceiveBufferSize = 1024 * 64; } public int ReceiveBufferSize diff --git a/test/TestClient/Program.cs b/test/TestClient/Program.cs index 2c16bc5576..ac36c45d96 100644 --- a/test/TestClient/Program.cs +++ b/test/TestClient/Program.cs @@ -22,13 +22,23 @@ namespace TestClient { WebSocketClient client = new WebSocketClient(); WebSocket socket = await client.ConnectAsync(new Uri("ws://chrross-togo:12345/"), CancellationToken.None); - byte[] data = Encoding.UTF8.GetBytes("Hello World"); + byte[] data = Encoding.UTF8.GetBytes( + // TODO: Hangs after 10 seconds + // "Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World" + // "Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, " + // "Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, " + "Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, " + ); while (true) { await socket.SendAsync(new ArraySegment(data), WebSocketMessageType.Text, true, CancellationToken.None); - WebSocketReceiveResult result = await socket.ReceiveAsync(new ArraySegment(data), CancellationToken.None); - Console.WriteLine(result.MessageType + ", " + result.Count + ", " + result.EndOfMessage); - Console.WriteLine(Encoding.UTF8.GetString(data, 0, result.Count)); + WebSocketReceiveResult result; + do + { + result = await socket.ReceiveAsync(new ArraySegment(data), CancellationToken.None); + // Console.WriteLine("Received: " + result.MessageType + ", " + result.Count + ", " + result.EndOfMessage); + } while (!result.EndOfMessage); + // Console.WriteLine(Encoding.UTF8.GetString(data, 0, result.Count)); } await socket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Closing", CancellationToken.None); } diff --git a/test/TestServer/Program.cs b/test/TestServer/Program.cs index 59b5825b55..c3c9384aab 100644 --- a/test/TestServer/Program.cs +++ b/test/TestServer/Program.cs @@ -41,7 +41,7 @@ namespace TestServer while (received.MessageType != WebSocketMessageType.Close) { - Console.WriteLine("Echo"); + // Console.WriteLine("Echo, " + received.Count + ", " + received.MessageType + ", " + received.EndOfMessage); // Echo anything we receive await webSocket.SendAsync(new ArraySegment(buffer, 0, received.Count), received.MessageType, received.EndOfMessage, CancellationToken.None); From 678af7c22fd21d2f35b57e138408c78c32c5766b Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Sat, 8 Mar 2014 15:14:54 -0800 Subject: [PATCH 011/453] Implement KeepAliveInterval, send pings. --- .../CommonWebSocket.cs | 80 +++++++++++++++++-- .../WebSocketClient.cs | 11 ++- 2 files changed, 84 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs index 979ae18606..e1795dbef2 100644 --- a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs +++ b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs @@ -12,6 +12,7 @@ namespace Microsoft.Net.WebSockets public class CommonWebSocket : WebSocket { private readonly static Random Random = new Random(); + private readonly static byte[] PingBuffer = Encoding.ASCII.GetBytes("abcdefghijklmnopqrstuvwxyz"); private readonly Stream _stream; private readonly string _subProtocl; @@ -19,6 +20,7 @@ namespace Microsoft.Net.WebSockets private readonly bool _unmaskInput; private readonly bool _useZeroMask; private readonly SemaphoreSlim _writeLock; + private readonly Timer _keepAliveTimer; private WebSocketState _state; @@ -35,7 +37,7 @@ namespace Microsoft.Net.WebSockets private long _frameBytesRemaining; private int? _firstDataOpCode; - public CommonWebSocket(Stream stream, string subProtocol, int receiveBufferSize, bool maskOutput, bool useZeroMask, bool unmaskInput) + public CommonWebSocket(Stream stream, string subProtocol, TimeSpan keepAliveInterval, int receiveBufferSize, bool maskOutput, bool useZeroMask, bool unmaskInput) { _stream = stream; _subProtocl = subProtocol; @@ -45,16 +47,20 @@ namespace Microsoft.Net.WebSockets _useZeroMask = useZeroMask; _unmaskInput = unmaskInput; _writeLock = new SemaphoreSlim(1); + if (keepAliveInterval != Timeout.InfiniteTimeSpan) + { + _keepAliveTimer = new Timer(SendKeepAlive, this, keepAliveInterval, keepAliveInterval); + } } - public static CommonWebSocket CreateClientWebSocket(Stream stream, string subProtocol, int receiveBufferSize, bool useZeroMask) + public static CommonWebSocket CreateClientWebSocket(Stream stream, string subProtocol, TimeSpan keepAliveInterval, int receiveBufferSize, bool useZeroMask) { - return new CommonWebSocket(stream, subProtocol, receiveBufferSize, maskOutput: true, useZeroMask: useZeroMask, unmaskInput: false); + return new CommonWebSocket(stream, subProtocol, keepAliveInterval, receiveBufferSize, maskOutput: true, useZeroMask: useZeroMask, unmaskInput: false); } - public static CommonWebSocket CreateServerWebSocket(Stream stream, string subProtocol, int receiveBufferSize) + public static CommonWebSocket CreateServerWebSocket(Stream stream, string subProtocol, TimeSpan keepAliveInterval, int receiveBufferSize) { - return new CommonWebSocket(stream, subProtocol, receiveBufferSize, maskOutput: false, useZeroMask: false, unmaskInput: true); + return new CommonWebSocket(stream, subProtocol, keepAliveInterval, receiveBufferSize, maskOutput: false, useZeroMask: false, unmaskInput: true); } public override WebSocketCloseStatus? CloseStatus @@ -140,6 +146,58 @@ namespace Microsoft.Net.WebSockets } } + private static void SendKeepAlive(object state) + { + CommonWebSocket websocket = (CommonWebSocket)state; + websocket.SendKeepAliveAsync(); + } + + private async void SendKeepAliveAsync() + { + // Check concurrent writes, pings & pongs, or closes + bool lockAquired = await _writeLock.WaitAsync(TimeSpan.FromMinutes(1)); // TODO: Wait up to KeepAliveInterval? + if (!lockAquired) + { + // Pings aren't that important, discard them if we can't take the lock. + return; + } + try + { + if (State == WebSocketState.CloseSent || State >= WebSocketState.Closed) + { + _keepAliveTimer.Dispose(); + return; + } + + int mask = GetNextMask(); + FrameHeader frameHeader = new FrameHeader(true, Constants.OpCodes.PingFrame, _maskOutput, mask, PingBuffer.Length); + ArraySegment headerSegment = frameHeader.Buffer; + + // TODO: CancelationToken / timeout? + if (_maskOutput && mask != 0) + { + byte[] maskedFrame = Utilities.MergeAndMask(mask, headerSegment, new ArraySegment(PingBuffer)); + await _stream.WriteAsync(maskedFrame, 0, maskedFrame.Length); + } + else + { + await _stream.WriteAsync(headerSegment.Array, headerSegment.Offset, headerSegment.Count); + await _stream.WriteAsync(PingBuffer, 0, PingBuffer.Length); + } + } + catch (Exception) + { + // TODO: Log exception, this is a background thread. + + // Shut down, we must be in a faulted state; + Abort(); + } + finally + { + _writeLock.Release(); + } + } + public async override Task ReceiveAsync(ArraySegment buffer, CancellationToken cancellationToken) { ThrowIfDisposed(); @@ -376,6 +434,10 @@ namespace Microsoft.Net.WebSockets { ThrowIfDisposed(); ThrowIfOutputClosed(); + if (_keepAliveTimer != null) + { + _keepAliveTimer.Dispose(); + } byte[] descriptionBytes = Encoding.UTF8.GetBytes(statusDescription ?? string.Empty); byte[] fullData = new byte[descriptionBytes.Length + 2]; @@ -419,6 +481,10 @@ namespace Microsoft.Net.WebSockets } _state = WebSocketState.Aborted; + if (_keepAliveTimer != null) + { + _keepAliveTimer.Dispose(); + } _stream.Dispose(); } @@ -430,6 +496,10 @@ namespace Microsoft.Net.WebSockets } _state = WebSocketState.Closed; + if (_keepAliveTimer != null) + { + _keepAliveTimer.Dispose(); + } _stream.Dispose(); } diff --git a/src/Microsoft.Net.WebSockets/WebSocketClient.cs b/src/Microsoft.Net.WebSockets/WebSocketClient.cs index a5c5c666a4..60636a05f0 100644 --- a/src/Microsoft.Net.WebSockets/WebSocketClient.cs +++ b/src/Microsoft.Net.WebSockets/WebSocketClient.cs @@ -24,7 +24,14 @@ namespace Microsoft.Net.WebSockets.Client public WebSocketClient() { - ReceiveBufferSize = 1024 * 64; + ReceiveBufferSize = 1024 * 16; + KeepAliveInterval = TimeSpan.FromMinutes(2); + } + + public TimeSpan KeepAliveInterval + { + get; + set; } public int ReceiveBufferSize @@ -85,7 +92,7 @@ namespace Microsoft.Net.WebSockets.Client Stream stream = response.GetResponseStream(); - return CommonWebSocket.CreateClientWebSocket(stream, null, ReceiveBufferSize, useZeroMask: UseZeroMask); + return CommonWebSocket.CreateClientWebSocket(stream, null, KeepAliveInterval, ReceiveBufferSize, useZeroMask: UseZeroMask); } } } From 65532849f6bed7f95f7869bac2b057e984ff31e4 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Sat, 8 Mar 2014 23:01:53 -0800 Subject: [PATCH 012/453] Handle unmasking offset data. --- .../CommonWebSocket.cs | 5 +- src/Microsoft.Net.WebSockets/Utilities.cs | 8 +- .../BufferStream.cs | 337 ++++++++++++++++++ .../DuplexStream.cs | 172 +++++++++ .../DuplexTests.cs | 63 ++++ .../Microsoft.Net.WebSockets.Test.csproj | 3 + 6 files changed, 584 insertions(+), 4 deletions(-) create mode 100644 test/Microsoft.Net.WebSockets.Test/BufferStream.cs create mode 100644 test/Microsoft.Net.WebSockets.Test/DuplexStream.cs create mode 100644 test/Microsoft.Net.WebSockets.Test/DuplexTests.cs diff --git a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs index e1795dbef2..2edd8f6e47 100644 --- a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs +++ b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs @@ -36,6 +36,7 @@ namespace Microsoft.Net.WebSockets private FrameHeader _frameInProgress; private long _frameBytesRemaining; private int? _firstDataOpCode; + private int _dataUnmaskOffset; public CommonWebSocket(Stream stream, string subProtocol, TimeSpan keepAliveInterval, int receiveBufferSize, bool maskOutput, bool useZeroMask, bool unmaskInput) { @@ -242,9 +243,8 @@ namespace Microsoft.Net.WebSockets if (_unmaskInput) { - // TODO: mask alignment may be off between reads. // _frameInProgress.Masked == _unmaskInput already verified - Utilities.MaskInPlace(_frameInProgress.MaskKey, new ArraySegment(buffer.Array, buffer.Offset, bytesToCopy)); + Utilities.MaskInPlace(_frameInProgress.MaskKey, ref _dataUnmaskOffset, new ArraySegment(buffer.Array, buffer.Offset, bytesToCopy)); } WebSocketReceiveResult result; @@ -257,6 +257,7 @@ namespace Microsoft.Net.WebSockets _firstDataOpCode = null; } _frameInProgress = null; + _dataUnmaskOffset = 0; } else { diff --git a/src/Microsoft.Net.WebSockets/Utilities.cs b/src/Microsoft.Net.WebSockets/Utilities.cs index a4fdcfda4b..c478b4140e 100644 --- a/src/Microsoft.Net.WebSockets/Utilities.cs +++ b/src/Microsoft.Net.WebSockets/Utilities.cs @@ -16,8 +16,13 @@ namespace Microsoft.Net.WebSockets return frame; } - // Un/Masks the data in place public static void MaskInPlace(int mask, ArraySegment data) + { + int maskOffset = 0; + MaskInPlace(mask, ref maskOffset, data); + } + + public static void MaskInPlace(int mask, ref int maskOffset, ArraySegment data) { if (mask == 0) { @@ -31,7 +36,6 @@ namespace Microsoft.Net.WebSockets (byte)(mask >> 8), (byte)mask, }; - int maskOffset = 0; int end = data.Offset + data.Count; for (int i = data.Offset; i < end; i++) diff --git a/test/Microsoft.Net.WebSockets.Test/BufferStream.cs b/test/Microsoft.Net.WebSockets.Test/BufferStream.cs new file mode 100644 index 0000000000..de2c308f14 --- /dev/null +++ b/test/Microsoft.Net.WebSockets.Test/BufferStream.cs @@ -0,0 +1,337 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. + +using System; +using System.Collections.Concurrent; +using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.Contracts; +using System.IO; +using System.Threading; +using System.Threading.Tasks; + +namespace Microsoft.Net.WebSockets.Test +{ + // This steam accepts writes from one side, buffers them internally, and returns the data via Reads + // when requested on the other side. + public class BufferStream : Stream + { + private bool _disposed; + private bool _aborted; + private Exception _abortException; + private ConcurrentQueue _bufferedData; + private ArraySegment _topBuffer; + private SemaphoreSlim _readLock; + private SemaphoreSlim _writeLock; + private TaskCompletionSource _readWaitingForData; + + internal BufferStream() + { + _readLock = new SemaphoreSlim(1, 1); + _writeLock = new SemaphoreSlim(1, 1); + _bufferedData = new ConcurrentQueue(); + _readWaitingForData = new TaskCompletionSource(); + } + + public override bool CanRead + { + get { return true; } + } + + public override bool CanSeek + { + get { return false; } + } + + public override bool CanWrite + { + get { return true; } + } + + #region NotSupported + + public override long Length + { + get { throw new NotSupportedException(); } + } + + public override long Position + { + get { throw new NotSupportedException(); } + set { throw new NotSupportedException(); } + } + + public override long Seek(long offset, SeekOrigin origin) + { + throw new NotSupportedException(); + } + + public override void SetLength(long value) + { + throw new NotSupportedException(); + } + + #endregion NotSupported + + public override void Flush() + { + CheckDisposed(); + // TODO: Wait for data to drain? + } + + public override Task FlushAsync(CancellationToken cancellationToken) + { + if (cancellationToken.IsCancellationRequested) + { + TaskCompletionSource tcs = new TaskCompletionSource(); + tcs.TrySetCanceled(); + return tcs.Task; + } + + Flush(); + + // TODO: Wait for data to drain? + + return Task.FromResult(0); + } + + public override int Read(byte[] buffer, int offset, int count) + { + VerifyBuffer(buffer, offset, count, allowEmpty: false); + _readLock.Wait(); + try + { + int totalRead = 0; + do + { + // Don't drain buffered data when signaling an abort. + CheckAborted(); + if (_topBuffer.Count <= 0) + { + byte[] topBuffer = null; + while (!_bufferedData.TryDequeue(out topBuffer)) + { + if (_disposed) + { + CheckAborted(); + // Graceful close + return totalRead; + } + WaitForDataAsync().Wait(); + } + _topBuffer = new ArraySegment(topBuffer); + } + int actualCount = Math.Min(count, _topBuffer.Count); + Buffer.BlockCopy(_topBuffer.Array, _topBuffer.Offset, buffer, offset, actualCount); + _topBuffer = new ArraySegment(_topBuffer.Array, + _topBuffer.Offset + actualCount, + _topBuffer.Count - actualCount); + totalRead += actualCount; + offset += actualCount; + count -= actualCount; + } + while (count > 0 && (_topBuffer.Count > 0 || _bufferedData.Count > 0)); + // Keep reading while there is more data available and we have more space to put it in. + return totalRead; + } + finally + { + _readLock.Release(); + } + } + + public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) + { + // TODO: This option doesn't preserve the state object. + // return ReadAsync(buffer, offset, count); + return base.BeginRead(buffer, offset, count, callback, state); + } + + public override int EndRead(IAsyncResult asyncResult) + { + // return ((Task)asyncResult).Result; + return base.EndRead(asyncResult); + } + + public async override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + VerifyBuffer(buffer, offset, count, allowEmpty: false); + CancellationTokenRegistration registration = cancellationToken.Register(Abort); + await _readLock.WaitAsync(cancellationToken); + try + { + int totalRead = 0; + do + { + // Don't drained buffered data on abort. + CheckAborted(); + if (_topBuffer.Count <= 0) + { + byte[] topBuffer = null; + while (!_bufferedData.TryDequeue(out topBuffer)) + { + if (_disposed) + { + CheckAborted(); + // Graceful close + return totalRead; + } + await WaitForDataAsync(); + } + _topBuffer = new ArraySegment(topBuffer); + } + int actualCount = Math.Min(count, _topBuffer.Count); + Buffer.BlockCopy(_topBuffer.Array, _topBuffer.Offset, buffer, offset, actualCount); + _topBuffer = new ArraySegment(_topBuffer.Array, + _topBuffer.Offset + actualCount, + _topBuffer.Count - actualCount); + totalRead += actualCount; + offset += actualCount; + count -= actualCount; + } + while (count > 0 && (_topBuffer.Count > 0 || _bufferedData.Count > 0)); + // Keep reading while there is more data available and we have more space to put it in. + return totalRead; + } + finally + { + registration.Dispose(); + _readLock.Release(); + } + } + + // Write with count 0 will still trigger OnFirstWrite + public override void Write(byte[] buffer, int offset, int count) + { + VerifyBuffer(buffer, offset, count, allowEmpty: true); + CheckDisposed(); + + _writeLock.Wait(); + try + { + if (count == 0) + { + return; + } + // Copies are necessary because we don't know what the caller is going to do with the buffer afterwards. + byte[] internalBuffer = new byte[count]; + Buffer.BlockCopy(buffer, offset, internalBuffer, 0, count); + _bufferedData.Enqueue(internalBuffer); + + SignalDataAvailable(); + } + finally + { + _writeLock.Release(); + } + } + + public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) + { + Write(buffer, offset, count); + TaskCompletionSource tcs = new TaskCompletionSource(state); + tcs.TrySetResult(null); + IAsyncResult result = tcs.Task; + if (callback != null) + { + callback(result); + } + return result; + } + + public override void EndWrite(IAsyncResult asyncResult) + { + } + + public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + VerifyBuffer(buffer, offset, count, allowEmpty: true); + if (cancellationToken.IsCancellationRequested) + { + TaskCompletionSource tcs = new TaskCompletionSource(); + tcs.TrySetCanceled(); + return tcs.Task; + } + + Write(buffer, offset, count); + return Task.FromResult(null); + } + + private static void VerifyBuffer(byte[] buffer, int offset, int count, bool allowEmpty) + { + if (buffer == null) + { + throw new ArgumentNullException("buffer"); + } + if (offset < 0 || offset > buffer.Length) + { + throw new ArgumentOutOfRangeException("offset", offset, string.Empty); + } + if (count < 0 || count > buffer.Length - offset + || (!allowEmpty && count == 0)) + { + throw new ArgumentOutOfRangeException("count", count, string.Empty); + } + } + + private void SignalDataAvailable() + { + // Dispatch, as TrySetResult will synchronously execute the waiters callback and block our Write. + Task.Factory.StartNew(() => _readWaitingForData.TrySetResult(null)); + } + + private Task WaitForDataAsync() + { + _readWaitingForData = new TaskCompletionSource(); + + if (!_bufferedData.IsEmpty || _disposed) + { + // Race, data could have arrived before we created the TCS. + _readWaitingForData.TrySetResult(null); + } + + return _readWaitingForData.Task; + } + + internal void Abort() + { + Abort(new OperationCanceledException()); + } + + internal void Abort(Exception innerException) + { + Contract.Requires(innerException != null); + _aborted = true; + _abortException = innerException; + Dispose(); + } + + private void CheckAborted() + { + if (_aborted) + { + throw new IOException(string.Empty, _abortException); + } + } + + [SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "_writeLock", Justification = "ODEs from the locks would mask IOEs from abort.")] + [SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "_readLock", Justification = "Data can still be read unless we get aborted.")] + protected override void Dispose(bool disposing) + { + if (disposing) + { + // Throw for further writes, but not reads. Allow reads to drain the buffered data and then return 0 for further reads. + _disposed = true; + _readWaitingForData.TrySetResult(null); + } + + base.Dispose(disposing); + } + + private void CheckDisposed() + { + if (_disposed) + { + throw new ObjectDisposedException(GetType().FullName); + } + } + } +} diff --git a/test/Microsoft.Net.WebSockets.Test/DuplexStream.cs b/test/Microsoft.Net.WebSockets.Test/DuplexStream.cs new file mode 100644 index 0000000000..7cd19c17f8 --- /dev/null +++ b/test/Microsoft.Net.WebSockets.Test/DuplexStream.cs @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. + +using System; +using System.IO; +using System.Threading; +using System.Threading.Tasks; + +namespace Microsoft.Net.WebSockets.Test +{ + // A duplex wrapper around a read and write stream. + public class DuplexStream : Stream + { + private readonly Stream _readStream; + private readonly Stream _writeStream; + + public DuplexStream() + : this (new BufferStream(), new BufferStream()) + { + } + + public DuplexStream(Stream readStream, Stream writeStream) + { + _readStream = readStream; + _writeStream = writeStream; + } + + public DuplexStream CreateReverseDuplexStream() + { + return new DuplexStream(_writeStream, _readStream); + } + +#region Properties + + public override bool CanRead + { + get { return _readStream.CanRead; } + } + + public override bool CanSeek + { + get { return false; } + } + + public override bool CanTimeout + { + get { return _readStream.CanTimeout || _writeStream.CanTimeout; } + } + + public override bool CanWrite + { + get { return _writeStream.CanWrite; } + } + + public override long Length + { + get { throw new NotSupportedException(); } + } + + public override long Position + { + get { throw new NotSupportedException(); } + set { throw new NotSupportedException(); } + } + + public override int ReadTimeout + { + get { return _readStream.ReadTimeout; } + set { _readStream.ReadTimeout = value; } + } + + public override int WriteTimeout + { + get { return _writeStream.WriteTimeout; } + set { _writeStream.WriteTimeout = value; } + } + +#endregion Properties + + public override long Seek(long offset, SeekOrigin origin) + { + throw new NotSupportedException(); + } + + public override void SetLength(long value) + { + throw new NotSupportedException(); + } + +#region Read + + public override int Read(byte[] buffer, int offset, int count) + { + return _readStream.Read(buffer, offset, count); + } + + public override int ReadByte() + { + return _readStream.ReadByte(); + } + + public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) + { + return _readStream.BeginRead(buffer, offset, count, callback, state); + } + + public override int EndRead(IAsyncResult asyncResult) + { + return _readStream.EndRead(asyncResult); + } + + public override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + return _readStream.ReadAsync(buffer, offset, count, cancellationToken); + } + + public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken) + { + return _readStream.CopyToAsync(destination, bufferSize, cancellationToken); + } + +#endregion Read + +#region Write + + public override void Write(byte[] buffer, int offset, int count) + { + _writeStream.Write(buffer, offset, count); + } + + public override void WriteByte(byte value) + { + _writeStream.WriteByte(value); + } + + public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) + { + return _writeStream.BeginWrite(buffer, offset, count, callback, state); + } + + public override void EndWrite(IAsyncResult asyncResult) + { + _writeStream.EndWrite(asyncResult); + } + + public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + return _writeStream.WriteAsync(buffer, offset, count, cancellationToken); + } + + public override void Flush() + { + _writeStream.Flush(); + } + + public override Task FlushAsync(CancellationToken cancellationToken) + { + return _writeStream.FlushAsync(cancellationToken); + } + +#endregion Write + + protected override void Dispose(bool disposing) + { + if (disposing) + { + _readStream.Dispose(); + _writeStream.Dispose(); + } + base.Dispose(disposing); + } + } +} diff --git a/test/Microsoft.Net.WebSockets.Test/DuplexTests.cs b/test/Microsoft.Net.WebSockets.Test/DuplexTests.cs new file mode 100644 index 0000000000..117c233e88 --- /dev/null +++ b/test/Microsoft.Net.WebSockets.Test/DuplexTests.cs @@ -0,0 +1,63 @@ +using System; +using System.Net.WebSockets; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Microsoft.Net.WebSockets.Test +{ + public class DuplexTests + { + [Fact] + public async Task SendAndReceive() + { + DuplexStream serverStream = new DuplexStream(); + DuplexStream clientStream = serverStream.CreateReverseDuplexStream(); + + WebSocket serverWebSocket = CommonWebSocket.CreateServerWebSocket(serverStream, null, TimeSpan.FromMinutes(2), 1024); + WebSocket clientWebSocket = CommonWebSocket.CreateClientWebSocket(clientStream, null, TimeSpan.FromMinutes(2), 1024, false); + + byte[] clientBuffer = Encoding.ASCII.GetBytes("abcdefghijklmnopqrstuvwxyz"); + byte[] serverBuffer = new byte[clientBuffer.Length]; + + await clientWebSocket.SendAsync(new ArraySegment(clientBuffer), WebSocketMessageType.Text, true, CancellationToken.None); + WebSocketReceiveResult serverResult = await serverWebSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(serverResult.EndOfMessage); + Assert.Equal(clientBuffer.Length, serverResult.Count); + Assert.Equal(WebSocketMessageType.Text, serverResult.MessageType); + Assert.Equal(clientBuffer, serverBuffer); + } + + [Fact] + // Tests server unmasking with offset masks + public async Task ServerReceiveOffsetData() + { + DuplexStream serverStream = new DuplexStream(); + DuplexStream clientStream = serverStream.CreateReverseDuplexStream(); + + WebSocket serverWebSocket = CommonWebSocket.CreateServerWebSocket(serverStream, null, TimeSpan.FromMinutes(2), 1024); + WebSocket clientWebSocket = CommonWebSocket.CreateClientWebSocket(clientStream, null, TimeSpan.FromMinutes(2), 1024, false); + + byte[] clientBuffer = Encoding.ASCII.GetBytes("abcdefghijklmnopqrstuvwxyz"); + byte[] serverBuffer = new byte[clientBuffer.Length]; + + await clientWebSocket.SendAsync(new ArraySegment(clientBuffer), WebSocketMessageType.Text, true, CancellationToken.None); + WebSocketReceiveResult serverResult = await serverWebSocket.ReceiveAsync(new ArraySegment(serverBuffer, 0, 3), CancellationToken.None); + Assert.False(serverResult.EndOfMessage); + Assert.Equal(3, serverResult.Count); + Assert.Equal(WebSocketMessageType.Text, serverResult.MessageType); + + serverResult = await serverWebSocket.ReceiveAsync(new ArraySegment(serverBuffer, 3, 10), CancellationToken.None); + Assert.False(serverResult.EndOfMessage); + Assert.Equal(10, serverResult.Count); + Assert.Equal(WebSocketMessageType.Text, serverResult.MessageType); + + serverResult = await serverWebSocket.ReceiveAsync(new ArraySegment(serverBuffer, 13, 13), CancellationToken.None); + Assert.True(serverResult.EndOfMessage); + Assert.Equal(13, serverResult.Count); + Assert.Equal(WebSocketMessageType.Text, serverResult.MessageType); + Assert.Equal(clientBuffer, serverBuffer); + } + } +} diff --git a/test/Microsoft.Net.WebSockets.Test/Microsoft.Net.WebSockets.Test.csproj b/test/Microsoft.Net.WebSockets.Test/Microsoft.Net.WebSockets.Test.csproj index fcfd99f1a4..25f16b963c 100644 --- a/test/Microsoft.Net.WebSockets.Test/Microsoft.Net.WebSockets.Test.csproj +++ b/test/Microsoft.Net.WebSockets.Test/Microsoft.Net.WebSockets.Test.csproj @@ -45,6 +45,9 @@ + + + From 2dbe40dca507494a575367ad5b515b9c67e50242 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Sun, 9 Mar 2014 20:55:43 -0700 Subject: [PATCH 013/453] Negotiate sub-protocol. --- src/Microsoft.Net.WebSockets/Constants.cs | 3 ++- .../WebSocketClient.cs | 27 +++++++++++++++---- .../WebSocketClientTests.cs | 26 ++++++++++++++++++ 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.Net.WebSockets/Constants.cs b/src/Microsoft.Net.WebSockets/Constants.cs index 8fb002913e..6877c70d0b 100644 --- a/src/Microsoft.Net.WebSockets/Constants.cs +++ b/src/Microsoft.Net.WebSockets/Constants.cs @@ -10,7 +10,8 @@ namespace Microsoft.Net.WebSockets { public static class Headers { - public const string WebSocketVersion = "Sec-WebSocket-Version"; + public const string SecWebSocketVersion = "Sec-WebSocket-Version"; + public const string SecWebSocketProtocol = "Sec-WebSocket-Protocol"; public const string SupportedVersion = "13"; } diff --git a/src/Microsoft.Net.WebSockets/WebSocketClient.cs b/src/Microsoft.Net.WebSockets/WebSocketClient.cs index 60636a05f0..ca77944110 100644 --- a/src/Microsoft.Net.WebSockets/WebSocketClient.cs +++ b/src/Microsoft.Net.WebSockets/WebSocketClient.cs @@ -1,5 +1,7 @@ using System; +using System.Collections.Generic; using System.IO; +using System.Linq; using System.Net; using System.Net.WebSockets; using System.Threading; @@ -26,6 +28,13 @@ namespace Microsoft.Net.WebSockets.Client { ReceiveBufferSize = 1024 * 16; KeepAliveInterval = TimeSpan.FromMinutes(2); + SubProtocols = new List(); + } + + public IList SubProtocols + { + get; + private set; } public TimeSpan KeepAliveInterval @@ -64,8 +73,11 @@ namespace Microsoft.Net.WebSockets.Client CancellationTokenRegistration cancellation = cancellationToken.Register(() => request.Abort()); - request.Headers[Constants.Headers.WebSocketVersion] = Constants.Headers.SupportedVersion; - // TODO: Sub-protocols + request.Headers[Constants.Headers.SecWebSocketVersion] = Constants.Headers.SupportedVersion; + if (SubProtocols.Count > 0) + { + request.Headers[Constants.Headers.SecWebSocketProtocol] = string.Join(", ", SubProtocols); + } if (ConfigureRequest != null) { @@ -85,14 +97,19 @@ namespace Microsoft.Net.WebSockets.Client if (response.StatusCode != HttpStatusCode.SwitchingProtocols) { response.Dispose(); - throw new InvalidOperationException("Incomplete handshake"); + throw new InvalidOperationException("Incomplete handshake, invalid status code: " + response.StatusCode); } + // TODO: Validate Sec-WebSocket-Key/Sec-WebSocket-Accept - // TODO: Sub protocol + string subProtocol = response.Headers[Constants.Headers.SecWebSocketProtocol]; + if (!string.IsNullOrEmpty(subProtocol) && !SubProtocols.Contains(subProtocol, StringComparer.OrdinalIgnoreCase)) + { + throw new InvalidOperationException("Incomplete handshake, the server specified an unknown sub-protocol: " + subProtocol); + } Stream stream = response.GetResponseStream(); - return CommonWebSocket.CreateClientWebSocket(stream, null, KeepAliveInterval, ReceiveBufferSize, useZeroMask: UseZeroMask); + return CommonWebSocket.CreateClientWebSocket(stream, subProtocol, KeepAliveInterval, ReceiveBufferSize, useZeroMask: UseZeroMask); } } } diff --git a/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs b/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs index 91d1045e4c..f4c6b207fe 100644 --- a/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs +++ b/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs @@ -35,6 +35,32 @@ namespace Microsoft.Net.WebSockets.Test } } + [Fact] + public async Task NegotiateSubProtocol_Success() + { + using (HttpListener listener = new HttpListener()) + { + listener.Prefixes.Add(ServerAddress); + listener.Start(); + Task serverAccept = listener.GetContextAsync(); + + WebSocketClient client = new WebSocketClient(); + client.SubProtocols.Add("alpha"); + client.SubProtocols.Add("bravo"); + client.SubProtocols.Add("charlie"); + Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + + HttpListenerContext serverContext = await serverAccept; + Assert.True(serverContext.Request.IsWebSocketRequest); + Assert.Equal("alpha, bravo, charlie", serverContext.Request.Headers["Sec-WebSocket-Protocol"]); + HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync("Bravo"); + + WebSocket clientSocket = await clientConnect; + Assert.Equal("Bravo", clientSocket.SubProtocol); + clientSocket.Dispose(); + } + } + [Fact] public async Task SendShortData_Success() { From 1853c711148539ac12f50eea1a717eb4651478b4 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Mon, 10 Mar 2014 08:32:59 -0700 Subject: [PATCH 014/453] Narrow ping write lock. --- src/Microsoft.Net.WebSockets/CommonWebSocket.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs index 2edd8f6e47..b4315644b2 100644 --- a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs +++ b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs @@ -156,10 +156,9 @@ namespace Microsoft.Net.WebSockets private async void SendKeepAliveAsync() { // Check concurrent writes, pings & pongs, or closes - bool lockAquired = await _writeLock.WaitAsync(TimeSpan.FromMinutes(1)); // TODO: Wait up to KeepAliveInterval? - if (!lockAquired) + if (!_writeLock.Wait(0)) { - // Pings aren't that important, discard them if we can't take the lock. + // Sending real data is better than a ping, discard it. return; } try From 704239bca8ec1c7087f37cd6da31aece205c7d31 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Tue, 11 Mar 2014 08:26:42 -0700 Subject: [PATCH 015/453] Allow zero length sends and receives. --- .../CommonWebSocket.cs | 4 +- .../WebSocketClientTests.cs | 63 +++++++++++++++++++ 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs index b4315644b2..cbad809539 100644 --- a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs +++ b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs @@ -533,11 +533,11 @@ namespace Microsoft.Net.WebSockets { throw new ArgumentNullException("buffer"); } - if (buffer.Offset < 0 || buffer.Offset >= buffer.Array.Length) + if (buffer.Offset < 0 || buffer.Offset > buffer.Array.Length) { throw new ArgumentOutOfRangeException("buffer.Offset", buffer.Offset, string.Empty); } - if (buffer.Count <= 0 || buffer.Count > buffer.Array.Length - buffer.Offset) + if (buffer.Count < 0 || buffer.Count > buffer.Array.Length - buffer.Offset) { throw new ArgumentOutOfRangeException("buffer.Count", buffer.Count, string.Empty); } diff --git a/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs b/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs index f4c6b207fe..b0a9779c82 100644 --- a/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs +++ b/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs @@ -61,6 +61,38 @@ namespace Microsoft.Net.WebSockets.Test } } + [Fact] + public async Task SendEmptyData_Success() + { + using (HttpListener listener = new HttpListener()) + { + listener.Prefixes.Add(ServerAddress); + listener.Start(); + Task serverAccept = listener.GetContextAsync(); + + WebSocketClient client = new WebSocketClient(); + Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + + HttpListenerContext serverContext = await serverAccept; + Assert.True(serverContext.Request.IsWebSocketRequest); + HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); + + WebSocket clientSocket = await clientConnect; + + byte[] orriginalData = new byte[0]; + await clientSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + + byte[] serverBuffer = new byte[orriginalData.Length]; + WebSocketReceiveResult result = await serverWebSocketContext.WebSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, serverBuffer); + + clientSocket.Dispose(); + } + } + [Fact] public async Task SendShortData_Success() { @@ -220,6 +252,37 @@ namespace Microsoft.Net.WebSockets.Test } } + [Fact] + public async Task ReceiveEmptyData_Success() + { + using (HttpListener listener = new HttpListener()) + { + listener.Prefixes.Add(ServerAddress); + listener.Start(); + Task serverAccept = listener.GetContextAsync(); + + WebSocketClient client = new WebSocketClient(); + Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + + HttpListenerContext serverContext = await serverAccept; + Assert.True(serverContext.Request.IsWebSocketRequest); + HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); + + WebSocket clientSocket = await clientConnect; + + byte[] orriginalData = Encoding.UTF8.GetBytes("Hello World"); + await serverWebSocketContext.WebSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + + byte[] clientBuffer = new byte[0]; + WebSocketReceiveResult result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.False(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + clientSocket.Dispose(); + } + } + [Fact] public async Task ReceiveShortData_Success() { From ecbb52fa409b41ddad32aac8079df4420b3b7ae3 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Mon, 17 Mar 2014 00:37:20 -0700 Subject: [PATCH 016/453] Updated to use KoreBuild - Updated solution file to use generated projects - Updated to use new test runner --- .gitattributes | 50 ++++++++++++++++ .gitignore | 39 +++++++------ NuGet.Config | 13 +++++ WebSockets.sln | 38 ++++++++----- build.cmd | 23 ++++++++ global.json | 3 + makefile.shade | 7 +++ .../Microsoft.Net.WebSockets.csproj | 57 ------------------- src/Microsoft.Net.WebSockets/project.json | 6 ++ .../Microsoft.Net.WebSockets.Test.csproj | 6 -- .../packages.config | 5 -- .../project.json | 20 +++++++ test/TestClient/App.config | 6 +- test/TestClient/TestClient.csproj | 9 +-- 14 files changed, 176 insertions(+), 106 deletions(-) create mode 100644 .gitattributes create mode 100644 NuGet.Config create mode 100644 build.cmd create mode 100644 global.json create mode 100644 makefile.shade delete mode 100644 src/Microsoft.Net.WebSockets/Microsoft.Net.WebSockets.csproj create mode 100644 src/Microsoft.Net.WebSockets/project.json delete mode 100644 test/Microsoft.Net.WebSockets.Test/packages.config create mode 100644 test/Microsoft.Net.WebSockets.Test/project.json diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..bdaa5ba982 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,50 @@ +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain + +*.jpg binary +*.png binary +*.gif binary + +*.cs text=auto diff=csharp +*.vb text=auto +*.resx text=auto +*.c text=auto +*.cpp text=auto +*.cxx text=auto +*.h text=auto +*.hxx text=auto +*.py text=auto +*.rb text=auto +*.java text=auto +*.html text=auto +*.htm text=auto +*.css text=auto +*.scss text=auto +*.sass text=auto +*.less text=auto +*.js text=auto +*.lisp text=auto +*.clj text=auto +*.sql text=auto +*.php text=auto +*.lua text=auto +*.m text=auto +*.asm text=auto +*.erl text=auto +*.fs text=auto +*.fsx text=auto +*.hs text=auto + +*.csproj text=auto +*.vbproj text=auto +*.fsproj text=auto +*.dbproj text=auto +*.sln text=auto eol=crlf diff --git a/.gitignore b/.gitignore index cb3474e72b..8bc217058d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,24 @@ -bin -obj -*.suo +[Oo]bj/ +[Bb]in/ +TestResults/ +.nuget/ +_ReSharper.*/ +packages/ +artifacts/ +PublishProfiles/ *.user +*.suo +*.cache +*.docstates _ReSharper.* -*.DS_Store -*.userprefs -*.pidb -*.vspx +nuget.exe +*net45.csproj +*k10.csproj *.psess -TestResults/* -TestResult.xml -nugetkey -packages -target -artifacts -StyleCop.Cache -node_modules -*.snk -.nuget/NuGet.exe -docs/build +*.vsp +*.pidb +*.userprefs +*DS_Store +*.ncrunchsolution +*.*sdf +*.ipch \ No newline at end of file diff --git a/NuGet.Config b/NuGet.Config new file mode 100644 index 0000000000..a059188b09 --- /dev/null +++ b/NuGet.Config @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/WebSockets.sln b/WebSockets.sln index abcfa94b4f..c2f3292dcd 100644 --- a/WebSockets.sln +++ b/WebSockets.sln @@ -1,30 +1,28 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.30203.2 +VisualStudioVersion = 12.0.30313.0 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Net.WebSockets", "src\Microsoft.Net.WebSockets\Microsoft.Net.WebSockets.csproj", "{6C1D09CA-F799-44AE-8EC8-9D19C76080C1}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Net.WebSockets.Test", "test\Microsoft.Net.WebSockets.Test\Microsoft.Net.WebSockets.Test.csproj", "{EF1FE910-6E0C-4DE8-8CC1-6118B726A59E}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestClient", "test\TestClient\TestClient.csproj", "{22AB02E0-0346-4C4B-BBE7-C829A8D1C19E}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestServer", "test\TestServer\TestServer.csproj", "{4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2C7947A5-9FBD-4267-97C1-2D726D7B3BAF}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{C45106D0-76C8-4776-A140-F7DD83CA2958}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Net.WebSockets.net45", "src\Microsoft.Net.WebSockets\Microsoft.Net.WebSockets.net45.csproj", "{B43D2069-9690-49B2-BA0C-9E8ACC32CB83}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Net.WebSockets.Test.net45", "test\Microsoft.Net.WebSockets.Test\Microsoft.Net.WebSockets.Test.net45.csproj", "{DA755E15-86B8-4E9C-A3B0-B2D95E3646B5}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6C1D09CA-F799-44AE-8EC8-9D19C76080C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6C1D09CA-F799-44AE-8EC8-9D19C76080C1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6C1D09CA-F799-44AE-8EC8-9D19C76080C1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6C1D09CA-F799-44AE-8EC8-9D19C76080C1}.Release|Any CPU.Build.0 = Release|Any CPU - {EF1FE910-6E0C-4DE8-8CC1-6118B726A59E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EF1FE910-6E0C-4DE8-8CC1-6118B726A59E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EF1FE910-6E0C-4DE8-8CC1-6118B726A59E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EF1FE910-6E0C-4DE8-8CC1-6118B726A59E}.Release|Any CPU.Build.0 = Release|Any CPU {22AB02E0-0346-4C4B-BBE7-C829A8D1C19E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {22AB02E0-0346-4C4B-BBE7-C829A8D1C19E}.Debug|Any CPU.Build.0 = Debug|Any CPU {22AB02E0-0346-4C4B-BBE7-C829A8D1C19E}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -33,8 +31,22 @@ Global {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Debug|Any CPU.Build.0 = Debug|Any CPU {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Release|Any CPU.ActiveCfg = Release|Any CPU {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Release|Any CPU.Build.0 = Release|Any CPU + {B43D2069-9690-49B2-BA0C-9E8ACC32CB83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B43D2069-9690-49B2-BA0C-9E8ACC32CB83}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B43D2069-9690-49B2-BA0C-9E8ACC32CB83}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B43D2069-9690-49B2-BA0C-9E8ACC32CB83}.Release|Any CPU.Build.0 = Release|Any CPU + {DA755E15-86B8-4E9C-A3B0-B2D95E3646B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DA755E15-86B8-4E9C-A3B0-B2D95E3646B5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DA755E15-86B8-4E9C-A3B0-B2D95E3646B5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DA755E15-86B8-4E9C-A3B0-B2D95E3646B5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {22AB02E0-0346-4C4B-BBE7-C829A8D1C19E} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} + {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} + {B43D2069-9690-49B2-BA0C-9E8ACC32CB83} = {2C7947A5-9FBD-4267-97C1-2D726D7B3BAF} + {DA755E15-86B8-4E9C-A3B0-B2D95E3646B5} = {C45106D0-76C8-4776-A140-F7DD83CA2958} + EndGlobalSection EndGlobal diff --git a/build.cmd b/build.cmd new file mode 100644 index 0000000000..7045ee1f84 --- /dev/null +++ b/build.cmd @@ -0,0 +1,23 @@ +@echo off +cd %~dp0 + +SETLOCAL +SET CACHED_NUGET=%LocalAppData%\NuGet\NuGet.exe + +IF EXIST %CACHED_NUGET% goto copynuget +echo Downloading latest version of NuGet.exe... +IF NOT EXIST %LocalAppData%\NuGet md %LocalAppData%\NuGet +@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://www.nuget.org/nuget.exe' -OutFile '%CACHED_NUGET%'" + +:copynuget +IF EXIST .nuget\nuget.exe goto restore +md .nuget +copy %CACHED_NUGET% .nuget\nuget.exe > nul + +:restore +IF EXIST packages\KoreBuild goto run +.nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre +.nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion + +:run +packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* diff --git a/global.json b/global.json new file mode 100644 index 0000000000..840c36f6ad --- /dev/null +++ b/global.json @@ -0,0 +1,3 @@ +{ + "sources": ["src"] +} \ No newline at end of file diff --git a/makefile.shade b/makefile.shade new file mode 100644 index 0000000000..6357ea2841 --- /dev/null +++ b/makefile.shade @@ -0,0 +1,7 @@ + +var VERSION='0.1' +var FULL_VERSION='0.1' +var AUTHORS='Microsoft' + +use-standard-lifecycle +k-standard-goals diff --git a/src/Microsoft.Net.WebSockets/Microsoft.Net.WebSockets.csproj b/src/Microsoft.Net.WebSockets/Microsoft.Net.WebSockets.csproj deleted file mode 100644 index dec92dc375..0000000000 --- a/src/Microsoft.Net.WebSockets/Microsoft.Net.WebSockets.csproj +++ /dev/null @@ -1,57 +0,0 @@ - - - - - Debug - AnyCPU - {6C1D09CA-F799-44AE-8EC8-9D19C76080C1} - Library - Properties - Microsoft.Net.WebSockets - Microsoft.Net.WebSockets - v4.5 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Microsoft.Net.WebSockets/project.json b/src/Microsoft.Net.WebSockets/project.json new file mode 100644 index 0000000000..80f3c5a063 --- /dev/null +++ b/src/Microsoft.Net.WebSockets/project.json @@ -0,0 +1,6 @@ +{ + "version": "0.1-alpha-*", + "configurations": { + "net45": { } + } +} \ No newline at end of file diff --git a/test/Microsoft.Net.WebSockets.Test/Microsoft.Net.WebSockets.Test.csproj b/test/Microsoft.Net.WebSockets.Test/Microsoft.Net.WebSockets.Test.csproj index 25f16b963c..70cae1a0ff 100644 --- a/test/Microsoft.Net.WebSockets.Test/Microsoft.Net.WebSockets.Test.csproj +++ b/test/Microsoft.Net.WebSockets.Test/Microsoft.Net.WebSockets.Test.csproj @@ -52,12 +52,6 @@ - - - {6c1d09ca-f799-44ae-8ec8-9d19c76080c1} - Microsoft.Net.WebSockets - - diff --git a/test/Microsoft.Net.WebSockets.Test/packages.config b/test/Microsoft.Net.WebSockets.Test/packages.config deleted file mode 100644 index 67a23e70da..0000000000 --- a/test/Microsoft.Net.WebSockets.Test/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/test/Microsoft.Net.WebSockets.Test/project.json b/test/Microsoft.Net.WebSockets.Test/project.json new file mode 100644 index 0000000000..4ddcfd6ef3 --- /dev/null +++ b/test/Microsoft.Net.WebSockets.Test/project.json @@ -0,0 +1,20 @@ +{ + "dependencies": { + "Microsoft.Net.WebSockets": "", + "Xunit.KRunner": "0.1-alpha-*", + "xunit.abstractions": "2.0.0-aspnet-*", + "xunit.assert": "2.0.0-aspnet-*", + "xunit.core": "2.0.0-aspnet-*", + "xunit.execution": "2.0.0-aspnet-*" + }, + "configurations": { + "net45": { + "dependencies": { + "System.Runtime" : "" + } + } + }, + "commands": { + "test": "Xunit.KRunner" + } +} \ No newline at end of file diff --git a/test/TestClient/App.config b/test/TestClient/App.config index 8e15646352..d0feca6f79 100644 --- a/test/TestClient/App.config +++ b/test/TestClient/App.config @@ -1,6 +1,6 @@ - + - + - \ No newline at end of file + diff --git a/test/TestClient/TestClient.csproj b/test/TestClient/TestClient.csproj index 842f76c15d..fdd95f9be8 100644 --- a/test/TestClient/TestClient.csproj +++ b/test/TestClient/TestClient.csproj @@ -9,8 +9,9 @@ Properties TestClient TestClient - v4.5 + v4.5.1 512 + AnyCPU @@ -48,9 +49,9 @@ - - {6c1d09ca-f799-44ae-8ec8-9d19c76080c1} - Microsoft.Net.WebSockets + + {b43d2069-9690-49b2-ba0c-9e8acc32cb83} + Microsoft.Net.WebSockets.net45 From f46a7a344e01768c6eb64f8fcd21a2f42ba1154a Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Wed, 7 May 2014 18:28:07 -0700 Subject: [PATCH 017/453] Sort dependencies and remove duplicates in dependencies --- test/Microsoft.Net.WebSockets.Test/project.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.Net.WebSockets.Test/project.json b/test/Microsoft.Net.WebSockets.Test/project.json index 4ddcfd6ef3..29babc3ba7 100644 --- a/test/Microsoft.Net.WebSockets.Test/project.json +++ b/test/Microsoft.Net.WebSockets.Test/project.json @@ -1,11 +1,11 @@ { "dependencies": { "Microsoft.Net.WebSockets": "", - "Xunit.KRunner": "0.1-alpha-*", "xunit.abstractions": "2.0.0-aspnet-*", "xunit.assert": "2.0.0-aspnet-*", "xunit.core": "2.0.0-aspnet-*", - "xunit.execution": "2.0.0-aspnet-*" + "xunit.execution": "2.0.0-aspnet-*", + "Xunit.KRunner": "0.1-alpha-*" }, "configurations": { "net45": { From c0d4e84d78267e6c6c4b9f328152778ae372ea42 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Thu, 8 May 2014 10:42:47 -0700 Subject: [PATCH 018/453] Updated build script --- build.cmd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.cmd b/build.cmd index 7045ee1f84..903d532df3 100644 --- a/build.cmd +++ b/build.cmd @@ -18,6 +18,9 @@ copy %CACHED_NUGET% .nuget\nuget.exe > nul IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion +CALL packages\KoreBuild\build\kvm upgrade -svr50 -x86 +CALL packages\KoreBuild\build\kvm install default -svrc50 -x86 :run +CALL packages\KoreBuild\build\kvm use default -svr50 -x86 packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* From 31dfa9f42f582940cbc82adb0e5914f16d67a4c9 Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Thu, 8 May 2014 16:35:38 -0700 Subject: [PATCH 019/453] Create LICENSE.txt --- LICENSE.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 LICENSE.txt diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000000..d85a1524ad --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,12 @@ +Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +these files except in compliance with the License. You may obtain a copy of the +License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed +under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. From caa18342bc3042b5a3f095c160557a9b4bb86ebe Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 3 Jun 2014 11:13:25 -0700 Subject: [PATCH 020/453] Updating makefile to include Options and Logging repos --- build.cmd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.cmd b/build.cmd index 903d532df3..3aaf957583 100644 --- a/build.cmd +++ b/build.cmd @@ -18,6 +18,8 @@ copy %CACHED_NUGET% .nuget\nuget.exe > nul IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion + +IF "%SKIP_KRE_INSTALL%"=="1" goto run CALL packages\KoreBuild\build\kvm upgrade -svr50 -x86 CALL packages\KoreBuild\build\kvm install default -svrc50 -x86 From 7484db54c605ad6eb98a3ba0900445953d0fd2ab Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Thu, 12 Jun 2014 20:11:12 -0700 Subject: [PATCH 021/453] Compile for CoreClr. Seperate Client project. Rename everything. --- CONTRIBUTING.md | 4 + README.md | 9 ++ WebSockets.sln | 63 +++++--- .../Constants.cs | 21 +++ .../Microsoft.AspNet.WebSockets.Client.kproj | 35 +++++ .../WebSocketClient.cs | 15 +- .../project.json | 9 ++ ...crosoft.AspNet.WebSockets.Middleware.kproj | 35 +++++ .../WebSocketMiddleware.cs | 115 ++++++++++++++ .../WebSocketMiddlewareExtensions.cs | 12 ++ .../project.json | 16 ++ .../CommonWebSocket.cs | 7 +- .../Constants.cs | 15 +- .../FrameHeader.cs | 7 +- .../HandshakeHelpers.cs | 142 ++++++++++++++++++ ...Microsoft.AspNet.WebSockets.Protocol.kproj | 37 +++++ .../Project.json | 20 +++ .../Properties/AssemblyInfo.cs | 0 .../Utilities.cs | 7 +- .../Microsoft.Net.WebSockets.kproj | 38 +++++ src/Microsoft.Net.WebSockets/project.json | 6 - ...rosoft.AspNet.WebSockets.Client.Test.kproj | 34 +++++ .../WebSocketClientTests.cs | 6 +- .../project.json | 21 +++ .../BufferStream.cs | 2 +- .../DuplexStream.cs | 2 +- .../DuplexTests.cs | 7 +- ...soft.AspNet.WebSockets.Protocol.Test.kproj | 36 +++++ .../Microsoft.Net.WebSockets.Test.csproj | 0 .../Project.json} | 2 +- .../Properties/AssemblyInfo.cs | 0 .../UtilitiesTests.cs | 7 +- test/TestClient/Program.cs | 33 ++-- test/TestClient/Project.json | 10 ++ test/TestClient/TestClient.csproj | 65 -------- test/TestClient/TestClient.kproj | 34 +++++ 36 files changed, 740 insertions(+), 132 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 README.md create mode 100644 src/Microsoft.AspNet.WebSockets.Client/Constants.cs create mode 100644 src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.kproj rename src/{Microsoft.Net.WebSockets => Microsoft.AspNet.WebSockets.Client}/WebSocketClient.cs (86%) create mode 100644 src/Microsoft.AspNet.WebSockets.Client/project.json create mode 100644 src/Microsoft.AspNet.WebSockets.Middleware/Microsoft.AspNet.WebSockets.Middleware.kproj create mode 100644 src/Microsoft.AspNet.WebSockets.Middleware/WebSocketMiddleware.cs create mode 100644 src/Microsoft.AspNet.WebSockets.Middleware/WebSocketMiddlewareExtensions.cs create mode 100644 src/Microsoft.AspNet.WebSockets.Middleware/project.json rename src/{Microsoft.Net.WebSockets => Microsoft.AspNet.WebSockets.Protocol}/CommonWebSocket.cs (98%) rename src/{Microsoft.Net.WebSockets => Microsoft.AspNet.WebSockets.Protocol}/Constants.cs (52%) rename src/{Microsoft.Net.WebSockets => Microsoft.AspNet.WebSockets.Protocol}/FrameHeader.cs (96%) create mode 100644 src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs create mode 100644 src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.kproj create mode 100644 src/Microsoft.AspNet.WebSockets.Protocol/Project.json rename src/{Microsoft.Net.WebSockets => Microsoft.AspNet.WebSockets.Protocol}/Properties/AssemblyInfo.cs (100%) rename src/{Microsoft.Net.WebSockets => Microsoft.AspNet.WebSockets.Protocol}/Utilities.cs (90%) create mode 100644 src/Microsoft.Net.WebSockets/Microsoft.Net.WebSockets.kproj delete mode 100644 src/Microsoft.Net.WebSockets/project.json create mode 100644 test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.kproj rename test/{Microsoft.Net.WebSockets.Test => Microsoft.AspNet.WebSockets.Client.Test}/WebSocketClientTests.cs (99%) create mode 100644 test/Microsoft.AspNet.WebSockets.Client.Test/project.json rename test/{Microsoft.Net.WebSockets.Test => Microsoft.AspNet.WebSockets.Protocol.Test}/BufferStream.cs (99%) rename test/{Microsoft.Net.WebSockets.Test => Microsoft.AspNet.WebSockets.Protocol.Test}/DuplexStream.cs (98%) rename test/{Microsoft.Net.WebSockets.Test => Microsoft.AspNet.WebSockets.Protocol.Test}/DuplexTests.cs (92%) create mode 100644 test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.kproj rename test/{Microsoft.Net.WebSockets.Test => Microsoft.AspNet.WebSockets.Protocol.Test}/Microsoft.Net.WebSockets.Test.csproj (100%) rename test/{Microsoft.Net.WebSockets.Test/project.json => Microsoft.AspNet.WebSockets.Protocol.Test/Project.json} (89%) rename test/{Microsoft.Net.WebSockets.Test => Microsoft.AspNet.WebSockets.Protocol.Test}/Properties/AssemblyInfo.cs (100%) rename test/{Microsoft.Net.WebSockets.Test => Microsoft.AspNet.WebSockets.Protocol.Test}/UtilitiesTests.cs (65%) create mode 100644 test/TestClient/Project.json delete mode 100644 test/TestClient/TestClient.csproj create mode 100644 test/TestClient/TestClient.kproj diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..eac4268e4c --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,4 @@ +Contributing +====== + +Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/master/CONTRIBUTING.md) in the Home repo. diff --git a/README.md b/README.md new file mode 100644 index 0000000000..2a9add8342 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +WebSockets +================ + +Contains a managed implementation of the WebSocket protocol, along with client and server integration components. + +This project is part of ASP.NET vNext. You can find samples, documentation and getting started instructions for ASP.NET vNext at the [Home](https://github.com/aspnet/home) repo. + + + diff --git a/WebSockets.sln b/WebSockets.sln index c2f3292dcd..fcae05ecd2 100644 --- a/WebSockets.sln +++ b/WebSockets.sln @@ -1,10 +1,8 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.30313.0 +# Visual Studio 14 +VisualStudioVersion = 14.0.21730.1 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestClient", "test\TestClient\TestClient.csproj", "{22AB02E0-0346-4C4B-BBE7-C829A8D1C19E}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestServer", "test\TestServer\TestServer.csproj", "{4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2C7947A5-9FBD-4267-97C1-2D726D7B3BAF}" @@ -13,9 +11,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{C45106D0-7 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Net.WebSockets.net45", "src\Microsoft.Net.WebSockets\Microsoft.Net.WebSockets.net45.csproj", "{B43D2069-9690-49B2-BA0C-9E8ACC32CB83}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Protocol", "src\Microsoft.AspNet.WebSockets.Protocol\Microsoft.AspNet.WebSockets.Protocol.kproj", "{E0C10DEC-3339-4A47-85BC-3100C5D34AD4}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Net.WebSockets.Test.net45", "test\Microsoft.Net.WebSockets.Test\Microsoft.Net.WebSockets.Test.net45.csproj", "{DA755E15-86B8-4E9C-A3B0-B2D95E3646B5}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Protocol.Test", "test\Microsoft.AspNet.WebSockets.Protocol.Test\Microsoft.AspNet.WebSockets.Protocol.Test.kproj", "{62A07A24-4D06-4DDA-B6BF-02D0C9CB7D32}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestClient", "test\TestClient\TestClient.kproj", "{8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Client", "src\Microsoft.AspNet.WebSockets.Client\Microsoft.AspNet.WebSockets.Client.kproj", "{4A1C4875-AE21-4A78-979A-F0E4DF5EB518}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Client.Test", "test\Microsoft.AspNet.WebSockets.Client.Test\Microsoft.AspNet.WebSockets.Client.Test.kproj", "{6604D154-817F-4BC5-BE95-FF7E851179D9}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Middleware", "src\Microsoft.AspNet.WebSockets.Middleware\Microsoft.AspNet.WebSockets.Middleware.kproj", "{78A097D0-C0A4-4AED-93E2-84A65392FB52}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -23,30 +29,45 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {22AB02E0-0346-4C4B-BBE7-C829A8D1C19E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {22AB02E0-0346-4C4B-BBE7-C829A8D1C19E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {22AB02E0-0346-4C4B-BBE7-C829A8D1C19E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {22AB02E0-0346-4C4B-BBE7-C829A8D1C19E}.Release|Any CPU.Build.0 = Release|Any CPU {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Debug|Any CPU.Build.0 = Debug|Any CPU {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Release|Any CPU.ActiveCfg = Release|Any CPU {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Release|Any CPU.Build.0 = Release|Any CPU - {B43D2069-9690-49B2-BA0C-9E8ACC32CB83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B43D2069-9690-49B2-BA0C-9E8ACC32CB83}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B43D2069-9690-49B2-BA0C-9E8ACC32CB83}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B43D2069-9690-49B2-BA0C-9E8ACC32CB83}.Release|Any CPU.Build.0 = Release|Any CPU - {DA755E15-86B8-4E9C-A3B0-B2D95E3646B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DA755E15-86B8-4E9C-A3B0-B2D95E3646B5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DA755E15-86B8-4E9C-A3B0-B2D95E3646B5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DA755E15-86B8-4E9C-A3B0-B2D95E3646B5}.Release|Any CPU.Build.0 = Release|Any CPU + {E0C10DEC-3339-4A47-85BC-3100C5D34AD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E0C10DEC-3339-4A47-85BC-3100C5D34AD4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E0C10DEC-3339-4A47-85BC-3100C5D34AD4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E0C10DEC-3339-4A47-85BC-3100C5D34AD4}.Release|Any CPU.Build.0 = Release|Any CPU + {62A07A24-4D06-4DDA-B6BF-02D0C9CB7D32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {62A07A24-4D06-4DDA-B6BF-02D0C9CB7D32}.Debug|Any CPU.Build.0 = Debug|Any CPU + {62A07A24-4D06-4DDA-B6BF-02D0C9CB7D32}.Release|Any CPU.ActiveCfg = Release|Any CPU + {62A07A24-4D06-4DDA-B6BF-02D0C9CB7D32}.Release|Any CPU.Build.0 = Release|Any CPU + {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Release|Any CPU.Build.0 = Release|Any CPU + {4A1C4875-AE21-4A78-979A-F0E4DF5EB518}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4A1C4875-AE21-4A78-979A-F0E4DF5EB518}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4A1C4875-AE21-4A78-979A-F0E4DF5EB518}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4A1C4875-AE21-4A78-979A-F0E4DF5EB518}.Release|Any CPU.Build.0 = Release|Any CPU + {6604D154-817F-4BC5-BE95-FF7E851179D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6604D154-817F-4BC5-BE95-FF7E851179D9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6604D154-817F-4BC5-BE95-FF7E851179D9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6604D154-817F-4BC5-BE95-FF7E851179D9}.Release|Any CPU.Build.0 = Release|Any CPU + {78A097D0-C0A4-4AED-93E2-84A65392FB52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {78A097D0-C0A4-4AED-93E2-84A65392FB52}.Debug|Any CPU.Build.0 = Debug|Any CPU + {78A097D0-C0A4-4AED-93E2-84A65392FB52}.Release|Any CPU.ActiveCfg = Release|Any CPU + {78A097D0-C0A4-4AED-93E2-84A65392FB52}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {22AB02E0-0346-4C4B-BBE7-C829A8D1C19E} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} - {B43D2069-9690-49B2-BA0C-9E8ACC32CB83} = {2C7947A5-9FBD-4267-97C1-2D726D7B3BAF} - {DA755E15-86B8-4E9C-A3B0-B2D95E3646B5} = {C45106D0-76C8-4776-A140-F7DD83CA2958} + {E0C10DEC-3339-4A47-85BC-3100C5D34AD4} = {2C7947A5-9FBD-4267-97C1-2D726D7B3BAF} + {62A07A24-4D06-4DDA-B6BF-02D0C9CB7D32} = {C45106D0-76C8-4776-A140-F7DD83CA2958} + {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} + {4A1C4875-AE21-4A78-979A-F0E4DF5EB518} = {2C7947A5-9FBD-4267-97C1-2D726D7B3BAF} + {6604D154-817F-4BC5-BE95-FF7E851179D9} = {C45106D0-76C8-4776-A140-F7DD83CA2958} + {78A097D0-C0A4-4AED-93E2-84A65392FB52} = {2C7947A5-9FBD-4267-97C1-2D726D7B3BAF} EndGlobalSection EndGlobal diff --git a/src/Microsoft.AspNet.WebSockets.Client/Constants.cs b/src/Microsoft.AspNet.WebSockets.Client/Constants.cs new file mode 100644 index 0000000000..0178e7d75f --- /dev/null +++ b/src/Microsoft.AspNet.WebSockets.Client/Constants.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.AspNet.WebSockets.Client +{ + public static class Constants + { + public static class Headers + { + public const string Upgrade = "Upgrade"; + public const string UpgradeWebSocket = "websocket"; + public const string Connection = "Connection"; + public const string ConnectionUpgrade = "Upgrade"; + public const string SecWebSocketKey = "Sec-WebSocket-Key"; + public const string SecWebSocketVersion = "Sec-WebSocket-Version"; + public const string SecWebSocketProtocol = "Sec-WebSocket-Protocol"; + public const string SecWebSocketAccept = "Sec-WebSocket-Accept"; + public const string SupportedVersion = "13"; + } + } +} diff --git a/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.kproj b/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.kproj new file mode 100644 index 0000000000..cbb9475cbe --- /dev/null +++ b/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.kproj @@ -0,0 +1,35 @@ + + + + 12.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + Debug + AnyCPU + + + + 4a1c4875-ae21-4a78-979a-f0e4df5eb518 + Library + + + ConsoleDebugger + + + WebDebugger + + + + + 2.0 + + + + + + + + + + \ No newline at end of file diff --git a/src/Microsoft.Net.WebSockets/WebSocketClient.cs b/src/Microsoft.AspNet.WebSockets.Client/WebSocketClient.cs similarity index 86% rename from src/Microsoft.Net.WebSockets/WebSocketClient.cs rename to src/Microsoft.AspNet.WebSockets.Client/WebSocketClient.cs index ca77944110..f886e53987 100644 --- a/src/Microsoft.Net.WebSockets/WebSocketClient.cs +++ b/src/Microsoft.AspNet.WebSockets.Client/WebSocketClient.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -6,8 +9,9 @@ using System.Net; using System.Net.WebSockets; using System.Threading; using System.Threading.Tasks; +using Microsoft.AspNet.WebSockets.Protocol; -namespace Microsoft.Net.WebSockets.Client +namespace Microsoft.AspNet.WebSockets.Client { public class WebSocketClient { @@ -94,10 +98,11 @@ namespace Microsoft.Net.WebSockets.Client } // TODO: Validate handshake - if (response.StatusCode != HttpStatusCode.SwitchingProtocols) + HttpStatusCode statusCode = response.StatusCode; + if (statusCode != HttpStatusCode.SwitchingProtocols) { response.Dispose(); - throw new InvalidOperationException("Incomplete handshake, invalid status code: " + response.StatusCode); + throw new InvalidOperationException("Incomplete handshake, invalid status code: " + statusCode); } // TODO: Validate Sec-WebSocket-Key/Sec-WebSocket-Accept @@ -112,4 +117,4 @@ namespace Microsoft.Net.WebSockets.Client return CommonWebSocket.CreateClientWebSocket(stream, subProtocol, KeepAliveInterval, ReceiveBufferSize, useZeroMask: UseZeroMask); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebSockets.Client/project.json b/src/Microsoft.AspNet.WebSockets.Client/project.json new file mode 100644 index 0000000000..693ed10e9e --- /dev/null +++ b/src/Microsoft.AspNet.WebSockets.Client/project.json @@ -0,0 +1,9 @@ +{ + "version": "0.1-alpha-*", + "dependencies": { + "Microsoft.AspNet.WebSockets.Protocol": "" + }, + "configurations": { + "net45": { } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebSockets.Middleware/Microsoft.AspNet.WebSockets.Middleware.kproj b/src/Microsoft.AspNet.WebSockets.Middleware/Microsoft.AspNet.WebSockets.Middleware.kproj new file mode 100644 index 0000000000..45d5fac74c --- /dev/null +++ b/src/Microsoft.AspNet.WebSockets.Middleware/Microsoft.AspNet.WebSockets.Middleware.kproj @@ -0,0 +1,35 @@ + + + + 12.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + Debug + AnyCPU + + + + 78a097d0-c0a4-4aed-93e2-84a65392fb52 + Library + + + ConsoleDebugger + + + WebDebugger + + + + + 2.0 + + + + + + + + + + \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebSockets.Middleware/WebSocketMiddleware.cs b/src/Microsoft.AspNet.WebSockets.Middleware/WebSocketMiddleware.cs new file mode 100644 index 0000000000..4407194370 --- /dev/null +++ b/src/Microsoft.AspNet.WebSockets.Middleware/WebSocketMiddleware.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Net.WebSockets; +using System.Threading.Tasks; +using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Http; +using Microsoft.AspNet.HttpFeature; +using Microsoft.AspNet.WebSockets.Protocol; + +namespace Microsoft.AspNet.WebSockets.Middleware +{ + public class WebSocketMiddleware + { + private RequestDelegate _next; + + public WebSocketMiddleware(RequestDelegate next) + { + _next = next; + } + + public Task Invoke(HttpContext context) + { + // Detect if an opaque upgrade is available, and if websocket upgrade headers are present. + // If so, add a websocket upgrade. + var upgradeFeature = context.GetFeature(); + if (upgradeFeature != null) + { + context.SetFeature(new UpgradeHandshake(context, upgradeFeature)); + } + + return _next(context); + } + + private class UpgradeHandshake : IHttpWebSocketFeature + { + private HttpContext _context; + private IHttpOpaqueUpgradeFeature _upgradeFeature; + + public UpgradeHandshake(HttpContext context, IHttpOpaqueUpgradeFeature upgradeFeature) + { + _context = context; + _upgradeFeature = upgradeFeature; + } + + public bool IsWebSocketRequest + { + get + { + if (!_upgradeFeature.IsUpgradableRequest) + { + return false; + } + var headers = new List>(); + foreach (string headerName in HandshakeHelpers.NeededHeaders) + { + foreach (var value in _context.Request.Headers.GetCommaSeparatedValues(headerName)) + { + headers.Add(new KeyValuePair(headerName, value)); + } + } + return HandshakeHelpers.CheckSupportedWebSocketRequest(_context.Request.Method, headers); + } + } + + public async Task AcceptAsync(IWebSocketAcceptContext acceptContext) + { + if (!IsWebSocketRequest) + { + throw new InvalidOperationException("Not a WebSocket request."); + } + + string subProtocol = null; + if (acceptContext != null) + { + subProtocol = acceptContext.SubProtocol; + } + + TimeSpan keepAliveInterval = TimeSpan.FromMinutes(2); // TODO: + int receiveBufferSize = 4 * 1024; // TODO: + var advancedAcceptContext = acceptContext as WebSocketAcceptContext; + if (advancedAcceptContext != null) + { + if (advancedAcceptContext.ReceiveBufferSize.HasValue) + { + receiveBufferSize = advancedAcceptContext.ReceiveBufferSize.Value; + } + if (advancedAcceptContext.KeepAliveInterval.HasValue) + { + keepAliveInterval = advancedAcceptContext.KeepAliveInterval.Value; + } + } + + string key = string.Join(", ", _context.Request.Headers[Constants.Headers.SecWebSocketKey]); + + var responseHeaders = HandshakeHelpers.GenerateResponseHeaders(key, subProtocol); + foreach (var headerPair in responseHeaders) + { + _context.Response.Headers[headerPair.Key] = headerPair.Value; + } + Stream opaqueTransport = await _upgradeFeature.UpgradeAsync(); // Sets status code to 101 + + return CommonWebSocket.CreateServerWebSocket(opaqueTransport, subProtocol, keepAliveInterval, receiveBufferSize); + } + } + + public class WebSocketAcceptContext : IWebSocketAcceptContext + { + public string SubProtocol { get; set; } + public int? ReceiveBufferSize { get; set; } + public TimeSpan? KeepAliveInterval { get; set; } + // public ArraySegment? Buffer { get; set; } // TODO + } + } +} diff --git a/src/Microsoft.AspNet.WebSockets.Middleware/WebSocketMiddlewareExtensions.cs b/src/Microsoft.AspNet.WebSockets.Middleware/WebSocketMiddlewareExtensions.cs new file mode 100644 index 0000000000..ee0e3eb764 --- /dev/null +++ b/src/Microsoft.AspNet.WebSockets.Middleware/WebSocketMiddlewareExtensions.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNet.WebSockets.Middleware; + +namespace Microsoft.AspNet.Builder +{ + public static class WebSocketMiddlewareExtensions + { + public static IBuilder UseWebSockets(this IBuilder builder) + { + return builder.Use(next => new WebSocketMiddleware(next).Invoke); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebSockets.Middleware/project.json b/src/Microsoft.AspNet.WebSockets.Middleware/project.json new file mode 100644 index 0000000000..4d125efcb2 --- /dev/null +++ b/src/Microsoft.AspNet.WebSockets.Middleware/project.json @@ -0,0 +1,16 @@ +{ + "version": "0.1-alpha-*", + "dependencies": { + "Microsoft.AspNet.Http": "0.1-alpha-*", + "Microsoft.AspNet.HttpFeature": "0.1-alpha-*", + "Microsoft.AspNet.WebSockets.Protocol": "" + }, + "configurations" : { + "net45" : { }, + "k10" : { + "dependencies": { + "System.Runtime": "4.0.20.0" + } + } + } +} diff --git a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs similarity index 98% rename from src/Microsoft.Net.WebSockets/CommonWebSocket.cs rename to src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs index cbad809539..a5149a128f 100644 --- a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; using System.Diagnostics.Contracts; using System.IO; using System.Net.WebSockets; @@ -6,7 +9,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -namespace Microsoft.Net.WebSockets +namespace Microsoft.AspNet.WebSockets.Protocol { // https://tools.ietf.org/html/rfc6455 public class CommonWebSocket : WebSocket diff --git a/src/Microsoft.Net.WebSockets/Constants.cs b/src/Microsoft.AspNet.WebSockets.Protocol/Constants.cs similarity index 52% rename from src/Microsoft.Net.WebSockets/Constants.cs rename to src/Microsoft.AspNet.WebSockets.Protocol/Constants.cs index 6877c70d0b..07756e49e3 100644 --- a/src/Microsoft.Net.WebSockets/Constants.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/Constants.cs @@ -1,17 +1,20 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.Net.WebSockets +namespace Microsoft.AspNet.WebSockets.Protocol { public static class Constants { public static class Headers { + public const string Upgrade = "Upgrade"; + public const string UpgradeWebSocket = "websocket"; + public const string Connection = "Connection"; + public const string ConnectionUpgrade = "Upgrade"; + public const string SecWebSocketKey = "Sec-WebSocket-Key"; public const string SecWebSocketVersion = "Sec-WebSocket-Version"; public const string SecWebSocketProtocol = "Sec-WebSocket-Protocol"; + public const string SecWebSocketAccept = "Sec-WebSocket-Accept"; public const string SupportedVersion = "13"; } diff --git a/src/Microsoft.Net.WebSockets/FrameHeader.cs b/src/Microsoft.AspNet.WebSockets.Protocol/FrameHeader.cs similarity index 96% rename from src/Microsoft.Net.WebSockets/FrameHeader.cs rename to src/Microsoft.AspNet.WebSockets.Protocol/FrameHeader.cs index 35e54c7233..1307c69fd7 100644 --- a/src/Microsoft.Net.WebSockets/FrameHeader.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/FrameHeader.cs @@ -1,11 +1,14 @@ -using System; +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; using System.Collections.Generic; using System.Linq; using System.Net.WebSockets; using System.Text; using System.Threading.Tasks; -namespace Microsoft.Net.WebSockets +namespace Microsoft.AspNet.WebSockets.Protocol { public class FrameHeader { diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs b/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs new file mode 100644 index 0000000000..f8e3c22712 --- /dev/null +++ b/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Security.Cryptography; +using System.Text; + +namespace Microsoft.AspNet.WebSockets.Protocol +{ + public static class HandshakeHelpers + { + /// + /// Gets request headers needed process the handshake on the server. + /// + public static IEnumerable NeededHeaders + { + get + { + return new[] + { + Constants.Headers.Upgrade, + Constants.Headers.Connection, + Constants.Headers.SecWebSocketKey, + Constants.Headers.SecWebSocketVersion + }; + } + } + + // Verify Method, Upgrade, Connection, version, key, etc.. + public static bool CheckSupportedWebSocketRequest(string method, IEnumerable> headers) + { + bool validUpgrade = false, validConnection = false, validKey = false, validVersion = false; + + if (!string.Equals("GET", method, StringComparison.OrdinalIgnoreCase)) + { + return false; + } + + foreach (var pair in headers) + { + if (string.Equals(Constants.Headers.Connection, pair.Key, StringComparison.OrdinalIgnoreCase)) + { + if (string.Equals(Constants.Headers.ConnectionUpgrade, pair.Value, StringComparison.OrdinalIgnoreCase)) + { + validConnection = true; + } + } + else if (string.Equals(Constants.Headers.Upgrade, pair.Key, StringComparison.OrdinalIgnoreCase)) + { + if (string.Equals(Constants.Headers.UpgradeWebSocket, pair.Value, StringComparison.OrdinalIgnoreCase)) + { + validUpgrade = true; + } + } + else if (string.Equals(Constants.Headers.SecWebSocketVersion, pair.Key, StringComparison.OrdinalIgnoreCase)) + { + if (string.Equals(Constants.Headers.SupportedVersion, pair.Value, StringComparison.OrdinalIgnoreCase)) + { + validVersion = true; + } + } + else if (string.Equals(Constants.Headers.SecWebSocketKey, pair.Key, StringComparison.OrdinalIgnoreCase)) + { + validKey = IsRequestKeyValid(pair.Value); + } + } + + return validConnection && validUpgrade && validVersion && validKey; + } + + public static IEnumerable> GenerateResponseHeaders(string key, string subProtocol) + { + yield return new KeyValuePair(Constants.Headers.Connection, Constants.Headers.ConnectionUpgrade); + yield return new KeyValuePair(Constants.Headers.Upgrade, Constants.Headers.UpgradeWebSocket); + yield return new KeyValuePair(Constants.Headers.SecWebSocketAccept, CreateResponseKey(key)); + if (!string.IsNullOrWhiteSpace(subProtocol)) + { + yield return new KeyValuePair(Constants.Headers.SecWebSocketProtocol, subProtocol); + } + } + + /// + /// Validates the Sec-WebSocket-Key request header + /// "The value of this header field MUST be a nonce consisting of a randomly selected 16-byte value that has been base64-encoded." + /// + /// + /// + public static bool IsRequestKeyValid(string value) + { + if (string.IsNullOrWhiteSpace(value)) + { + return false; + } + try + { + byte[] data = Convert.FromBase64String(value); + return data.Length == 16; + } + catch (Exception) + { + return false; + } + } + + public static bool IsResponseKeyValid(string value) + { + throw new NotImplementedException(); + } + + /// + /// "The value of this header field MUST be a nonce consisting of a randomly selected 16-byte value that has been base64-encoded." + /// + /// + public static string CreateRequestKey() + { + throw new NotImplementedException(); + } + + /// + /// "...the base64-encoded SHA-1 of the concatenation of the |Sec-WebSocket-Key| (as a string, not base64-decoded) with the string + /// '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'" + /// + /// + /// + public static string CreateResponseKey(string requestKey) + { + if (string.IsNullOrWhiteSpace(requestKey)) + { + throw new ArgumentNullException("requestKey"); + } + + using (var algorithm = SHA1.Create()) + { + string merged = requestKey + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; + byte[] mergedBytes = Encoding.UTF8.GetBytes(merged); + byte[] hashedBytes = algorithm.ComputeHash(mergedBytes); + return Convert.ToBase64String(hashedBytes); + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.kproj b/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.kproj new file mode 100644 index 0000000000..6293d3e4f1 --- /dev/null +++ b/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.kproj @@ -0,0 +1,37 @@ + + + + 12.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + e0c10dec-3339-4a47-85bc-3100c5d34ad4 + Library + + + ConsoleDebugger + + + WebDebugger + + + + + + + 2.0 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/Project.json b/src/Microsoft.AspNet.WebSockets.Protocol/Project.json new file mode 100644 index 0000000000..8bace8ef52 --- /dev/null +++ b/src/Microsoft.AspNet.WebSockets.Protocol/Project.json @@ -0,0 +1,20 @@ +{ + "version": "0.1-alpha-*", + "configurations": { + "net45": { }, + "k10": { + "dependencies": { + "Microsoft.Net.WebSocketAbstractions": "0.1-alpha-*", + "System.Diagnostics.Contracts": "4.0.0.0", + "System.Linq": "4.0.0.0", + "System.Runtime": "4.0.20.0", + "System.Runtime.InteropServices": "4.0.20.0", + "System.Runtime.Extensions": "4.0.10.0", + "System.Security.Cryptography.HashAlgorithms.SHA1": "4.0.0.0", + "System.Threading": "4.0.0.0", + "System.Threading.Tasks": "4.0.10.0", + "System.Threading.Timer": "4.0.0.0" + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.Net.WebSockets/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.WebSockets.Protocol/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.Net.WebSockets/Properties/AssemblyInfo.cs rename to src/Microsoft.AspNet.WebSockets.Protocol/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.Net.WebSockets/Utilities.cs b/src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs similarity index 90% rename from src/Microsoft.Net.WebSockets/Utilities.cs rename to src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs index c478b4140e..a48a5a184b 100644 --- a/src/Microsoft.Net.WebSockets/Utilities.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs @@ -1,7 +1,10 @@ -using System; +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; using System.Net.WebSockets; -namespace Microsoft.Net.WebSockets +namespace Microsoft.AspNet.WebSockets.Protocol { public static class Utilities { diff --git a/src/Microsoft.Net.WebSockets/Microsoft.Net.WebSockets.kproj b/src/Microsoft.Net.WebSockets/Microsoft.Net.WebSockets.kproj new file mode 100644 index 0000000000..01bea96825 --- /dev/null +++ b/src/Microsoft.Net.WebSockets/Microsoft.Net.WebSockets.kproj @@ -0,0 +1,38 @@ + + + + 12.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + e0c10dec-3339-4a47-85bc-3100c5d34ad4 + Library + + + ConsoleDebugger + + + WebDebugger + + + + + + + 2.0 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Microsoft.Net.WebSockets/project.json b/src/Microsoft.Net.WebSockets/project.json deleted file mode 100644 index 80f3c5a063..0000000000 --- a/src/Microsoft.Net.WebSockets/project.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "0.1-alpha-*", - "configurations": { - "net45": { } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.kproj b/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.kproj new file mode 100644 index 0000000000..93d5ef5be4 --- /dev/null +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.kproj @@ -0,0 +1,34 @@ + + + + 12.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + Debug + AnyCPU + + + + 6604d154-817f-4bc5-be95-ff7e851179d9 + Library + + + ConsoleDebugger + + + WebDebugger + + + + + 2.0 + + + + + + + + + \ No newline at end of file diff --git a/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/WebSocketClientTests.cs similarity index 99% rename from test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs rename to test/Microsoft.AspNet.WebSockets.Client.Test/WebSocketClientTests.cs index b0a9779c82..23cf33bee0 100644 --- a/test/Microsoft.Net.WebSockets.Test/WebSocketClientTests.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/WebSocketClientTests.cs @@ -1,4 +1,6 @@ -using Microsoft.Net.WebSockets.Client; +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + using System; using System.Net; using System.Net.WebSockets; @@ -7,7 +9,7 @@ using System.Threading; using System.Threading.Tasks; using Xunit; -namespace Microsoft.Net.WebSockets.Test +namespace Microsoft.AspNet.WebSockets.Client.Test { public class WebSocketClientTests { diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json new file mode 100644 index 0000000000..78a038c2f1 --- /dev/null +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json @@ -0,0 +1,21 @@ +{ + "dependencies": { + "Microsoft.AspNet.WebSockets.Protocol": "", + "Microsoft.AspNet.WebSockets.Client": "", + "xunit.abstractions": "2.0.0-aspnet-*", + "xunit.assert": "2.0.0-aspnet-*", + "xunit.core": "2.0.0-aspnet-*", + "xunit.execution": "2.0.0-aspnet-*", + "Xunit.KRunner": "0.1-alpha-*" + }, + "configurations": { + "net45": { + "dependencies": { + "System.Runtime" : "" + } + } + }, + "commands": { + "test": "Xunit.KRunner" + } +} \ No newline at end of file diff --git a/test/Microsoft.Net.WebSockets.Test/BufferStream.cs b/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs similarity index 99% rename from test/Microsoft.Net.WebSockets.Test/BufferStream.cs rename to test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs index de2c308f14..604aea7671 100644 --- a/test/Microsoft.Net.WebSockets.Test/BufferStream.cs +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs @@ -8,7 +8,7 @@ using System.IO; using System.Threading; using System.Threading.Tasks; -namespace Microsoft.Net.WebSockets.Test +namespace Microsoft.AspNet.WebSockets.Protocol.Test { // This steam accepts writes from one side, buffers them internally, and returns the data via Reads // when requested on the other side. diff --git a/test/Microsoft.Net.WebSockets.Test/DuplexStream.cs b/test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexStream.cs similarity index 98% rename from test/Microsoft.Net.WebSockets.Test/DuplexStream.cs rename to test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexStream.cs index 7cd19c17f8..bfada4b0ab 100644 --- a/test/Microsoft.Net.WebSockets.Test/DuplexStream.cs +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexStream.cs @@ -5,7 +5,7 @@ using System.IO; using System.Threading; using System.Threading.Tasks; -namespace Microsoft.Net.WebSockets.Test +namespace Microsoft.AspNet.WebSockets.Protocol.Test { // A duplex wrapper around a read and write stream. public class DuplexStream : Stream diff --git a/test/Microsoft.Net.WebSockets.Test/DuplexTests.cs b/test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexTests.cs similarity index 92% rename from test/Microsoft.Net.WebSockets.Test/DuplexTests.cs rename to test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexTests.cs index 117c233e88..5e0c4473dd 100644 --- a/test/Microsoft.Net.WebSockets.Test/DuplexTests.cs +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexTests.cs @@ -1,11 +1,14 @@ -using System; +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; using System.Net.WebSockets; using System.Text; using System.Threading; using System.Threading.Tasks; using Xunit; -namespace Microsoft.Net.WebSockets.Test +namespace Microsoft.AspNet.WebSockets.Protocol.Test { public class DuplexTests { diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.kproj b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.kproj new file mode 100644 index 0000000000..651c44174e --- /dev/null +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.kproj @@ -0,0 +1,36 @@ + + + + 12.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 62a07a24-4d06-4dda-b6bf-02d0c9cb7d32 + Library + + + ConsoleDebugger + + + WebDebugger + + + + + + + 2.0 + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Microsoft.Net.WebSockets.Test/Microsoft.Net.WebSockets.Test.csproj b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.Net.WebSockets.Test.csproj similarity index 100% rename from test/Microsoft.Net.WebSockets.Test/Microsoft.Net.WebSockets.Test.csproj rename to test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.Net.WebSockets.Test.csproj diff --git a/test/Microsoft.Net.WebSockets.Test/project.json b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Project.json similarity index 89% rename from test/Microsoft.Net.WebSockets.Test/project.json rename to test/Microsoft.AspNet.WebSockets.Protocol.Test/Project.json index 29babc3ba7..bd91f51336 100644 --- a/test/Microsoft.Net.WebSockets.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Project.json @@ -1,6 +1,6 @@ { "dependencies": { - "Microsoft.Net.WebSockets": "", + "Microsoft.AspNet.WebSockets.Protocol": "", "xunit.abstractions": "2.0.0-aspnet-*", "xunit.assert": "2.0.0-aspnet-*", "xunit.core": "2.0.0-aspnet-*", diff --git a/test/Microsoft.Net.WebSockets.Test/Properties/AssemblyInfo.cs b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Properties/AssemblyInfo.cs similarity index 100% rename from test/Microsoft.Net.WebSockets.Test/Properties/AssemblyInfo.cs rename to test/Microsoft.AspNet.WebSockets.Protocol.Test/Properties/AssemblyInfo.cs diff --git a/test/Microsoft.Net.WebSockets.Test/UtilitiesTests.cs b/test/Microsoft.AspNet.WebSockets.Protocol.Test/UtilitiesTests.cs similarity index 65% rename from test/Microsoft.Net.WebSockets.Test/UtilitiesTests.cs rename to test/Microsoft.AspNet.WebSockets.Protocol.Test/UtilitiesTests.cs index 0a218308c8..ca07522b04 100644 --- a/test/Microsoft.Net.WebSockets.Test/UtilitiesTests.cs +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/UtilitiesTests.cs @@ -1,8 +1,11 @@ -using System; +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; using System.Text; using Xunit; -namespace Microsoft.Net.WebSockets.Test +namespace Microsoft.AspNet.WebSockets.Protocol.Test { public class UtilitiesTests { diff --git a/test/TestClient/Program.cs b/test/TestClient/Program.cs index ac36c45d96..a268f1000e 100644 --- a/test/TestClient/Program.cs +++ b/test/TestClient/Program.cs @@ -1,11 +1,9 @@ -using Microsoft.Net.WebSockets.Client; -using System; -using System.Collections.Generic; -using System.Linq; +using System; using System.Net.WebSockets; using System.Text; using System.Threading; using System.Threading.Tasks; +using Microsoft.AspNet.WebSockets.Client; namespace TestClient { @@ -13,32 +11,39 @@ namespace TestClient { static void Main(string[] args) { - Console.WriteLine("Waiting to start"); - Console.ReadKey(); - RunTestAsync().Wait(); + try + { + Console.WriteLine("Waiting to start"); + Console.ReadKey(); + RunTestAsync().Wait(); + } + catch (Exception ex) + { + Console.WriteLine(ex); + } } private static async Task RunTestAsync() { WebSocketClient client = new WebSocketClient(); - WebSocket socket = await client.ConnectAsync(new Uri("ws://chrross-togo:12345/"), CancellationToken.None); - byte[] data = Encoding.UTF8.GetBytes( + WebSocket socket = await client.ConnectAsync(new Uri("ws://localhost:8080/"), CancellationToken.None); + byte[] data = new byte[100]; // Encoding.UTF8.GetBytes( // TODO: Hangs after 10 seconds // "Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World" // "Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, " // "Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, " - "Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, " - ); + // "Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, " + // ); while (true) { - await socket.SendAsync(new ArraySegment(data), WebSocketMessageType.Text, true, CancellationToken.None); + // await socket.SendAsync(new ArraySegment(data), WebSocketMessageType.Text, true, CancellationToken.None); WebSocketReceiveResult result; do { result = await socket.ReceiveAsync(new ArraySegment(data), CancellationToken.None); - // Console.WriteLine("Received: " + result.MessageType + ", " + result.Count + ", " + result.EndOfMessage); + Console.WriteLine("Received: " + result.MessageType + ", " + result.Count + ", " + result.EndOfMessage); } while (!result.EndOfMessage); - // Console.WriteLine(Encoding.UTF8.GetString(data, 0, result.Count)); + Console.WriteLine(Encoding.UTF8.GetString(data, 0, result.Count)); } await socket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Closing", CancellationToken.None); } diff --git a/test/TestClient/Project.json b/test/TestClient/Project.json new file mode 100644 index 0000000000..f0b9935396 --- /dev/null +++ b/test/TestClient/Project.json @@ -0,0 +1,10 @@ +{ + "version": "0.1-alpha-*", + "dependencies": { + "Microsoft.AspNet.WebSockets.Protocol": "", + "Microsoft.AspNet.WebSockets.Client": "" + }, + "configurations": { + "net45": { } + } +} \ No newline at end of file diff --git a/test/TestClient/TestClient.csproj b/test/TestClient/TestClient.csproj deleted file mode 100644 index fdd95f9be8..0000000000 --- a/test/TestClient/TestClient.csproj +++ /dev/null @@ -1,65 +0,0 @@ - - - - - Debug - AnyCPU - {22AB02E0-0346-4C4B-BBE7-C829A8D1C19E} - Exe - Properties - TestClient - TestClient - v4.5.1 - 512 - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - {b43d2069-9690-49b2-ba0c-9e8acc32cb83} - Microsoft.Net.WebSockets.net45 - - - - - \ No newline at end of file diff --git a/test/TestClient/TestClient.kproj b/test/TestClient/TestClient.kproj new file mode 100644 index 0000000000..e5d4236d57 --- /dev/null +++ b/test/TestClient/TestClient.kproj @@ -0,0 +1,34 @@ + + + + 12.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 8c8eac01-dc49-4c5e-b348-e4e46fe675f9 + Library + + + ConsoleDebugger + + + WebDebugger + + + + + + + 2.0 + + + + + + + + + + + \ No newline at end of file From 2deea2c299a84f0499242220960d1cd98ed971e0 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Thu, 12 Jun 2014 20:16:25 -0700 Subject: [PATCH 022/453] Delete old file. --- .../Microsoft.Net.WebSockets.kproj | 38 ------------------- 1 file changed, 38 deletions(-) delete mode 100644 src/Microsoft.Net.WebSockets/Microsoft.Net.WebSockets.kproj diff --git a/src/Microsoft.Net.WebSockets/Microsoft.Net.WebSockets.kproj b/src/Microsoft.Net.WebSockets/Microsoft.Net.WebSockets.kproj deleted file mode 100644 index 01bea96825..0000000000 --- a/src/Microsoft.Net.WebSockets/Microsoft.Net.WebSockets.kproj +++ /dev/null @@ -1,38 +0,0 @@ - - - - 12.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - e0c10dec-3339-4a47-85bc-3100c5d34ad4 - Library - - - ConsoleDebugger - - - WebDebugger - - - - - - - 2.0 - - - - - - - - - - - - - - - \ No newline at end of file From 0c0321c6941a0c9a3bca95f1c8180fa65096006e Mon Sep 17 00:00:00 2001 From: David Fowler Date: Fri, 13 Jun 2014 07:32:13 -0700 Subject: [PATCH 023/453] Renamed Project.json to Project.json2 --- .../{Project.json => Project.json2} | 0 .../{Project.json => Project.json2} | 0 test/TestClient/{Project.json => Project.json2} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename src/Microsoft.AspNet.WebSockets.Protocol/{Project.json => Project.json2} (100%) rename test/Microsoft.AspNet.WebSockets.Protocol.Test/{Project.json => Project.json2} (100%) rename test/TestClient/{Project.json => Project.json2} (100%) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/Project.json b/src/Microsoft.AspNet.WebSockets.Protocol/Project.json2 similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Protocol/Project.json rename to src/Microsoft.AspNet.WebSockets.Protocol/Project.json2 diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Project.json b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Project.json2 similarity index 100% rename from test/Microsoft.AspNet.WebSockets.Protocol.Test/Project.json rename to test/Microsoft.AspNet.WebSockets.Protocol.Test/Project.json2 diff --git a/test/TestClient/Project.json b/test/TestClient/Project.json2 similarity index 100% rename from test/TestClient/Project.json rename to test/TestClient/Project.json2 From 32aa84d97578781c2f2a9f34c0a353cbeb6930c1 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Fri, 13 Jun 2014 07:32:14 -0700 Subject: [PATCH 024/453] Fixed project.json casing --- .../Microsoft.AspNet.WebSockets.Client.kproj | 2 +- .../Microsoft.AspNet.WebSockets.Middleware.kproj | 2 +- .../Microsoft.AspNet.WebSockets.Protocol.kproj | 2 +- .../{Project.json2 => project.json} | 0 .../Microsoft.AspNet.WebSockets.Client.Test.kproj | 2 +- .../Microsoft.AspNet.WebSockets.Protocol.Test.kproj | 2 +- .../{Project.json2 => project.json} | 0 test/TestClient/TestClient.kproj | 2 +- test/TestClient/{Project.json2 => project.json} | 0 9 files changed, 6 insertions(+), 6 deletions(-) rename src/Microsoft.AspNet.WebSockets.Protocol/{Project.json2 => project.json} (100%) rename test/Microsoft.AspNet.WebSockets.Protocol.Test/{Project.json2 => project.json} (100%) rename test/TestClient/{Project.json2 => project.json} (100%) diff --git a/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.kproj b/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.kproj index cbb9475cbe..0456e48b11 100644 --- a/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.kproj +++ b/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.kproj @@ -32,4 +32,4 @@ - \ No newline at end of file + diff --git a/src/Microsoft.AspNet.WebSockets.Middleware/Microsoft.AspNet.WebSockets.Middleware.kproj b/src/Microsoft.AspNet.WebSockets.Middleware/Microsoft.AspNet.WebSockets.Middleware.kproj index 45d5fac74c..89ca756f23 100644 --- a/src/Microsoft.AspNet.WebSockets.Middleware/Microsoft.AspNet.WebSockets.Middleware.kproj +++ b/src/Microsoft.AspNet.WebSockets.Middleware/Microsoft.AspNet.WebSockets.Middleware.kproj @@ -32,4 +32,4 @@ - \ No newline at end of file + diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.kproj b/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.kproj index 6293d3e4f1..a249dfede5 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.kproj +++ b/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.kproj @@ -34,4 +34,4 @@ - \ No newline at end of file + diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/Project.json2 b/src/Microsoft.AspNet.WebSockets.Protocol/project.json similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Protocol/Project.json2 rename to src/Microsoft.AspNet.WebSockets.Protocol/project.json diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.kproj b/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.kproj index 93d5ef5be4..8206597b7e 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.kproj +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.kproj @@ -31,4 +31,4 @@ - \ No newline at end of file + diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.kproj b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.kproj index 651c44174e..9e4aa7ba19 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.kproj +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.kproj @@ -33,4 +33,4 @@ - \ No newline at end of file + diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Project.json2 b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json similarity index 100% rename from test/Microsoft.AspNet.WebSockets.Protocol.Test/Project.json2 rename to test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json diff --git a/test/TestClient/TestClient.kproj b/test/TestClient/TestClient.kproj index e5d4236d57..37d8856a7d 100644 --- a/test/TestClient/TestClient.kproj +++ b/test/TestClient/TestClient.kproj @@ -31,4 +31,4 @@ - \ No newline at end of file + diff --git a/test/TestClient/Project.json2 b/test/TestClient/project.json similarity index 100% rename from test/TestClient/Project.json2 rename to test/TestClient/project.json From f938a6ad758017d4651613659bdab954b944206e Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Wed, 18 Jun 2014 16:52:47 -0700 Subject: [PATCH 025/453] Change the default author in makefile.shade --- makefile.shade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefile.shade b/makefile.shade index 6357ea2841..562494d144 100644 --- a/makefile.shade +++ b/makefile.shade @@ -1,7 +1,7 @@ var VERSION='0.1' var FULL_VERSION='0.1' -var AUTHORS='Microsoft' +var AUTHORS='Microsoft Open Technologies, Inc.' use-standard-lifecycle k-standard-goals From 6d56ee2471ff626d9433ef91c6b3b8e58f56b179 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Thu, 19 Jun 2014 11:45:50 -0700 Subject: [PATCH 026/453] Bump version to 1.0.0-* --- src/Microsoft.AspNet.WebSockets.Client/project.json | 2 +- src/Microsoft.AspNet.WebSockets.Middleware/project.json | 6 +++--- src/Microsoft.AspNet.WebSockets.Protocol/project.json | 4 ++-- test/Microsoft.AspNet.WebSockets.Client.Test/project.json | 6 +----- test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json | 6 +----- test/TestClient/project.json | 1 - 6 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Client/project.json b/src/Microsoft.AspNet.WebSockets.Client/project.json index 693ed10e9e..2d1668b984 100644 --- a/src/Microsoft.AspNet.WebSockets.Client/project.json +++ b/src/Microsoft.AspNet.WebSockets.Client/project.json @@ -1,5 +1,5 @@ { - "version": "0.1-alpha-*", + "version": "1.0.0-*", "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "" }, diff --git a/src/Microsoft.AspNet.WebSockets.Middleware/project.json b/src/Microsoft.AspNet.WebSockets.Middleware/project.json index 4d125efcb2..d4c932e7f9 100644 --- a/src/Microsoft.AspNet.WebSockets.Middleware/project.json +++ b/src/Microsoft.AspNet.WebSockets.Middleware/project.json @@ -1,8 +1,8 @@ { - "version": "0.1-alpha-*", + "version": "1.0.0-*", "dependencies": { - "Microsoft.AspNet.Http": "0.1-alpha-*", - "Microsoft.AspNet.HttpFeature": "0.1-alpha-*", + "Microsoft.AspNet.Http": "1.0.0-*", + "Microsoft.AspNet.HttpFeature": "1.0.0-*", "Microsoft.AspNet.WebSockets.Protocol": "" }, "configurations" : { diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index 8bace8ef52..5fdfe5b60f 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -1,10 +1,10 @@ { - "version": "0.1-alpha-*", + "version": "1.0.0-*", "configurations": { "net45": { }, "k10": { "dependencies": { - "Microsoft.Net.WebSocketAbstractions": "0.1-alpha-*", + "Microsoft.Net.WebSocketAbstractions": "1.0.0-*", "System.Diagnostics.Contracts": "4.0.0.0", "System.Linq": "4.0.0.0", "System.Runtime": "4.0.20.0", diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json index 78a038c2f1..d2883eb7e0 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json @@ -2,11 +2,7 @@ "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "", "Microsoft.AspNet.WebSockets.Client": "", - "xunit.abstractions": "2.0.0-aspnet-*", - "xunit.assert": "2.0.0-aspnet-*", - "xunit.core": "2.0.0-aspnet-*", - "xunit.execution": "2.0.0-aspnet-*", - "Xunit.KRunner": "0.1-alpha-*" + "Xunit.KRunner": "1.0.0-*" }, "configurations": { "net45": { diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json index bd91f51336..22571925e8 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json @@ -1,11 +1,7 @@ { "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "", - "xunit.abstractions": "2.0.0-aspnet-*", - "xunit.assert": "2.0.0-aspnet-*", - "xunit.core": "2.0.0-aspnet-*", - "xunit.execution": "2.0.0-aspnet-*", - "Xunit.KRunner": "0.1-alpha-*" + "Xunit.KRunner": "1.0.0-*" }, "configurations": { "net45": { diff --git a/test/TestClient/project.json b/test/TestClient/project.json index f0b9935396..fddf3c34f1 100644 --- a/test/TestClient/project.json +++ b/test/TestClient/project.json @@ -1,5 +1,4 @@ { - "version": "0.1-alpha-*", "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "", "Microsoft.AspNet.WebSockets.Client": "" From 4f54640fb58606d3661e9cd8461c5cfb61fe49fa Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Fri, 20 Jun 2014 14:34:13 -0700 Subject: [PATCH 027/453] Updating release Nuget.config --- NuGet.Config | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index a059188b09..1ce6b9e257 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,13 +1,7 @@ - + - + - - - - - - - \ No newline at end of file + From 75915500ccd9226e8f700236f4859ce2eb24c5f8 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Fri, 20 Jun 2014 14:34:14 -0700 Subject: [PATCH 028/453] Updating dev Nuget.config --- NuGet.Config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index 1ce6b9e257..f41e9c631d 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@ - + - + From b24d808b584f4e9b55c6588f83349b198fcd0877 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Mon, 30 Jun 2014 12:22:16 -0700 Subject: [PATCH 029/453] #10 - Rename Middleware package to Server. --- WebSockets.sln | 4 ++-- .../Microsoft.AspNet.WebSockets.Server.kproj} | 0 .../WebSocketMiddleware.cs | 7 +++++-- .../WebSocketMiddlewareExtensions.cs | 5 ++++- .../project.json | 0 5 files changed, 11 insertions(+), 5 deletions(-) rename src/{Microsoft.AspNet.WebSockets.Middleware/Microsoft.AspNet.WebSockets.Middleware.kproj => Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.kproj} (100%) rename src/{Microsoft.AspNet.WebSockets.Middleware => Microsoft.AspNet.WebSockets.Server}/WebSocketMiddleware.cs (94%) rename src/{Microsoft.AspNet.WebSockets.Middleware => Microsoft.AspNet.WebSockets.Server}/WebSocketMiddlewareExtensions.cs (53%) rename src/{Microsoft.AspNet.WebSockets.Middleware => Microsoft.AspNet.WebSockets.Server}/project.json (100%) diff --git a/WebSockets.sln b/WebSockets.sln index fcae05ecd2..d17c4c30fe 100644 --- a/WebSockets.sln +++ b/WebSockets.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.21730.1 +VisualStudioVersion = 14.0.21813.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestServer", "test\TestServer\TestServer.csproj", "{4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}" EndProject @@ -21,7 +21,7 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Client.Test", "test\Microsoft.AspNet.WebSockets.Client.Test\Microsoft.AspNet.WebSockets.Client.Test.kproj", "{6604D154-817F-4BC5-BE95-FF7E851179D9}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Middleware", "src\Microsoft.AspNet.WebSockets.Middleware\Microsoft.AspNet.WebSockets.Middleware.kproj", "{78A097D0-C0A4-4AED-93E2-84A65392FB52}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Server", "src\Microsoft.AspNet.WebSockets.Server\Microsoft.AspNet.WebSockets.Server.kproj", "{78A097D0-C0A4-4AED-93E2-84A65392FB52}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/Microsoft.AspNet.WebSockets.Middleware/Microsoft.AspNet.WebSockets.Middleware.kproj b/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.kproj similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Middleware/Microsoft.AspNet.WebSockets.Middleware.kproj rename to src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.kproj diff --git a/src/Microsoft.AspNet.WebSockets.Middleware/WebSocketMiddleware.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs similarity index 94% rename from src/Microsoft.AspNet.WebSockets.Middleware/WebSocketMiddleware.cs rename to src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs index 4407194370..44825a9897 100644 --- a/src/Microsoft.AspNet.WebSockets.Middleware/WebSocketMiddleware.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; using System.Collections.Generic; using System.IO; using System.Net.WebSockets; @@ -8,7 +11,7 @@ using Microsoft.AspNet.Http; using Microsoft.AspNet.HttpFeature; using Microsoft.AspNet.WebSockets.Protocol; -namespace Microsoft.AspNet.WebSockets.Middleware +namespace Microsoft.AspNet.WebSockets.Server { public class WebSocketMiddleware { diff --git a/src/Microsoft.AspNet.WebSockets.Middleware/WebSocketMiddlewareExtensions.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs similarity index 53% rename from src/Microsoft.AspNet.WebSockets.Middleware/WebSocketMiddlewareExtensions.cs rename to src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs index ee0e3eb764..584ca3abc1 100644 --- a/src/Microsoft.AspNet.WebSockets.Middleware/WebSocketMiddlewareExtensions.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs @@ -1,4 +1,7 @@ -using Microsoft.AspNet.WebSockets.Middleware; +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNet.WebSockets.Server; namespace Microsoft.AspNet.Builder { diff --git a/src/Microsoft.AspNet.WebSockets.Middleware/project.json b/src/Microsoft.AspNet.WebSockets.Server/project.json similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Middleware/project.json rename to src/Microsoft.AspNet.WebSockets.Server/project.json From df425e479662db6daafd0d6df48b8bfae5d86e8e Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Mon, 30 Jun 2014 12:50:55 -0700 Subject: [PATCH 030/453] Server: Expose WebSocketOptions. Make feature replacement configurable. --- .../Microsoft.AspNet.WebSockets.Server.kproj | 4 +- .../WebSocketAcceptContext.cs | 17 +++++++++ .../WebSocketMiddleware.cs | 38 +++++++++---------- .../WebSocketMiddlewareExtensions.cs | 7 +++- .../WebSocketOptions.cs | 38 +++++++++++++++++++ 5 files changed, 83 insertions(+), 21 deletions(-) create mode 100644 src/Microsoft.AspNet.WebSockets.Server/WebSocketAcceptContext.cs create mode 100644 src/Microsoft.AspNet.WebSockets.Server/WebSocketOptions.cs diff --git a/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.kproj b/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.kproj index 89ca756f23..8c7033f08b 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.kproj +++ b/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.kproj @@ -25,11 +25,13 @@ 2.0 + + - + \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketAcceptContext.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketAcceptContext.cs new file mode 100644 index 0000000000..0762d79eff --- /dev/null +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketAcceptContext.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNet.HttpFeature; + +namespace Microsoft.AspNet.WebSockets.Server +{ + public class WebSocketAcceptContext : IWebSocketAcceptContext + { + public string SubProtocol { get; set; } + public int? ReceiveBufferSize { get; set; } + public TimeSpan? KeepAliveInterval { get; set; } + + // public ArraySegment? Buffer { get; set; } // TODO + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs index 44825a9897..2a2077cfdc 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs @@ -15,21 +15,27 @@ namespace Microsoft.AspNet.WebSockets.Server { public class WebSocketMiddleware { - private RequestDelegate _next; + private readonly RequestDelegate _next; + private readonly WebSocketOptions _options; - public WebSocketMiddleware(RequestDelegate next) + public WebSocketMiddleware(RequestDelegate next, WebSocketOptions options) { _next = next; + _options = options; + + // TODO: validate options. } public Task Invoke(HttpContext context) { - // Detect if an opaque upgrade is available, and if websocket upgrade headers are present. - // If so, add a websocket upgrade. + // Detect if an opaque upgrade is available. If so, add a websocket upgrade. var upgradeFeature = context.GetFeature(); if (upgradeFeature != null) { - context.SetFeature(new UpgradeHandshake(context, upgradeFeature)); + if (_options.ReplaceFeature || context.GetFeature() == null) + { + context.SetFeature(new UpgradeHandshake(context, upgradeFeature, _options)); + } } return _next(context); @@ -37,13 +43,15 @@ namespace Microsoft.AspNet.WebSockets.Server private class UpgradeHandshake : IHttpWebSocketFeature { - private HttpContext _context; - private IHttpOpaqueUpgradeFeature _upgradeFeature; + private readonly HttpContext _context; + private readonly IHttpOpaqueUpgradeFeature _upgradeFeature; + private readonly WebSocketOptions _options; - public UpgradeHandshake(HttpContext context, IHttpOpaqueUpgradeFeature upgradeFeature) + public UpgradeHandshake(HttpContext context, IHttpOpaqueUpgradeFeature upgradeFeature, WebSocketOptions options) { _context = context; _upgradeFeature = upgradeFeature; + _options = options; } public bool IsWebSocketRequest @@ -70,7 +78,7 @@ namespace Microsoft.AspNet.WebSockets.Server { if (!IsWebSocketRequest) { - throw new InvalidOperationException("Not a WebSocket request."); + throw new InvalidOperationException("Not a WebSocket request."); // TODO: LOC } string subProtocol = null; @@ -79,8 +87,8 @@ namespace Microsoft.AspNet.WebSockets.Server subProtocol = acceptContext.SubProtocol; } - TimeSpan keepAliveInterval = TimeSpan.FromMinutes(2); // TODO: - int receiveBufferSize = 4 * 1024; // TODO: + TimeSpan keepAliveInterval = _options.KeepAliveInterval; + int receiveBufferSize = _options.ReceiveBufferSize; var advancedAcceptContext = acceptContext as WebSocketAcceptContext; if (advancedAcceptContext != null) { @@ -106,13 +114,5 @@ namespace Microsoft.AspNet.WebSockets.Server return CommonWebSocket.CreateServerWebSocket(opaqueTransport, subProtocol, keepAliveInterval, receiveBufferSize); } } - - public class WebSocketAcceptContext : IWebSocketAcceptContext - { - public string SubProtocol { get; set; } - public int? ReceiveBufferSize { get; set; } - public TimeSpan? KeepAliveInterval { get; set; } - // public ArraySegment? Buffer { get; set; } // TODO - } } } diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs index 584ca3abc1..8dd1559d23 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs @@ -9,7 +9,12 @@ namespace Microsoft.AspNet.Builder { public static IBuilder UseWebSockets(this IBuilder builder) { - return builder.Use(next => new WebSocketMiddleware(next).Invoke); + return builder.UseWebSockets(new WebSocketOptions()); + } + + public static IBuilder UseWebSockets(this IBuilder builder, WebSocketOptions options) // TODO: [NotNull] + { + return builder.Use(next => new WebSocketMiddleware(next, options).Invoke); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketOptions.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketOptions.cs new file mode 100644 index 0000000000..5f46a23558 --- /dev/null +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketOptions.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; + +namespace Microsoft.AspNet.WebSockets.Server +{ + /// + /// Configuration options for the WebSocketMiddleware + /// + public class WebSocketOptions + { + public WebSocketOptions() + { + KeepAliveInterval = TimeSpan.FromMinutes(2); + ReceiveBufferSize = 4 * 1024; + ReplaceFeature = false; + } + + /// + /// Gets or sets the frequency at which to send Ping/Pong keep-alive control frames. + /// The default is two minutes. + /// + public TimeSpan KeepAliveInterval { get; set; } + + /// + /// Gets or sets the size of the protocol buffer used to receive and parse frames. + /// The default is 4kb. + /// + public int ReceiveBufferSize { get; set; } + + /// + /// Gets or sets if the middleware should replace the WebSocket implementation provided by + /// a component earlier in the stack. This is false by default. + /// + public bool ReplaceFeature { get; set; } + } +} \ No newline at end of file From d98df8a873a802819cad1cf341e7c6d1dea60746 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Tue, 1 Jul 2014 10:22:31 -0700 Subject: [PATCH 031/453] Updated packages due to changes in security contracts --- src/Microsoft.AspNet.WebSockets.Protocol/project.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index 5fdfe5b60f..c0a6a41151 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -10,7 +10,8 @@ "System.Runtime": "4.0.20.0", "System.Runtime.InteropServices": "4.0.20.0", "System.Runtime.Extensions": "4.0.10.0", - "System.Security.Cryptography.HashAlgorithms.SHA1": "4.0.0.0", + "System.Security.Cryptography": "4.0.0.0", + "System.Security.Cryptography.Hashing.Algorithms": "4.0.0.0", "System.Threading": "4.0.0.0", "System.Threading.Tasks": "4.0.10.0", "System.Threading.Timer": "4.0.0.0" From 7133ab1b2a0b4c2e18501de2593728aafab10839 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Thu, 3 Jul 2014 14:07:38 -0700 Subject: [PATCH 032/453] Rename IHttpOpaqueUpgradeFeature to IHttpUpgradeFeature. --- .../WebSocketMiddleware.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs index 2a2077cfdc..51e735674a 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs @@ -29,7 +29,7 @@ namespace Microsoft.AspNet.WebSockets.Server public Task Invoke(HttpContext context) { // Detect if an opaque upgrade is available. If so, add a websocket upgrade. - var upgradeFeature = context.GetFeature(); + var upgradeFeature = context.GetFeature(); if (upgradeFeature != null) { if (_options.ReplaceFeature || context.GetFeature() == null) @@ -44,10 +44,10 @@ namespace Microsoft.AspNet.WebSockets.Server private class UpgradeHandshake : IHttpWebSocketFeature { private readonly HttpContext _context; - private readonly IHttpOpaqueUpgradeFeature _upgradeFeature; + private readonly IHttpUpgradeFeature _upgradeFeature; private readonly WebSocketOptions _options; - public UpgradeHandshake(HttpContext context, IHttpOpaqueUpgradeFeature upgradeFeature, WebSocketOptions options) + public UpgradeHandshake(HttpContext context, IHttpUpgradeFeature upgradeFeature, WebSocketOptions options) { _context = context; _upgradeFeature = upgradeFeature; From 0a50505f4daf4d799f708b3fec16036a374dff0a Mon Sep 17 00:00:00 2001 From: David Fowler Date: Sun, 13 Jul 2014 22:09:54 -0700 Subject: [PATCH 033/453] Renamed configurations to frameworks in project.json --- src/Microsoft.AspNet.WebSockets.Client/project.json | 4 ++-- src/Microsoft.AspNet.WebSockets.Protocol/project.json | 6 +++--- src/Microsoft.AspNet.WebSockets.Server/project.json | 2 +- test/Microsoft.AspNet.WebSockets.Client.Test/project.json | 4 ++-- test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json | 6 +++--- test/TestClient/project.json | 6 +++--- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Client/project.json b/src/Microsoft.AspNet.WebSockets.Client/project.json index 2d1668b984..a3abcf62fb 100644 --- a/src/Microsoft.AspNet.WebSockets.Client/project.json +++ b/src/Microsoft.AspNet.WebSockets.Client/project.json @@ -3,7 +3,7 @@ "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "" }, - "configurations": { + "frameworks": { "net45": { } } -} \ No newline at end of file +} diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index c0a6a41151..784a1dc044 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -1,6 +1,6 @@ -{ +{ "version": "1.0.0-*", - "configurations": { + "frameworks": { "net45": { }, "k10": { "dependencies": { @@ -18,4 +18,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/Microsoft.AspNet.WebSockets.Server/project.json b/src/Microsoft.AspNet.WebSockets.Server/project.json index d4c932e7f9..3c0d73c1ca 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/project.json +++ b/src/Microsoft.AspNet.WebSockets.Server/project.json @@ -5,7 +5,7 @@ "Microsoft.AspNet.HttpFeature": "1.0.0-*", "Microsoft.AspNet.WebSockets.Protocol": "" }, - "configurations" : { + "frameworks" : { "net45" : { }, "k10" : { "dependencies": { diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json index d2883eb7e0..039029a32d 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json @@ -4,7 +4,7 @@ "Microsoft.AspNet.WebSockets.Client": "", "Xunit.KRunner": "1.0.0-*" }, - "configurations": { + "frameworks": { "net45": { "dependencies": { "System.Runtime" : "" @@ -14,4 +14,4 @@ "commands": { "test": "Xunit.KRunner" } -} \ No newline at end of file +} diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json index 22571925e8..d5058102aa 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json @@ -1,9 +1,9 @@ -{ +{ "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "", "Xunit.KRunner": "1.0.0-*" }, - "configurations": { + "frameworks": { "net45": { "dependencies": { "System.Runtime" : "" @@ -13,4 +13,4 @@ "commands": { "test": "Xunit.KRunner" } -} \ No newline at end of file +} diff --git a/test/TestClient/project.json b/test/TestClient/project.json index fddf3c34f1..a813f17211 100644 --- a/test/TestClient/project.json +++ b/test/TestClient/project.json @@ -1,9 +1,9 @@ -{ +{ "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "", "Microsoft.AspNet.WebSockets.Client": "" }, - "configurations": { + "frameworks": { "net45": { } } -} \ No newline at end of file +} From 839e066d5934a613ff2bf2ff3c84d51f1cf24c21 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 17 Jul 2014 09:30:34 -0700 Subject: [PATCH 034/453] Reacting to System.Security.Cryptograph.Encryption package rename --- src/Microsoft.AspNet.WebSockets.Protocol/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index 784a1dc044..0a600cfc61 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -10,7 +10,7 @@ "System.Runtime": "4.0.20.0", "System.Runtime.InteropServices": "4.0.20.0", "System.Runtime.Extensions": "4.0.10.0", - "System.Security.Cryptography": "4.0.0.0", + "System.Security.Cryptography.Encryption": "4.0.0.0", "System.Security.Cryptography.Hashing.Algorithms": "4.0.0.0", "System.Threading": "4.0.0.0", "System.Threading.Tasks": "4.0.10.0", From e86cae43bb78c953a96d3de301cb9e9562a10356 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 5 Aug 2014 15:51:09 -0700 Subject: [PATCH 035/453] Updating release Nuget.config --- NuGet.Config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index f41e9c631d..1ce6b9e257 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@ - + - + From 66a15775cbb4337ebfeb7080f98d020fbb39f97a Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 6 Aug 2014 12:30:54 -0700 Subject: [PATCH 036/453] Updating dev Nuget.config --- NuGet.Config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index 1ce6b9e257..f41e9c631d 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@ - + - + From 23b13d3143d2405e1e08b11a52df083219980ab9 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Fri, 15 Aug 2014 09:42:19 -0700 Subject: [PATCH 037/453] Removed source files from the project --- .../Microsoft.AspNet.WebSockets.Client.kproj | 9 +-------- .../Microsoft.AspNet.WebSockets.Protocol.kproj | 13 +------------ .../Microsoft.AspNet.WebSockets.Server.kproj | 9 --------- .../Microsoft.AspNet.WebSockets.Client.Test.kproj | 8 +------- .../Microsoft.AspNet.WebSockets.Protocol.Test.kproj | 12 +----------- test/TestClient/TestClient.kproj | 10 +--------- 6 files changed, 5 insertions(+), 56 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.kproj b/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.kproj index 0456e48b11..647fb58b72 100644 --- a/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.kproj +++ b/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.kproj @@ -24,12 +24,5 @@ 2.0 - - - - - - - - + \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.kproj b/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.kproj index a249dfede5..9e7d70fe30 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.kproj +++ b/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.kproj @@ -22,16 +22,5 @@ 2.0 - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.kproj b/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.kproj index 8c7033f08b..3e07ae5b82 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.kproj +++ b/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.kproj @@ -24,14 +24,5 @@ 2.0 - - - - - - - - - \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.kproj b/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.kproj index 8206597b7e..c107fe29b8 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.kproj +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.kproj @@ -24,11 +24,5 @@ 2.0 - - - - - - - + \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.kproj b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.kproj index 9e4aa7ba19..0381c2116b 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.kproj +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.kproj @@ -22,15 +22,5 @@ 2.0 - - - - - - - - - - - + \ No newline at end of file diff --git a/test/TestClient/TestClient.kproj b/test/TestClient/TestClient.kproj index 37d8856a7d..26ee2a677c 100644 --- a/test/TestClient/TestClient.kproj +++ b/test/TestClient/TestClient.kproj @@ -22,13 +22,5 @@ 2.0 - - - - - - - - - + \ No newline at end of file From ca360a25f740729204c9c6e76e6eb13c7c06252a Mon Sep 17 00:00:00 2001 From: David Fowler Date: Fri, 29 Aug 2014 00:10:01 -0700 Subject: [PATCH 038/453] Updated to use the new target framework in project.json --- src/Microsoft.AspNet.WebSockets.Client/project.json | 2 +- src/Microsoft.AspNet.WebSockets.Protocol/project.json | 4 ++-- src/Microsoft.AspNet.WebSockets.Server/project.json | 4 ++-- test/Microsoft.AspNet.WebSockets.Client.Test/project.json | 2 +- test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json | 2 +- test/TestClient/project.json | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Client/project.json b/src/Microsoft.AspNet.WebSockets.Client/project.json index a3abcf62fb..7a3966d04d 100644 --- a/src/Microsoft.AspNet.WebSockets.Client/project.json +++ b/src/Microsoft.AspNet.WebSockets.Client/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "" diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index 0a600cfc61..f91624ed40 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -1,8 +1,8 @@ -{ +{ "version": "1.0.0-*", "frameworks": { "net45": { }, - "k10": { + "aspnetcore50": { "dependencies": { "Microsoft.Net.WebSocketAbstractions": "1.0.0-*", "System.Diagnostics.Contracts": "4.0.0.0", diff --git a/src/Microsoft.AspNet.WebSockets.Server/project.json b/src/Microsoft.AspNet.WebSockets.Server/project.json index 3c0d73c1ca..12c16adf0a 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/project.json +++ b/src/Microsoft.AspNet.WebSockets.Server/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "dependencies": { "Microsoft.AspNet.Http": "1.0.0-*", @@ -7,7 +7,7 @@ }, "frameworks" : { "net45" : { }, - "k10" : { + "aspnetcore50" : { "dependencies": { "System.Runtime": "4.0.20.0" } diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json index 039029a32d..60eb7a7043 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json @@ -1,4 +1,4 @@ -{ +{ "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "", "Microsoft.AspNet.WebSockets.Client": "", diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json index d5058102aa..ab53a015e4 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json @@ -1,4 +1,4 @@ -{ +{ "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "", "Xunit.KRunner": "1.0.0-*" diff --git a/test/TestClient/project.json b/test/TestClient/project.json index a813f17211..356d8e0767 100644 --- a/test/TestClient/project.json +++ b/test/TestClient/project.json @@ -1,4 +1,4 @@ -{ +{ "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "", "Microsoft.AspNet.WebSockets.Client": "" From ddcce629cf83a31cc1119fee4c7bd392c4ca3563 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Thu, 4 Sep 2014 01:41:48 -0700 Subject: [PATCH 039/453] Made the server project aspnet50 instead of net45 --- .gitignore | 3 ++- src/Microsoft.AspNet.WebSockets.Server/project.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 8bc217058d..e3c5c21725 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,5 @@ nuget.exe *DS_Store *.ncrunchsolution *.*sdf -*.ipch \ No newline at end of file +*.ipch +*.sln.ide diff --git a/src/Microsoft.AspNet.WebSockets.Server/project.json b/src/Microsoft.AspNet.WebSockets.Server/project.json index 12c16adf0a..07d555dddf 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/project.json +++ b/src/Microsoft.AspNet.WebSockets.Server/project.json @@ -6,7 +6,7 @@ "Microsoft.AspNet.WebSockets.Protocol": "" }, "frameworks" : { - "net45" : { }, + "aspnet50" : { }, "aspnetcore50" : { "dependencies": { "System.Runtime": "4.0.20.0" From 9c47620e1d1734156e5b77d1453459296094d7aa Mon Sep 17 00:00:00 2001 From: David Fowler Date: Fri, 5 Sep 2014 01:53:27 -0700 Subject: [PATCH 040/453] Updated build.cmd --- build.cmd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.cmd b/build.cmd index 3aaf957583..86ca5bbbf1 100644 --- a/build.cmd +++ b/build.cmd @@ -20,9 +20,9 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion IF "%SKIP_KRE_INSTALL%"=="1" goto run -CALL packages\KoreBuild\build\kvm upgrade -svr50 -x86 -CALL packages\KoreBuild\build\kvm install default -svrc50 -x86 +CALL packages\KoreBuild\build\kvm upgrade -runtime CLR -x86 +CALL packages\KoreBuild\build\kvm install default -runtime CoreCLR -x86 :run -CALL packages\KoreBuild\build\kvm use default -svr50 -x86 +CALL packages\KoreBuild\build\kvm use default -runtime CLR -x86 packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* From a2fc6e28a8b61d5d091fa47cbbfa5d32b5bdd6d2 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Wed, 10 Sep 2014 14:39:52 -0700 Subject: [PATCH 041/453] Handle IBuilder rename to IApplicationBuilder. --- WebSockets.sln | 7 ++++++- .../WebSocketMiddlewareExtensions.cs | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/WebSockets.sln b/WebSockets.sln index d17c4c30fe..9101a12f9e 100644 --- a/WebSockets.sln +++ b/WebSockets.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.21813.0 +VisualStudioVersion = 14.0.22013.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestServer", "test\TestServer\TestServer.csproj", "{4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}" EndProject @@ -23,6 +23,11 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Server", "src\Microsoft.AspNet.WebSockets.Server\Microsoft.AspNet.WebSockets.Server.kproj", "{78A097D0-C0A4-4AED-93E2-84A65392FB52}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{86E1ADA2-631C-484F-906C-2D0BCF628E65}" + ProjectSection(SolutionItems) = preProject + global.json = global.json + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs index 8dd1559d23..91c69080ba 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs @@ -7,12 +7,12 @@ namespace Microsoft.AspNet.Builder { public static class WebSocketMiddlewareExtensions { - public static IBuilder UseWebSockets(this IBuilder builder) + public static IApplicationBuilder UseWebSockets(this IApplicationBuilder builder) { return builder.UseWebSockets(new WebSocketOptions()); } - public static IBuilder UseWebSockets(this IBuilder builder, WebSocketOptions options) // TODO: [NotNull] + public static IApplicationBuilder UseWebSockets(this IApplicationBuilder builder, WebSocketOptions options) // TODO: [NotNull] { return builder.Use(next => new WebSocketMiddleware(next, options).Invoke); } From 3b5c3daf08d88f41e0816e5bb2f4f3c5f793b9db Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 17 Sep 2014 10:01:11 -0700 Subject: [PATCH 042/453] Updating release NuGet.config --- NuGet.Config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index f41e9c631d..1ce6b9e257 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@ - + - + From b704f6142082286596141327883b06f9618215da Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 17 Sep 2014 10:01:13 -0700 Subject: [PATCH 043/453] Updating dev NuGet.config --- NuGet.Config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index 1ce6b9e257..f41e9c631d 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@ - + - + From 49fcaa7862bffe1b65c16b5886228410987fd3e1 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Sat, 4 Oct 2014 03:03:08 -0700 Subject: [PATCH 044/453] Updated the target framework --- test/Microsoft.AspNet.WebSockets.Client.Test/project.json | 2 +- test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json index 60eb7a7043..f1199e942b 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json @@ -5,7 +5,7 @@ "Xunit.KRunner": "1.0.0-*" }, "frameworks": { - "net45": { + "aspnet50": { "dependencies": { "System.Runtime" : "" } diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json index ab53a015e4..1fbe5b2da8 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json @@ -4,7 +4,7 @@ "Xunit.KRunner": "1.0.0-*" }, "frameworks": { - "net45": { + "aspnet50": { "dependencies": { "System.Runtime" : "" } From 787138322bb2468c0e86bb01c4bb6f528a9ad071 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Sun, 5 Oct 2014 14:21:22 -0700 Subject: [PATCH 045/453] Fixup references --- .../project.json | 2 +- .../project.json | 26 +++++++++---------- .../project.json | 12 ++++----- .../project.json | 10 +++---- .../project.json | 8 ++---- test/TestClient/project.json | 6 ++--- 6 files changed, 28 insertions(+), 36 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Client/project.json b/src/Microsoft.AspNet.WebSockets.Client/project.json index 7a3966d04d..201fefcb75 100644 --- a/src/Microsoft.AspNet.WebSockets.Client/project.json +++ b/src/Microsoft.AspNet.WebSockets.Client/project.json @@ -1,7 +1,7 @@ { "version": "1.0.0-*", "dependencies": { - "Microsoft.AspNet.WebSockets.Protocol": "" + "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*" }, "frameworks": { "net45": { } diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index f91624ed40..6442c8dbea 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -3,19 +3,19 @@ "frameworks": { "net45": { }, "aspnetcore50": { - "dependencies": { - "Microsoft.Net.WebSocketAbstractions": "1.0.0-*", - "System.Diagnostics.Contracts": "4.0.0.0", - "System.Linq": "4.0.0.0", - "System.Runtime": "4.0.20.0", - "System.Runtime.InteropServices": "4.0.20.0", - "System.Runtime.Extensions": "4.0.10.0", - "System.Security.Cryptography.Encryption": "4.0.0.0", - "System.Security.Cryptography.Hashing.Algorithms": "4.0.0.0", - "System.Threading": "4.0.0.0", - "System.Threading.Tasks": "4.0.10.0", - "System.Threading.Timer": "4.0.0.0" - } + "dependencies": { + "Microsoft.Net.WebSocketAbstractions": "1.0.0-*", + "System.Diagnostics.Contracts": "4.0.0.0", + "System.Linq": "4.0.0.0", + "System.Runtime": "4.0.20.0", + "System.Runtime.InteropServices": "4.0.20.0", + "System.Runtime.Extensions": "4.0.10.0", + "System.Security.Cryptography.Encryption": "4.0.0.0", + "System.Security.Cryptography.Hashing.Algorithms": "4.0.0.0", + "System.Threading": "4.0.0.0", + "System.Threading.Tasks": "4.0.10.0", + "System.Threading.Timer": "4.0.0.0" + } } } } diff --git a/src/Microsoft.AspNet.WebSockets.Server/project.json b/src/Microsoft.AspNet.WebSockets.Server/project.json index 07d555dddf..101ea39934 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/project.json +++ b/src/Microsoft.AspNet.WebSockets.Server/project.json @@ -1,13 +1,13 @@ { "version": "1.0.0-*", "dependencies": { - "Microsoft.AspNet.Http": "1.0.0-*", - "Microsoft.AspNet.HttpFeature": "1.0.0-*", - "Microsoft.AspNet.WebSockets.Protocol": "" + "Microsoft.AspNet.Http": "1.0.0-*", + "Microsoft.AspNet.HttpFeature": { "version": "1.0.0-*", "type": "build" }, + "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*" }, - "frameworks" : { - "aspnet50" : { }, - "aspnetcore50" : { + "frameworks": { + "aspnet50": { }, + "aspnetcore50": { "dependencies": { "System.Runtime": "4.0.20.0" } diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json index f1199e942b..2513189d82 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json @@ -1,15 +1,11 @@ { "dependencies": { - "Microsoft.AspNet.WebSockets.Protocol": "", - "Microsoft.AspNet.WebSockets.Client": "", + "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", + "Microsoft.AspNet.WebSockets.Client": "1.0.0-*", "Xunit.KRunner": "1.0.0-*" }, "frameworks": { - "aspnet50": { - "dependencies": { - "System.Runtime" : "" - } - } + "aspnet50": { } }, "commands": { "test": "Xunit.KRunner" diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json index 1fbe5b2da8..e33d7f4d0d 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json @@ -1,14 +1,10 @@ { "dependencies": { - "Microsoft.AspNet.WebSockets.Protocol": "", + "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", "Xunit.KRunner": "1.0.0-*" }, "frameworks": { - "aspnet50": { - "dependencies": { - "System.Runtime" : "" - } - } + "aspnet50": { } }, "commands": { "test": "Xunit.KRunner" diff --git a/test/TestClient/project.json b/test/TestClient/project.json index 356d8e0767..ec5d45197c 100644 --- a/test/TestClient/project.json +++ b/test/TestClient/project.json @@ -1,9 +1,9 @@ { "dependencies": { - "Microsoft.AspNet.WebSockets.Protocol": "", - "Microsoft.AspNet.WebSockets.Client": "" + "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", + "Microsoft.AspNet.WebSockets.Client": "1.0.0-*" }, "frameworks": { - "net45": { } + "aspnet50": { } } } From 83f4d0261d6c2ab1a7bbf39edf6a5eeeff6d96d8 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 10 Oct 2014 10:34:52 -0700 Subject: [PATCH 046/453] Reacting to CLR package versioning changes --- .../project.json | 20 +++++++++---------- .../project.json | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index 6442c8dbea..8094991757 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -5,16 +5,16 @@ "aspnetcore50": { "dependencies": { "Microsoft.Net.WebSocketAbstractions": "1.0.0-*", - "System.Diagnostics.Contracts": "4.0.0.0", - "System.Linq": "4.0.0.0", - "System.Runtime": "4.0.20.0", - "System.Runtime.InteropServices": "4.0.20.0", - "System.Runtime.Extensions": "4.0.10.0", - "System.Security.Cryptography.Encryption": "4.0.0.0", - "System.Security.Cryptography.Hashing.Algorithms": "4.0.0.0", - "System.Threading": "4.0.0.0", - "System.Threading.Tasks": "4.0.10.0", - "System.Threading.Timer": "4.0.0.0" + "System.Diagnostics.Contracts": "4.0.0-beta-*", + "System.Linq": "4.0.0-beta-*", + "System.Runtime": "4.0.20-beta-*", + "System.Runtime.InteropServices": "4.0.20-beta-*", + "System.Runtime.Extensions": "4.0.10-beta-*", + "System.Security.Cryptography.Encryption": "4.0.0-beta-*", + "System.Security.Cryptography.Hashing.Algorithms": "4.0.0-beta-*", + "System.Threading": "4.0.0-beta-*", + "System.Threading.Tasks": "4.0.10-beta-*", + "System.Threading.Timer": "4.0.0-beta-*" } } } diff --git a/src/Microsoft.AspNet.WebSockets.Server/project.json b/src/Microsoft.AspNet.WebSockets.Server/project.json index 101ea39934..f729c453dd 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/project.json +++ b/src/Microsoft.AspNet.WebSockets.Server/project.json @@ -9,7 +9,7 @@ "aspnet50": { }, "aspnetcore50": { "dependencies": { - "System.Runtime": "4.0.20.0" + "System.Runtime": "4.0.20-beta-*" } } } From 86822d541c7bcf864aedb4426812bca49d792065 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 21 Oct 2014 12:49:36 -0700 Subject: [PATCH 047/453] Adding build.sh --- build.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 build.sh diff --git a/build.sh b/build.sh new file mode 100644 index 0000000000..c7873ef58e --- /dev/null +++ b/build.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +if test `uname` = Darwin; then + cachedir=~/Library/Caches/KBuild +else + if [ -z $XDG_DATA_HOME ]; then + cachedir=$HOME/.local/share + else + cachedir=$XDG_DATA_HOME; + fi +fi +mkdir -p $cachedir + +url=https://www.nuget.org/nuget.exe + +if test ! -f $cachedir/nuget.exe; then + wget -O $cachedir/nuget.exe $url 2>/dev/null || curl -o $cachedir/nuget.exe --location $url /dev/null +fi + +if test ! -e .nuget; then + mkdir .nuget + cp $cachedir/nuget.exe .nuget/nuget.exe +fi + +if test ! -d packages/KoreBuild; then + mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre + mono .nuget/nuget.exe install Sake -version 0.2 -o packages -ExcludeVersion +fi + +if ! type k > /dev/null 2>&1; then + source packages/KoreBuild/build/kvm.sh +fi + +if ! type k > /dev/null 2>&1; then + kvm upgrade +fi + +mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" From ade78b1aba59c08f42111c60b1c32f2cc6b27d9b Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Wed, 22 Oct 2014 10:39:28 -0700 Subject: [PATCH 048/453] #1 - Implement Autobahn test client & server. --- WebSockets.sln | 16 ++- .../AutobahnTestClient.kproj | 20 ++++ test/AutobahnTestClient/Program.cs | 102 ++++++++++++++++++ test/AutobahnTestClient/Project.json | 11 ++ test/AutobahnTestClient/ReadMe.txt | 23 ++++ .../AutobahnTestServer.kproj | 19 ++++ test/AutobahnTestServer/Project.json | 14 +++ test/AutobahnTestServer/ReadMe.txt | 25 +++++ test/AutobahnTestServer/Startup.cs | 55 ++++++++++ 9 files changed, 284 insertions(+), 1 deletion(-) create mode 100644 test/AutobahnTestClient/AutobahnTestClient.kproj create mode 100644 test/AutobahnTestClient/Program.cs create mode 100644 test/AutobahnTestClient/Project.json create mode 100644 test/AutobahnTestClient/ReadMe.txt create mode 100644 test/AutobahnTestServer/AutobahnTestServer.kproj create mode 100644 test/AutobahnTestServer/Project.json create mode 100644 test/AutobahnTestServer/ReadMe.txt create mode 100644 test/AutobahnTestServer/Startup.cs diff --git a/WebSockets.sln b/WebSockets.sln index 9101a12f9e..6b9df02739 100644 --- a/WebSockets.sln +++ b/WebSockets.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.22013.1 +VisualStudioVersion = 14.0.22216.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestServer", "test\TestServer\TestServer.csproj", "{4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}" EndProject @@ -28,6 +28,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution global.json = global.json EndProjectSection EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AutobahnTestServer", "test\AutobahnTestServer\AutobahnTestServer.kproj", "{C03C43FE-9201-48A6-B434-AD67EF627D67}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AutobahnTestClient", "test\AutobahnTestClient\AutobahnTestClient.kproj", "{BC4D2BB1-05A8-4816-8BC1-3A664F09EE32}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -62,6 +66,14 @@ Global {78A097D0-C0A4-4AED-93E2-84A65392FB52}.Debug|Any CPU.Build.0 = Debug|Any CPU {78A097D0-C0A4-4AED-93E2-84A65392FB52}.Release|Any CPU.ActiveCfg = Release|Any CPU {78A097D0-C0A4-4AED-93E2-84A65392FB52}.Release|Any CPU.Build.0 = Release|Any CPU + {C03C43FE-9201-48A6-B434-AD67EF627D67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C03C43FE-9201-48A6-B434-AD67EF627D67}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C03C43FE-9201-48A6-B434-AD67EF627D67}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C03C43FE-9201-48A6-B434-AD67EF627D67}.Release|Any CPU.Build.0 = Release|Any CPU + {BC4D2BB1-05A8-4816-8BC1-3A664F09EE32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BC4D2BB1-05A8-4816-8BC1-3A664F09EE32}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BC4D2BB1-05A8-4816-8BC1-3A664F09EE32}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BC4D2BB1-05A8-4816-8BC1-3A664F09EE32}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -74,5 +86,7 @@ Global {4A1C4875-AE21-4A78-979A-F0E4DF5EB518} = {2C7947A5-9FBD-4267-97C1-2D726D7B3BAF} {6604D154-817F-4BC5-BE95-FF7E851179D9} = {C45106D0-76C8-4776-A140-F7DD83CA2958} {78A097D0-C0A4-4AED-93E2-84A65392FB52} = {2C7947A5-9FBD-4267-97C1-2D726D7B3BAF} + {C03C43FE-9201-48A6-B434-AD67EF627D67} = {C45106D0-76C8-4776-A140-F7DD83CA2958} + {BC4D2BB1-05A8-4816-8BC1-3A664F09EE32} = {C45106D0-76C8-4776-A140-F7DD83CA2958} EndGlobalSection EndGlobal diff --git a/test/AutobahnTestClient/AutobahnTestClient.kproj b/test/AutobahnTestClient/AutobahnTestClient.kproj new file mode 100644 index 0000000000..46b1cb9752 --- /dev/null +++ b/test/AutobahnTestClient/AutobahnTestClient.kproj @@ -0,0 +1,20 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + bc4d2bb1-05a8-4816-8bc1-3a664f09ee32 + AutobahnTestClient + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ + + + + 2.0 + + + \ No newline at end of file diff --git a/test/AutobahnTestClient/Program.cs b/test/AutobahnTestClient/Program.cs new file mode 100644 index 0000000000..15300f825b --- /dev/null +++ b/test/AutobahnTestClient/Program.cs @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Net.WebSockets; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNet.WebSockets.Client; + +namespace AutobahnTestClient +{ + public class Program + { + public async Task Main(string[] args) + { + try + { + string serverAddress = "ws://localhost:9001"; + string agent = + "ManagedWebSockets"; + // "NativeWebSockets"; + + Console.WriteLine("Getting case count."); + var caseCount = await GetCaseCountAsync(serverAddress, agent); + Console.WriteLine(caseCount + " case(s)."); + + for (int i = 1; i <= caseCount; i++) + { + await RunCaseAsync(serverAddress, i, agent); + } + + await UpdateReportsAsync(serverAddress, agent); + } + catch (Exception ex) + { + Console.WriteLine(ex); + } + + Console.WriteLine("Done"); + Console.ReadLine(); + } + + private async Task ConnectAsync(string address, string agent) + { + if (string.Equals(agent, "NativeWebSockets")) + { + var client = new ClientWebSocket(); + await client.ConnectAsync(new Uri(address), CancellationToken.None); + return client; + } + else + { + // TODO: BUG: Require ws or wss schemes + var client = new WebSocketClient(); + return await client.ConnectAsync(new Uri(address), CancellationToken.None); + } + } + + private async Task GetCaseCountAsync(string serverAddress, string agent) + { + var webSocket = await ConnectAsync(serverAddress + "/getCaseCount", agent); + byte[] buffer = new byte[1024 * 4]; + var result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); + await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty, CancellationToken.None); + var caseCountText = Encoding.UTF8.GetString(buffer, 0, result.Count); + return int.Parse(caseCountText); + } + + private async Task RunCaseAsync(string serverAddress, int caseId, string agent) + { + try + { + Console.WriteLine("Running case " + caseId); + var webSocket = await ConnectAsync(serverAddress + "/runCase?case=" + caseId + "&agent=" + agent, agent); + await Echo(webSocket); + } + catch (Exception ex) + { + Console.WriteLine(ex); + } + } + + private async Task Echo(WebSocket webSocket) + { + byte[] buffer = new byte[1024 * 4]; + var result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); + while (!result.CloseStatus.HasValue) + { + await webSocket.SendAsync(new ArraySegment(buffer, 0, result.Count), result.MessageType, result.EndOfMessage, CancellationToken.None); + result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); + } + await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + } + + private async Task UpdateReportsAsync(string serverAddress, string agent) + { + var webSocket = await ConnectAsync(serverAddress + "/updateReports?agent=" + agent, agent); + await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty, CancellationToken.None); + } + } +} diff --git a/test/AutobahnTestClient/Project.json b/test/AutobahnTestClient/Project.json new file mode 100644 index 0000000000..ecb3dd00df --- /dev/null +++ b/test/AutobahnTestClient/Project.json @@ -0,0 +1,11 @@ +{ + "dependencies": { + "Microsoft.AspNet.WebSockets.Client": "1.0.0-*" + }, + "commands": { + "run" : "run" + }, + "frameworks" : { + "aspnet50" : { } + } +} diff --git a/test/AutobahnTestClient/ReadMe.txt b/test/AutobahnTestClient/ReadMe.txt new file mode 100644 index 0000000000..c49984330f --- /dev/null +++ b/test/AutobahnTestClient/ReadMe.txt @@ -0,0 +1,23 @@ +This test server is for use in testing client side implementations of the WebSocekt protocol. It is currently implemented to test +Microsoft.AspNet.WebSockets.Client.WebSocketClient and System.Net.WebSockets.ClientWebSocket. + +See http://autobahn.ws/ to download and install the test framework. + +Usage: +Run the test server: +"C:\Program Files\Python\2.7.6\Scripts\wstest" -d -m fuzzingserver -s fuzzingserver.json +Where fuzzingserver.json contains the following: + +{ + "url": "ws://127.0.0.1:9001", + + "options": {"failByDrop": false}, + "outdir": "./reports/clients", + "webport": 8080, + + "cases": ["*"], + "exclude-cases": [], + "exclude-agent-cases": {} +} + +Then run the client of your choice, taking care to update the serverAddress and agent fields in the client code. \ No newline at end of file diff --git a/test/AutobahnTestServer/AutobahnTestServer.kproj b/test/AutobahnTestServer/AutobahnTestServer.kproj new file mode 100644 index 0000000000..d8b0d38382 --- /dev/null +++ b/test/AutobahnTestServer/AutobahnTestServer.kproj @@ -0,0 +1,19 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + c03c43fe-9201-48a6-b434-ad67ef627d67 + AutobahnTestServer + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ + + + 2.0 + 60351 + + + \ No newline at end of file diff --git a/test/AutobahnTestServer/Project.json b/test/AutobahnTestServer/Project.json new file mode 100644 index 0000000000..b1ac9e5da6 --- /dev/null +++ b/test/AutobahnTestServer/Project.json @@ -0,0 +1,14 @@ +{ + "webroot": "wwwroot", + "exclude": "wwwroot/**/*", + "dependencies": { + "Microsoft.AspNet.Server.IIS": "1.0.0-beta1-*", + "Microsoft.AspNet.Server.WebListener": "1.0.0-beta1-*", + "Microsoft.AspNet.WebSockets.Server": "1.0.0-beta1-*" + }, + "commands": { "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:12345" }, + "frameworks" : { + "aspnet50" : { }, + "aspnetcore50" : { } + } +} diff --git a/test/AutobahnTestServer/ReadMe.txt b/test/AutobahnTestServer/ReadMe.txt new file mode 100644 index 0000000000..0c0bb6837d --- /dev/null +++ b/test/AutobahnTestServer/ReadMe.txt @@ -0,0 +1,25 @@ +This test server is for use in testing server side implementations of the WebSocekt protocol. It should work with Helios, WebListener (native), +and the managed implementation of WebSockets in this project (running on WebListener, Kestrel, etc.). The tests only require that the server implement +a basic WebSocket accept and then echo any content received. + +See http://autobahn.ws/ to download and install the test framework. + +Usage: +Configure and start the server of your choice. +Run the test client: +"C:\Program Files\Python\2.7.6\Scripts\wstest.exe" -d -m fuzzingclient -s fuzzingclient.json +Where fussingclient.json contains: +{ + "options": {"failByDrop": false}, + "outdir": "./reports/servers", + + "servers": [ + {"agent": "NameOfImplementationBeingTested", + "url": "ws://localhost:12345", + "options": {"version": 18}} + ], + + "cases": ["*"], + "exclude-cases": [], + "exclude-agent-cases": {} +} \ No newline at end of file diff --git a/test/AutobahnTestServer/Startup.cs b/test/AutobahnTestServer/Startup.cs new file mode 100644 index 0000000000..1e17919b11 --- /dev/null +++ b/test/AutobahnTestServer/Startup.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Net.WebSockets; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Http; +using Microsoft.AspNet.WebSockets.Server; + +namespace AutobahnTestServer +{ + public class Startup + { + public void Configure(IApplicationBuilder app) + { + // Comment this out to test native server implementations + app.UseWebSockets(new WebSocketOptions() + { + ReplaceFeature = true, + }); + + app.Use(async (context, next) => + { + if (context.IsWebSocketRequest) + { + Console.WriteLine("Echo: " + context.Request.Path); + var webSocket = await context.AcceptWebSocketAsync(); + await Echo(webSocket); + return; + } + await next(); + }); + + app.Run(context => + { + Console.WriteLine("Hello World"); + return context.Response.WriteAsync("Hello World"); + }); + } + + private async Task Echo(WebSocket webSocket) + { + byte[] buffer = new byte[1024 * 4]; + var result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); + while (!result.CloseStatus.HasValue) + { + await webSocket.SendAsync(new ArraySegment(buffer, 0, result.Count), result.MessageType, result.EndOfMessage, CancellationToken.None); + result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); + } + await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + } + } +} From 4a5dbccb46acb83cced322b464b0dee82e52c775 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Wed, 22 Oct 2014 15:55:26 -0700 Subject: [PATCH 049/453] #13 - Utf8 validation. --- .../CommonWebSocket.cs | 9 +++ .../Utilities.cs | 72 +++++++++++++++++++ .../Utf8ValidationTests.cs | 62 ++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 test/Microsoft.AspNet.WebSockets.Protocol.Test/Utf8ValidationTests.cs diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs index a5149a128f..191d436157 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs @@ -40,6 +40,7 @@ namespace Microsoft.AspNet.WebSockets.Protocol private long _frameBytesRemaining; private int? _firstDataOpCode; private int _dataUnmaskOffset; + private Utilities.Utf8MessageState _incomingUtf8MessageState = new Utilities.Utf8MessageState(); public CommonWebSocket(Stream stream, string subProtocol, TimeSpan keepAliveInterval, int receiveBufferSize, bool maskOutput, bool useZeroMask, bool unmaskInput) { @@ -251,6 +252,14 @@ namespace Microsoft.AspNet.WebSockets.Protocol WebSocketReceiveResult result; WebSocketMessageType messageType = Utilities.GetMessageType(opCode); + + if (messageType == WebSocketMessageType.Text + && !Utilities.TryValidateUtf8(new ArraySegment(buffer.Array, buffer.Offset, bytesToCopy), _frameInProgress.Fin, _incomingUtf8MessageState)) + { + await CloseOutputAsync(WebSocketCloseStatus.InvalidPayloadData, string.Empty, cancellationToken); + throw new InvalidOperationException("An invalid UTF-8 payload was received."); + } + if (bytesToCopy == _frameBytesRemaining) { result = new WebSocketReceiveResult(bytesToCopy, messageType, _frameInProgress.Fin); diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs b/src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs index a48a5a184b..a5a27c8299 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs @@ -69,5 +69,77 @@ namespace Microsoft.AspNet.WebSockets.Protocol default: throw new NotImplementedException(opCode.ToString()); } } + + // For now this is stateless and does not handle sequences spliced across messages. + // http://etutorials.org/Programming/secure+programming/Chapter+3.+Input+Validation/3.12+Detecting+Illegal+UTF-8+Characters/ + public static bool TryValidateUtf8(ArraySegment arraySegment, bool endOfMessage, Utf8MessageState state) + { + for (int i = arraySegment.Offset; i < arraySegment.Offset + arraySegment.Count; ) + { + if (!state.SequenceInProgress) + { + state.SequenceInProgress = true; + byte b = arraySegment.Array[i]; + if ((b & 0x80) == 0) // 0bbbbbbb, single byte + { + state.AdditionalBytesExpected = 0; + } + else if ((b & 0xC0) == 0x80) + { + return false; // Misplaced 10bbbbbb byte. This cannot be the first byte. + } + else if ((b & 0xE0) == 0xC0) // 110bbbbb 10bbbbbb + { + state.AdditionalBytesExpected = 1; + } + else if ((b & 0xF0) == 0xE0) // 1110bbbb 10bbbbbb 10bbbbbb + { + state.AdditionalBytesExpected = 2; + } + else if ((b & 0xF8) == 0xF0) // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb + { + state.AdditionalBytesExpected = 3; + } + else if ((b & 0xFC) == 0xF8) // 111110bb 10bbbbbb 10bbbbbb 10bbbbbb 10bbbbbb + { + state.AdditionalBytesExpected = 4; + } + else if ((b & 0xFE) == 0xFC) // 1111110b 10bbbbbb 10bbbbbb 10bbbbbb 10bbbbbb 10bbbbbb + { + state.AdditionalBytesExpected = 5; + } + else // 11111110 && 11111111 are not valid + { + return false; + } + i++; + } + while (state.AdditionalBytesExpected > 0 && i < arraySegment.Offset + arraySegment.Count) + { + byte b = arraySegment.Array[i]; + if ((b & 0xC0) != 0x80) + { + return false; + } + state.AdditionalBytesExpected--; + i++; + } + if (state.AdditionalBytesExpected == 0) + { + state.SequenceInProgress = false; + } + } + if (endOfMessage && state.SequenceInProgress) + { + return false; + } + return true; + } + + public class Utf8MessageState + { + public bool SequenceInProgress { get; set; } + public int AdditionalBytesExpected { get; set; } + } } } diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Utf8ValidationTests.cs b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Utf8ValidationTests.cs new file mode 100644 index 0000000000..a34fa2616d --- /dev/null +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Utf8ValidationTests.cs @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Text; +using Xunit; + +namespace Microsoft.AspNet.WebSockets.Protocol.Test +{ + public class Utf8ValidationTests + { + [Theory] + [InlineData(new byte[] { })] + [InlineData(new byte[] { 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64 })] // Hello World + [InlineData(new byte[] { 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x2D, 0xC2, 0xB5, 0x40, 0xC3, 0x9F, 0xC3, 0xB6, 0xC3, 0xA4, 0xC3, 0xBC, 0xC3, 0xA0, 0xC3, 0xA1 })] // "Hello-µ@ßöäüàá"; + public void ValidateSingleValidSegments_Valid(byte[] data) + { + var state = new Utilities.Utf8MessageState(); + Assert.True(Utilities.TryValidateUtf8(new ArraySegment(data), endOfMessage: true, state: state)); + } + + [Theory] + [InlineData(new byte[] { }, new byte[] { }, new byte[] { })] + [InlineData(new byte[] { 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20 }, new byte[] { }, new byte[] { 0x57, 0x6F, 0x72, 0x6C, 0x64 })] // Hello ,, World + [InlineData(new byte[] { 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x2D, 0xC2, }, new byte[] { 0xB5, 0x40, 0xC3, 0x9F, 0xC3, 0xB6, 0xC3, 0xA4, }, new byte[] { 0xC3, 0xBC, 0xC3, 0xA0, 0xC3, 0xA1 })] // "Hello-µ@ßöäüàá"; + public void ValidateMultipleValidSegments_Valid(byte[] data1, byte[] data2, byte[] data3) + { + var state = new Utilities.Utf8MessageState(); + Assert.True(Utilities.TryValidateUtf8(new ArraySegment(data1), endOfMessage: false, state: state)); + Assert.True(Utilities.TryValidateUtf8(new ArraySegment(data2), endOfMessage: false, state: state)); + Assert.True(Utilities.TryValidateUtf8(new ArraySegment(data3), endOfMessage: true, state: state)); + } + + [Theory] + [InlineData(new byte[] { 0xfe })] + [InlineData(new byte[] { 0xff })] + [InlineData(new byte[] { 0xfe, 0xfe, 0xff, 0xff })] + // [InlineData(new byte[] { 0xc0, 0xaf })] + // [InlineData(new byte[] { 0xe0, 0x80, 0xaf })] + // [InlineData(new byte[] { 0xf4, 0x90, 0x80, 0x80 })] + // [InlineData(new byte[] { 0xf0, 0x80, 0x80, 0xaf })] + // [InlineData(new byte[] { 0xf8, 0x80, 0x80, 0x80, 0xaf })] + // [InlineData(new byte[] { 0xfc, 0x80, 0x80, 0x80, 0x80, 0xaf })] + // [InlineData(new byte[] { 0xc1, 0xbf })] + // [InlineData(new byte[] { 0xed, 0xa0, 0x80, 0x65, 0x64, 0x69, 0x74, 0x65, 0x64 })] // 0xEDA080 decodes to 0xD800, which is a reserved high surrogate character. + public void ValidateSingleInvalidSegment_Invalid(byte[] data) + { + var state = new Utilities.Utf8MessageState(); + Assert.False(Utilities.TryValidateUtf8(new ArraySegment(data), endOfMessage: true, state: state)); + } + /* + [Theory] + // [InlineData(true, new byte[] { 0xce, 0xba, 0xe1, 0xbd, 0xb9, 0xcf, 0x83, 0xce, 0xbc, 0xce, 0xb5, 0xf4 }, false, new byte[] { 0x90 }, true, new byte[] { })] + public void ValidateMultipleInvalidSegments_Invalid(bool valid1, byte[] data1, bool valid2, byte[] data2, bool valid3, byte[] data3) + { + var state = new Utilities.Utf8MessageState(); + Assert.True(valid1 == Utilities.TryValidateUtf8(new ArraySegment(data1), endOfMessage: false, state: state), "1st"); + Assert.True(valid2 == Utilities.TryValidateUtf8(new ArraySegment(data2), endOfMessage: false, state: state), "2nd"); + Assert.True(valid3 == Utilities.TryValidateUtf8(new ArraySegment(data3), endOfMessage: true, state: state), "3rd"); + }*/ + } +} \ No newline at end of file From 207767a9b0878ea90690fc5ca28d3d531d104c18 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Wed, 22 Oct 2014 16:25:22 -0700 Subject: [PATCH 050/453] #15 - Validate ping frame size limits. --- .../CommonWebSocket.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs index 191d436157..32b39389bd 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs @@ -299,6 +299,15 @@ namespace Microsoft.AspNet.WebSockets.Protocol if (_frameInProgress.OpCode == Constants.OpCodes.PingFrame || _frameInProgress.OpCode == Constants.OpCodes.PongFrame) { + if (_frameBytesRemaining > 125) + { + if (State == WebSocketState.Open) + { + await CloseOutputAsync(WebSocketCloseStatus.ProtocolError, "Invalid control frame size", cancellationToken); + Abort(); + } + throw new InvalidOperationException("Control frame too large."); // TODO: WebSocketException + } // Drain it, should be less than 125 bytes await EnsureDataAvailableOrReadAsync((int)_frameBytesRemaining, cancellationToken); From 7d110347909189a672f95270e679d93ec444b5db Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Wed, 22 Oct 2014 16:26:20 -0700 Subject: [PATCH 051/453] #14 - Validate reserved bits. --- .../CommonWebSocket.cs | 32 ++++++++++++++++--- .../FrameHeader.cs | 6 ++++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs index 32b39389bd..e221a64cf2 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs @@ -221,7 +221,12 @@ namespace Microsoft.AspNet.WebSockets.Protocol { if (!_firstDataOpCode.HasValue) { - throw new InvalidOperationException("A continuation can't be the first frame"); + if (State == WebSocketState.Open) + { + await CloseOutputAsync(WebSocketCloseStatus.ProtocolError, "Invalid continuation frame", cancellationToken); + Abort(); + } + throw new InvalidOperationException("A continuation can't be the first frame"); // TODO: WebSocketException } opCode = _firstDataOpCode.Value; } @@ -256,8 +261,12 @@ namespace Microsoft.AspNet.WebSockets.Protocol if (messageType == WebSocketMessageType.Text && !Utilities.TryValidateUtf8(new ArraySegment(buffer.Array, buffer.Offset, bytesToCopy), _frameInProgress.Fin, _incomingUtf8MessageState)) { - await CloseOutputAsync(WebSocketCloseStatus.InvalidPayloadData, string.Empty, cancellationToken); - throw new InvalidOperationException("An invalid UTF-8 payload was received."); + if (State == WebSocketState.Open) + { + await CloseOutputAsync(WebSocketCloseStatus.InvalidPayloadData, "Invalid UTF-8", cancellationToken); + Abort(); + } + throw new InvalidOperationException("An invalid UTF-8 payload was received."); // TODO: WebSocketException } if (bytesToCopy == _frameBytesRemaining) @@ -292,9 +301,24 @@ namespace Microsoft.AspNet.WebSockets.Protocol _receiveBufferBytes -= frameHeaderSize; _frameBytesRemaining = _frameInProgress.DataLength; + if (_frameInProgress.AreReservedSet()) + { + if (State == WebSocketState.Open) + { + await CloseOutputAsync(WebSocketCloseStatus.ProtocolError, "Unexpected reserved bits set", cancellationToken); + Abort(); + } + throw new InvalidOperationException("Unexpected reserved bits are set."); // TODO: WebSocketException + } + if (_unmaskInput != _frameInProgress.Masked) { - throw new InvalidOperationException("Unmasking settings out of sync with data."); + if (State == WebSocketState.Open) + { + await CloseOutputAsync(WebSocketCloseStatus.ProtocolError, "Incorrect masking", cancellationToken); + Abort(); + } + throw new InvalidOperationException("Unmasking settings out of sync with data."); // TODO: WebSocketException } if (_frameInProgress.OpCode == Constants.OpCodes.PingFrame || _frameInProgress.OpCode == Constants.OpCodes.PongFrame) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/FrameHeader.cs b/src/Microsoft.AspNet.WebSockets.Protocol/FrameHeader.cs index 1307c69fd7..7c1cb0ab51 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/FrameHeader.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/FrameHeader.cs @@ -209,6 +209,12 @@ namespace Microsoft.AspNet.WebSockets.Protocol } } + // bits 1-3. + internal bool AreReservedSet() + { + return (_header[0] & 0x70) != 0; + } + // Given the second bytes of a frame, calculate how long the whole frame header should be. // Range 2-12 bytes public static int CalculateFrameHeaderSize(byte b2) From 31c76a0032a886d1a1cd3848893c50212b8f1fe7 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Wed, 22 Oct 2014 17:09:57 -0700 Subject: [PATCH 052/453] Clean up error handling. Check for control frame fragmentation. --- .../CommonWebSocket.cs | 72 +++++++++---------- .../FrameHeader.cs | 8 +++ 2 files changed, 41 insertions(+), 39 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs index e221a64cf2..ba76cc74d0 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs @@ -221,12 +221,7 @@ namespace Microsoft.AspNet.WebSockets.Protocol { if (!_firstDataOpCode.HasValue) { - if (State == WebSocketState.Open) - { - await CloseOutputAsync(WebSocketCloseStatus.ProtocolError, "Invalid continuation frame", cancellationToken); - Abort(); - } - throw new InvalidOperationException("A continuation can't be the first frame"); // TODO: WebSocketException + await SendErrorAbortAndThrow(WebSocketCloseStatus.ProtocolError, "Invalid continuation frame", cancellationToken); } opCode = _firstDataOpCode.Value; } @@ -261,12 +256,7 @@ namespace Microsoft.AspNet.WebSockets.Protocol if (messageType == WebSocketMessageType.Text && !Utilities.TryValidateUtf8(new ArraySegment(buffer.Array, buffer.Offset, bytesToCopy), _frameInProgress.Fin, _incomingUtf8MessageState)) { - if (State == WebSocketState.Open) - { - await CloseOutputAsync(WebSocketCloseStatus.InvalidPayloadData, "Invalid UTF-8", cancellationToken); - Abort(); - } - throw new InvalidOperationException("An invalid UTF-8 payload was received."); // TODO: WebSocketException + await SendErrorAbortAndThrow(WebSocketCloseStatus.InvalidPayloadData, "Invalid UTF-8", cancellationToken); } if (bytesToCopy == _frameBytesRemaining) @@ -303,47 +293,41 @@ namespace Microsoft.AspNet.WebSockets.Protocol if (_frameInProgress.AreReservedSet()) { - if (State == WebSocketState.Open) - { - await CloseOutputAsync(WebSocketCloseStatus.ProtocolError, "Unexpected reserved bits set", cancellationToken); - Abort(); - } - throw new InvalidOperationException("Unexpected reserved bits are set."); // TODO: WebSocketException + await SendErrorAbortAndThrow(WebSocketCloseStatus.ProtocolError, "Unexpected reserved bits set", cancellationToken); } if (_unmaskInput != _frameInProgress.Masked) { - if (State == WebSocketState.Open) - { - await CloseOutputAsync(WebSocketCloseStatus.ProtocolError, "Incorrect masking", cancellationToken); - Abort(); - } - throw new InvalidOperationException("Unmasking settings out of sync with data."); // TODO: WebSocketException + await SendErrorAbortAndThrow(WebSocketCloseStatus.ProtocolError, "Incorrect masking", cancellationToken); } - if (_frameInProgress.OpCode == Constants.OpCodes.PingFrame || _frameInProgress.OpCode == Constants.OpCodes.PongFrame) + if (_frameInProgress.IsControlFrame) { if (_frameBytesRemaining > 125) { - if (State == WebSocketState.Open) - { - await CloseOutputAsync(WebSocketCloseStatus.ProtocolError, "Invalid control frame size", cancellationToken); - Abort(); - } - throw new InvalidOperationException("Control frame too large."); // TODO: WebSocketException + await SendErrorAbortAndThrow(WebSocketCloseStatus.ProtocolError, "Invalid control frame size", cancellationToken); } - // Drain it, should be less than 125 bytes - await EnsureDataAvailableOrReadAsync((int)_frameBytesRemaining, cancellationToken); - if (_frameInProgress.OpCode == Constants.OpCodes.PingFrame) + if (!_frameInProgress.Fin) { - await SendPongReplyAsync(cancellationToken); + await SendErrorAbortAndThrow(WebSocketCloseStatus.ProtocolError, "Fragmented control frame", cancellationToken); } - _receiveBufferOffset += (int)_frameBytesRemaining; - _receiveBufferBytes -= (int)_frameBytesRemaining; - _frameBytesRemaining = 0; - _frameInProgress = null; + if (_frameInProgress.OpCode == Constants.OpCodes.PingFrame || _frameInProgress.OpCode == Constants.OpCodes.PongFrame) + { + // Drain it, should be less than 125 bytes + await EnsureDataAvailableOrReadAsync((int)_frameBytesRemaining, cancellationToken); + + if (_frameInProgress.OpCode == Constants.OpCodes.PingFrame) + { + await SendPongReplyAsync(cancellationToken); + } + + _receiveBufferOffset += (int)_frameBytesRemaining; + _receiveBufferBytes -= (int)_frameBytesRemaining; + _frameBytesRemaining = 0; + _frameInProgress = null; + } } } @@ -587,5 +571,15 @@ namespace Microsoft.AspNet.WebSockets.Protocol throw new ArgumentOutOfRangeException("buffer.Count", buffer.Count, string.Empty); } } + + private async Task SendErrorAbortAndThrow(WebSocketCloseStatus error, string message, CancellationToken cancellationToken) + { + if (State == WebSocketState.Open) + { + await CloseOutputAsync(error, message, cancellationToken); + } + Abort(); + throw new InvalidOperationException(message); // TODO: WebSocketException + } } } diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/FrameHeader.cs b/src/Microsoft.AspNet.WebSockets.Protocol/FrameHeader.cs index 7c1cb0ab51..5d9d693763 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/FrameHeader.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/FrameHeader.cs @@ -209,6 +209,14 @@ namespace Microsoft.AspNet.WebSockets.Protocol } } + public bool IsControlFrame + { + get + { + return OpCode >= Constants.OpCodes.CloseFrame; + } + } + // bits 1-3. internal bool AreReservedSet() { From e8c498532222a29b6acb69c576a060218b618e4c Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Thu, 23 Oct 2014 08:24:19 -0700 Subject: [PATCH 053/453] Verify contination frames. --- .../CommonWebSocket.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs index ba76cc74d0..41219be884 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs @@ -215,8 +215,14 @@ namespace Microsoft.AspNet.WebSockets.Protocol await ReadNextFrameAsync(cancellationToken); } - // Handle fragmentation, remember the first frame type int opCode = _frameInProgress.OpCode; + + if (opCode == Constants.OpCodes.CloseFrame) + { + return await ProcessCloseFrameAsync(cancellationToken); + } + + // Handle fragmentation, remember the first frame type if (opCode == Constants.OpCodes.ContinuationFrame) { if (!_firstDataOpCode.HasValue) @@ -230,11 +236,6 @@ namespace Microsoft.AspNet.WebSockets.Protocol _firstDataOpCode = opCode; } - if (opCode == Constants.OpCodes.CloseFrame) - { - return await ProcessCloseFrameAsync(cancellationToken); - } - // Make sure there's at least some data in the buffer int bytesToBuffer = (int)Math.Min((long)_receiveBuffer.Length, _frameBytesRemaining); await EnsureDataAvailableOrReadAsync(bytesToBuffer, cancellationToken); @@ -329,6 +330,11 @@ namespace Microsoft.AspNet.WebSockets.Protocol _frameInProgress = null; } } + else if (_firstDataOpCode.HasValue && _frameInProgress.OpCode != Constants.OpCodes.ContinuationFrame) + { + // A data frame is already in progress, but this new frame is not a continuation frame. + await SendErrorAbortAndThrow(WebSocketCloseStatus.ProtocolError, "Expected a continuation frame: " + _frameInProgress.OpCode, cancellationToken); + } } private async Task EnsureDataAvailableOrReadAsync(int bytesNeeded, CancellationToken cancellationToken) From b7c8d5cd42d3f72d7177b1fee4d0eeae49a9d419 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Thu, 23 Oct 2014 09:15:11 -0700 Subject: [PATCH 054/453] #17 - Validate close frame body. --- .../CommonWebSocket.cs | 14 +++++++++++++- .../project.json | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs index 41219be884..a045609012 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs @@ -414,7 +414,19 @@ namespace Microsoft.AspNet.WebSockets.Protocol Utilities.MaskInPlace(_frameInProgress.MaskKey, new ArraySegment(_receiveBuffer, _receiveBufferOffset, (int)_frameBytesRemaining)); } _closeStatus = (WebSocketCloseStatus)((_receiveBuffer[_receiveBufferOffset] << 8) | _receiveBuffer[_receiveBufferOffset + 1]); - _closeStatusDescription = Encoding.UTF8.GetString(_receiveBuffer, _receiveBufferOffset + 2, (int)_frameBytesRemaining - 2) ?? string.Empty; + try + { + var encoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true); + _closeStatusDescription = encoding.GetString(_receiveBuffer, _receiveBufferOffset + 2, (int)_frameBytesRemaining - 2) ?? string.Empty; + } + catch (DecoderFallbackException) + { + await SendErrorAbortAndThrow(WebSocketCloseStatus.ProtocolError, "Invalid UTF-8 close message.", cancellationToken); + } + } + else if (_frameBytesRemaining == 1) + { + await SendErrorAbortAndThrow(WebSocketCloseStatus.ProtocolError, "Invalid close body.", cancellationToken); } else { diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index 8094991757..3bf854488d 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -14,6 +14,7 @@ "System.Security.Cryptography.Hashing.Algorithms": "4.0.0-beta-*", "System.Threading": "4.0.0-beta-*", "System.Threading.Tasks": "4.0.10-beta-*", + "System.Text.Encoding.Extensions": "4.0.10-beta-*", "System.Threading.Timer": "4.0.0-beta-*" } } From 08441efeaeb9c951e99421d743114d64422c542f Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Thu, 23 Oct 2014 09:38:10 -0700 Subject: [PATCH 055/453] #18 - Validate close status codes. --- .../CommonWebSocket.cs | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs index a045609012..481e5a9393 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs @@ -414,6 +414,10 @@ namespace Microsoft.AspNet.WebSockets.Protocol Utilities.MaskInPlace(_frameInProgress.MaskKey, new ArraySegment(_receiveBuffer, _receiveBufferOffset, (int)_frameBytesRemaining)); } _closeStatus = (WebSocketCloseStatus)((_receiveBuffer[_receiveBufferOffset] << 8) | _receiveBuffer[_receiveBufferOffset + 1]); + if (!ValidateCloseStatus(_closeStatus.Value)) + { + await SendErrorAbortAndThrow(WebSocketCloseStatus.ProtocolError, "Invalid close status code.", cancellationToken); + } try { var encoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true); @@ -451,6 +455,29 @@ namespace Microsoft.AspNet.WebSockets.Protocol return result; } + private static bool ValidateCloseStatus(WebSocketCloseStatus closeStatus) + { + if (closeStatus < (WebSocketCloseStatus)1000 || closeStatus >= (WebSocketCloseStatus)5000) + { + return false; + } + else if (closeStatus >= (WebSocketCloseStatus)3000) + { + // 3000-3999 - Reserved for frameworks + // 4000-4999 - Reserved for private usage + return true; + } + int[] validCodes = new[] { 1000, 1001, 1002, 1003, 1007, 1008, 1009, 1010, 1011 }; + foreach (var validCode in validCodes) + { + if (closeStatus == (WebSocketCloseStatus)validCode) + { + return true; + } + } + return false; + } + public async override Task CloseAsync(WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken) { ThrowIfDisposed(); @@ -592,7 +619,7 @@ namespace Microsoft.AspNet.WebSockets.Protocol private async Task SendErrorAbortAndThrow(WebSocketCloseStatus error, string message, CancellationToken cancellationToken) { - if (State == WebSocketState.Open) + if (State == WebSocketState.Open || State == WebSocketState.CloseReceived) { await CloseOutputAsync(error, message, cancellationToken); } From ae77def939c3fe714f41e05efb0415ba407f832e Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Thu, 23 Oct 2014 10:08:14 -0700 Subject: [PATCH 056/453] #20 - Validate OpCodes. --- .../CommonWebSocket.cs | 57 +++++++++++-------- .../Constants.cs | 12 +++- 2 files changed, 45 insertions(+), 24 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs index 481e5a9393..c6d82a573b 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs @@ -4,6 +4,7 @@ using System; using System.Diagnostics.Contracts; using System.IO; +using System.Linq; using System.Net.WebSockets; using System.Text; using System.Threading; @@ -302,6 +303,11 @@ namespace Microsoft.AspNet.WebSockets.Protocol await SendErrorAbortAndThrow(WebSocketCloseStatus.ProtocolError, "Incorrect masking", cancellationToken); } + if (!ValidateOpCode(_frameInProgress.OpCode)) + { + await SendErrorAbortAndThrow(WebSocketCloseStatus.ProtocolError, "Invalid opcode: " + _frameInProgress.OpCode, cancellationToken); + } + if (_frameInProgress.IsControlFrame) { if (_frameBytesRemaining > 125) @@ -455,29 +461,6 @@ namespace Microsoft.AspNet.WebSockets.Protocol return result; } - private static bool ValidateCloseStatus(WebSocketCloseStatus closeStatus) - { - if (closeStatus < (WebSocketCloseStatus)1000 || closeStatus >= (WebSocketCloseStatus)5000) - { - return false; - } - else if (closeStatus >= (WebSocketCloseStatus)3000) - { - // 3000-3999 - Reserved for frameworks - // 4000-4999 - Reserved for private usage - return true; - } - int[] validCodes = new[] { 1000, 1001, 1002, 1003, 1007, 1008, 1009, 1010, 1011 }; - foreach (var validCode in validCodes) - { - if (closeStatus == (WebSocketCloseStatus)validCode) - { - return true; - } - } - return false; - } - public async override Task CloseAsync(WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken) { ThrowIfDisposed(); @@ -617,6 +600,34 @@ namespace Microsoft.AspNet.WebSockets.Protocol } } + private bool ValidateOpCode(int opCode) + { + return Constants.OpCodes.ValidOpCodes.Contains(opCode); + } + + private static bool ValidateCloseStatus(WebSocketCloseStatus closeStatus) + { + if (closeStatus < (WebSocketCloseStatus)1000 || closeStatus >= (WebSocketCloseStatus)5000) + { + return false; + } + else if (closeStatus >= (WebSocketCloseStatus)3000) + { + // 3000-3999 - Reserved for frameworks + // 4000-4999 - Reserved for private usage + return true; + } + int[] validCodes = new[] { 1000, 1001, 1002, 1003, 1007, 1008, 1009, 1010, 1011 }; + foreach (var validCode in validCodes) + { + if (closeStatus == (WebSocketCloseStatus)validCode) + { + return true; + } + } + return false; + } + private async Task SendErrorAbortAndThrow(WebSocketCloseStatus error, string message, CancellationToken cancellationToken) { if (State == WebSocketState.Open || State == WebSocketState.CloseReceived) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/Constants.cs b/src/Microsoft.AspNet.WebSockets.Protocol/Constants.cs index 07756e49e3..60a9340b67 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/Constants.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/Constants.cs @@ -25,7 +25,17 @@ namespace Microsoft.AspNet.WebSockets.Protocol public const int BinaryFrame = 0x2; public const int CloseFrame = 0x8; public const int PingFrame = 0x9; - public const int PongFrame = 0xA; + public const int PongFrame = 0xA; + + internal static readonly int[] ValidOpCodes = new int[] + { + ContinuationFrame, + TextFrame, + BinaryFrame, + CloseFrame, + PingFrame, + PongFrame, + }; } } } From 98e9285fa8b2ab00abe81374466d8f1a8c0fa9a3 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Thu, 23 Oct 2014 17:34:26 -0700 Subject: [PATCH 057/453] #13 - Detailed UTF-8 validation. --- .../Utilities.cs | 53 ++++++++++++++----- .../Utf8ValidationTests.cs | 45 ++++++++++------ 2 files changed, 68 insertions(+), 30 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs b/src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs index a5a27c8299..6531bea1a5 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs @@ -70,49 +70,52 @@ namespace Microsoft.AspNet.WebSockets.Protocol } } - // For now this is stateless and does not handle sequences spliced across messages. - // http://etutorials.org/Programming/secure+programming/Chapter+3.+Input+Validation/3.12+Detecting+Illegal+UTF-8+Characters/ + // Performs a stateful validation of UTF-8 bytes. + // It checks for valid formatting, overlong encodings, surrogates, and value ranges. public static bool TryValidateUtf8(ArraySegment arraySegment, bool endOfMessage, Utf8MessageState state) { for (int i = arraySegment.Offset; i < arraySegment.Offset + arraySegment.Count; ) { + // Have we started a character sequence yet? if (!state.SequenceInProgress) { + // The first byte tells us how many bytes are in the sequence. state.SequenceInProgress = true; byte b = arraySegment.Array[i]; + i++; if ((b & 0x80) == 0) // 0bbbbbbb, single byte { state.AdditionalBytesExpected = 0; + state.CurrentDecodeBits = b & 0x7F; + state.ExpectedValueMin = 0; } else if ((b & 0xC0) == 0x80) { - return false; // Misplaced 10bbbbbb byte. This cannot be the first byte. + // Misplaced 10bbbbbb continuation byte. This cannot be the first byte. + return false; } else if ((b & 0xE0) == 0xC0) // 110bbbbb 10bbbbbb { state.AdditionalBytesExpected = 1; + state.CurrentDecodeBits = b & 0x1F; + state.ExpectedValueMin = 0x80; } else if ((b & 0xF0) == 0xE0) // 1110bbbb 10bbbbbb 10bbbbbb { state.AdditionalBytesExpected = 2; + state.CurrentDecodeBits = b & 0xF; + state.ExpectedValueMin = 0x800; } else if ((b & 0xF8) == 0xF0) // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb { state.AdditionalBytesExpected = 3; + state.CurrentDecodeBits = b & 0x7; + state.ExpectedValueMin = 0x10000; } - else if ((b & 0xFC) == 0xF8) // 111110bb 10bbbbbb 10bbbbbb 10bbbbbb 10bbbbbb - { - state.AdditionalBytesExpected = 4; - } - else if ((b & 0xFE) == 0xFC) // 1111110b 10bbbbbb 10bbbbbb 10bbbbbb 10bbbbbb 10bbbbbb - { - state.AdditionalBytesExpected = 5; - } - else // 11111110 && 11111111 are not valid + else // 111110bb & 1111110b & 11111110 && 11111111 are not valid { return false; } - i++; } while (state.AdditionalBytesExpected > 0 && i < arraySegment.Offset + arraySegment.Count) { @@ -121,12 +124,32 @@ namespace Microsoft.AspNet.WebSockets.Protocol { return false; } - state.AdditionalBytesExpected--; + i++; + state.AdditionalBytesExpected--; + + // Each continuation byte carries 6 bits of data 0x10bbbbbb. + state.CurrentDecodeBits = (state.CurrentDecodeBits << 6) | b & 0x3F; + + if (state.AdditionalBytesExpected == 1 && state.CurrentDecodeBits >= 0x360 && state.CurrentDecodeBits <= 0x37F) + { + // This is going to end up in the range of 0xD800-0xDFFF UTF-16 surrogates that are not allowed in UTF-8; + return false; + } + if (state.AdditionalBytesExpected == 2 && state.CurrentDecodeBits >= 0x110) + { + // This is going to be out of the upper Unicode bound 0x10FFFF. + return false; + } } if (state.AdditionalBytesExpected == 0) { state.SequenceInProgress = false; + if (state.CurrentDecodeBits < state.ExpectedValueMin) + { + // Overlong encoding (e.g. using 2 bytes to encode something that only needed 1). + return false; + } } } if (endOfMessage && state.SequenceInProgress) @@ -140,6 +163,8 @@ namespace Microsoft.AspNet.WebSockets.Protocol { public bool SequenceInProgress { get; set; } public int AdditionalBytesExpected { get; set; } + public int ExpectedValueMin { get; set; } + public int CurrentDecodeBits { get; set; } } } } diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Utf8ValidationTests.cs b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Utf8ValidationTests.cs index a34fa2616d..ffd990b5e2 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Utf8ValidationTests.cs +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Utf8ValidationTests.cs @@ -13,6 +13,8 @@ namespace Microsoft.AspNet.WebSockets.Protocol.Test [InlineData(new byte[] { })] [InlineData(new byte[] { 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64 })] // Hello World [InlineData(new byte[] { 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x2D, 0xC2, 0xB5, 0x40, 0xC3, 0x9F, 0xC3, 0xB6, 0xC3, 0xA4, 0xC3, 0xBC, 0xC3, 0xA0, 0xC3, 0xA1 })] // "Hello-µ@ßöäüàá"; + // [InlineData(new byte[] { 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0xf0, 0xa4, 0xad, 0xa2, 0x77, 0x6f, 0x72, 0x6c, 0x64 })] // "hello\U00024b62world" + [InlineData(new byte[] { 0xf0, 0xa4, 0xad, 0xa2 })] // "\U00024b62" public void ValidateSingleValidSegments_Valid(byte[] data) { var state = new Utilities.Utf8MessageState(); @@ -35,28 +37,39 @@ namespace Microsoft.AspNet.WebSockets.Protocol.Test [InlineData(new byte[] { 0xfe })] [InlineData(new byte[] { 0xff })] [InlineData(new byte[] { 0xfe, 0xfe, 0xff, 0xff })] - // [InlineData(new byte[] { 0xc0, 0xaf })] - // [InlineData(new byte[] { 0xe0, 0x80, 0xaf })] - // [InlineData(new byte[] { 0xf4, 0x90, 0x80, 0x80 })] - // [InlineData(new byte[] { 0xf0, 0x80, 0x80, 0xaf })] - // [InlineData(new byte[] { 0xf8, 0x80, 0x80, 0x80, 0xaf })] - // [InlineData(new byte[] { 0xfc, 0x80, 0x80, 0x80, 0x80, 0xaf })] - // [InlineData(new byte[] { 0xc1, 0xbf })] - // [InlineData(new byte[] { 0xed, 0xa0, 0x80, 0x65, 0x64, 0x69, 0x74, 0x65, 0x64 })] // 0xEDA080 decodes to 0xD800, which is a reserved high surrogate character. + [InlineData(new byte[] { 0xc0, 0xb1 })] // Overlong Ascii + [InlineData(new byte[] { 0xc1, 0xb1 })] // Overlong Ascii + [InlineData(new byte[] { 0xe0, 0x80, 0xaf })] // Overlong + [InlineData(new byte[] { 0xf0, 0x80, 0x80, 0xaf })] // Overlong + [InlineData(new byte[] { 0xf8, 0x80, 0x80, 0x80, 0xaf })] // Overlong + [InlineData(new byte[] { 0xfc, 0x80, 0x80, 0x80, 0x80, 0xaf })] // Overlong + [InlineData(new byte[] { 0xed, 0xa0, 0x80, 0x65, 0x64, 0x69, 0x74, 0x65, 0x64 })] // 0xEDA080 decodes to 0xD800, which is a reserved high surrogate character. public void ValidateSingleInvalidSegment_Invalid(byte[] data) { var state = new Utilities.Utf8MessageState(); Assert.False(Utilities.TryValidateUtf8(new ArraySegment(data), endOfMessage: true, state: state)); } - /* - [Theory] - // [InlineData(true, new byte[] { 0xce, 0xba, 0xe1, 0xbd, 0xb9, 0xcf, 0x83, 0xce, 0xbc, 0xce, 0xb5, 0xf4 }, false, new byte[] { 0x90 }, true, new byte[] { })] - public void ValidateMultipleInvalidSegments_Invalid(bool valid1, byte[] data1, bool valid2, byte[] data2, bool valid3, byte[] data3) + + [Fact] + public void ValidateIndividualInvalidSegments_Invalid() { + var data = new byte[] { 0xce, 0xba, 0xe1, 0xbd, 0xb9, 0xcf, 0x83, 0xce, 0xbc, 0xce, 0xb5, 0xed, 0xa0, 0x80, 0x65, 0x64, 0x69, 0x74, 0x65, 0x64 }; var state = new Utilities.Utf8MessageState(); - Assert.True(valid1 == Utilities.TryValidateUtf8(new ArraySegment(data1), endOfMessage: false, state: state), "1st"); - Assert.True(valid2 == Utilities.TryValidateUtf8(new ArraySegment(data2), endOfMessage: false, state: state), "2nd"); - Assert.True(valid3 == Utilities.TryValidateUtf8(new ArraySegment(data3), endOfMessage: true, state: state), "3rd"); - }*/ + for (int i = 0; i < 12; i++) + { + Assert.True(Utilities.TryValidateUtf8(new ArraySegment(data, i, 1), endOfMessage: false, state: state), i.ToString()); + } + Assert.False(Utilities.TryValidateUtf8(new ArraySegment(data, 12, 1), endOfMessage: false, state: state), 12.ToString()); + } + + [Fact] + public void ValidateMultipleInvalidSegments_Invalid() + { + var data0 = new byte[] { 0xce, 0xba, 0xe1, 0xbd, 0xb9, 0xcf, 0x83, 0xce, 0xbc, 0xce, 0xb5, 0xf4 }; + var data1 = new byte[] { 0x90 }; + var state = new Utilities.Utf8MessageState(); + Assert.True(Utilities.TryValidateUtf8(new ArraySegment(data0), endOfMessage: false, state: state)); + Assert.False(Utilities.TryValidateUtf8(new ArraySegment(data1), endOfMessage: false, state: state)); + } } } \ No newline at end of file From 76d3043bbea559647681376efa67334d05879dcb Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Fri, 24 Oct 2014 15:14:07 -0700 Subject: [PATCH 058/453] Update Autobahn server app with native and managed paths. --- test/AutobahnTestServer/Project.json | 8 ++++-- test/AutobahnTestServer/Startup.cs | 40 ++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/test/AutobahnTestServer/Project.json b/test/AutobahnTestServer/Project.json index b1ac9e5da6..50dfc16dc4 100644 --- a/test/AutobahnTestServer/Project.json +++ b/test/AutobahnTestServer/Project.json @@ -4,9 +4,13 @@ "dependencies": { "Microsoft.AspNet.Server.IIS": "1.0.0-beta1-*", "Microsoft.AspNet.Server.WebListener": "1.0.0-beta1-*", - "Microsoft.AspNet.WebSockets.Server": "1.0.0-beta1-*" + "Microsoft.AspNet.WebSockets.Server": "1.0.0-beta1-*", + "Kestrel": "1.0.0-beta1-*" + }, + "commands": { + "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:12345", + "kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:12344" }, - "commands": { "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:12345" }, "frameworks" : { "aspnet50" : { }, "aspnetcore50" : { } diff --git a/test/AutobahnTestServer/Startup.cs b/test/AutobahnTestServer/Startup.cs index 1e17919b11..3a5692aadf 100644 --- a/test/AutobahnTestServer/Startup.cs +++ b/test/AutobahnTestServer/Startup.cs @@ -15,22 +15,40 @@ namespace AutobahnTestServer { public void Configure(IApplicationBuilder app) { - // Comment this out to test native server implementations - app.UseWebSockets(new WebSocketOptions() + app.Map("/Managed", managedWebSocketsApp => { - ReplaceFeature = true, + // Comment this out to test native server implementations + managedWebSocketsApp.UseWebSockets(new WebSocketOptions() + { + ReplaceFeature = true, + }); + + managedWebSocketsApp.Use(async (context, next) => + { + if (context.IsWebSocketRequest) + { + Console.WriteLine("Echo: " + context.Request.Path); + var webSocket = await context.AcceptWebSocketAsync(); + await Echo(webSocket); + return; + } + await next(); + }); }); - app.Use(async (context, next) => + app.Map("/Native", nativeWebSocketsApp => { - if (context.IsWebSocketRequest) + nativeWebSocketsApp.Use(async (context, next) => { - Console.WriteLine("Echo: " + context.Request.Path); - var webSocket = await context.AcceptWebSocketAsync(); - await Echo(webSocket); - return; - } - await next(); + if (context.IsWebSocketRequest) + { + Console.WriteLine("Echo: " + context.Request.Path); + var webSocket = await context.AcceptWebSocketAsync(); + await Echo(webSocket); + return; + } + await next(); + }); }); app.Run(context => From 035983f90e1df6b5b22f372d83ae8edf852a4207 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Fri, 24 Oct 2014 15:24:01 -0700 Subject: [PATCH 059/453] Add missing dependency. --- src/Microsoft.AspNet.WebSockets.Protocol/project.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index 3bf854488d..296af96c55 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -6,6 +6,7 @@ "dependencies": { "Microsoft.Net.WebSocketAbstractions": "1.0.0-*", "System.Diagnostics.Contracts": "4.0.0-beta-*", + "System.IO": "4.0.10-beta-*", "System.Linq": "4.0.0-beta-*", "System.Runtime": "4.0.20-beta-*", "System.Runtime.InteropServices": "4.0.20-beta-*", From be8859d07cd1faa59aef5e8169a1d60e15975705 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Fri, 24 Oct 2014 15:25:41 -0700 Subject: [PATCH 060/453] Cleanup. --- src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs b/src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs index 6531bea1a5..7b0b3186da 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs @@ -129,7 +129,7 @@ namespace Microsoft.AspNet.WebSockets.Protocol state.AdditionalBytesExpected--; // Each continuation byte carries 6 bits of data 0x10bbbbbb. - state.CurrentDecodeBits = (state.CurrentDecodeBits << 6) | b & 0x3F; + state.CurrentDecodeBits = (state.CurrentDecodeBits << 6) | (b & 0x3F); if (state.AdditionalBytesExpected == 1 && state.CurrentDecodeBits >= 0x360 && state.CurrentDecodeBits <= 0x37F) { From 82511a8489118d241cee9780cb4bac09e00c9a3a Mon Sep 17 00:00:00 2001 From: David Fowler Date: Fri, 31 Oct 2014 02:57:32 -0700 Subject: [PATCH 061/453] Added package descriptions --- src/Microsoft.AspNet.WebSockets.Client/project.json | 1 + src/Microsoft.AspNet.WebSockets.Protocol/project.json | 1 + src/Microsoft.AspNet.WebSockets.Server/project.json | 1 + 3 files changed, 3 insertions(+) diff --git a/src/Microsoft.AspNet.WebSockets.Client/project.json b/src/Microsoft.AspNet.WebSockets.Client/project.json index 201fefcb75..4fb8819f32 100644 --- a/src/Microsoft.AspNet.WebSockets.Client/project.json +++ b/src/Microsoft.AspNet.WebSockets.Client/project.json @@ -1,5 +1,6 @@ { "version": "1.0.0-*", + "description": "Client for communicating over web sockets.", "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*" }, diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index 8094991757..a39062d40b 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -1,5 +1,6 @@ { "version": "1.0.0-*", + "description": "Managed web socket protocol parser.", "frameworks": { "net45": { }, "aspnetcore50": { diff --git a/src/Microsoft.AspNet.WebSockets.Server/project.json b/src/Microsoft.AspNet.WebSockets.Server/project.json index f729c453dd..6e272f6213 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/project.json +++ b/src/Microsoft.AspNet.WebSockets.Server/project.json @@ -1,5 +1,6 @@ { "version": "1.0.0-*", + "description": "ASP.NET 5 web socket middleware for use on top of opaque servers.", "dependencies": { "Microsoft.AspNet.Http": "1.0.0-*", "Microsoft.AspNet.HttpFeature": { "version": "1.0.0-*", "type": "build" }, From ca6aab28c1b062eaf68db97ae6e17873d97f8a71 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 6 Nov 2014 10:51:26 -0800 Subject: [PATCH 062/453] Updating to release NuGet.config --- NuGet.Config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index f41e9c631d..2d3b0cb857 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@  - + From c0d8e942875e20633987378bb46280d934e2b5a7 Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Wed, 12 Nov 2014 15:43:31 -0800 Subject: [PATCH 063/453] Update KProj to the latest format --- .../Microsoft.AspNet.WebSockets.Client.kproj | 26 +++++-------------- ...Microsoft.AspNet.WebSockets.Protocol.kproj | 24 +++++------------ .../Microsoft.AspNet.WebSockets.Server.kproj | 26 +++++-------------- .../AutobahnTestClient.kproj | 10 ++----- .../AutobahnTestServer.kproj | 9 ++----- ...rosoft.AspNet.WebSockets.Client.Test.kproj | 26 +++++-------------- ...soft.AspNet.WebSockets.Protocol.Test.kproj | 24 +++++------------ test/TestClient/TestClient.kproj | 24 +++++------------ 8 files changed, 40 insertions(+), 129 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.kproj b/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.kproj index 647fb58b72..e73513b9c0 100644 --- a/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.kproj +++ b/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.kproj @@ -1,28 +1,14 @@ - - + + - 12.0 + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - Debug - AnyCPU - 4a1c4875-ae21-4a78-979a-f0e4df5eb518 - Library - - - ConsoleDebugger - - - WebDebugger - - - - - 2.0 + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ - \ No newline at end of file + diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.kproj b/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.kproj index 9e7d70fe30..3c5b1c7569 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.kproj +++ b/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.kproj @@ -1,26 +1,14 @@ - - + + - 12.0 + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) e0c10dec-3339-4a47-85bc-3100c5d34ad4 - Library - - - ConsoleDebugger - - - WebDebugger - - - - - - - 2.0 + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ - \ No newline at end of file + diff --git a/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.kproj b/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.kproj index 3e07ae5b82..57cbc94927 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.kproj +++ b/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.kproj @@ -1,28 +1,14 @@ - - + + - 12.0 + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - Debug - AnyCPU - 78a097d0-c0a4-4aed-93e2-84a65392fb52 - Library - - - ConsoleDebugger - - - WebDebugger - - - - - 2.0 + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ - \ No newline at end of file + diff --git a/test/AutobahnTestClient/AutobahnTestClient.kproj b/test/AutobahnTestClient/AutobahnTestClient.kproj index 46b1cb9752..dbce852fbb 100644 --- a/test/AutobahnTestClient/AutobahnTestClient.kproj +++ b/test/AutobahnTestClient/AutobahnTestClient.kproj @@ -1,20 +1,14 @@ - + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - bc4d2bb1-05a8-4816-8bc1-3a664f09ee32 - AutobahnTestClient ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ - - - 2.0 - - \ No newline at end of file + diff --git a/test/AutobahnTestServer/AutobahnTestServer.kproj b/test/AutobahnTestServer/AutobahnTestServer.kproj index d8b0d38382..43e025b930 100644 --- a/test/AutobahnTestServer/AutobahnTestServer.kproj +++ b/test/AutobahnTestServer/AutobahnTestServer.kproj @@ -1,4 +1,4 @@ - + 14.0 @@ -7,13 +7,8 @@ c03c43fe-9201-48a6-b434-ad67ef627d67 - AutobahnTestServer ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ - - 2.0 - 60351 - - \ No newline at end of file + diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.kproj b/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.kproj index c107fe29b8..74056a4272 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.kproj +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.kproj @@ -1,28 +1,14 @@ - - + + - 12.0 + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - Debug - AnyCPU - 6604d154-817f-4bc5-be95-ff7e851179d9 - Library - - - ConsoleDebugger - - - WebDebugger - - - - - 2.0 + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ - \ No newline at end of file + diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.kproj b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.kproj index 0381c2116b..6b8f830c59 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.kproj +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.kproj @@ -1,26 +1,14 @@ - - + + - 12.0 + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 62a07a24-4d06-4dda-b6bf-02d0c9cb7d32 - Library - - - ConsoleDebugger - - - WebDebugger - - - - - - - 2.0 + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ - \ No newline at end of file + diff --git a/test/TestClient/TestClient.kproj b/test/TestClient/TestClient.kproj index 26ee2a677c..551c8a3bd9 100644 --- a/test/TestClient/TestClient.kproj +++ b/test/TestClient/TestClient.kproj @@ -1,26 +1,14 @@ - - + + - 12.0 + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 8c8eac01-dc49-4c5e-b348-e4e46fe675f9 - Library - - - ConsoleDebugger - - - WebDebugger - - - - - - - 2.0 + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ - \ No newline at end of file + From f505d5277118fa674fd156cb9669e08ad4c5637b Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Tue, 25 Nov 2014 11:10:52 -0800 Subject: [PATCH 064/453] Add schema version to kproj files --- .../Microsoft.AspNet.WebSockets.Client.kproj | 3 +++ .../Microsoft.AspNet.WebSockets.Protocol.kproj | 3 +++ .../Microsoft.AspNet.WebSockets.Server.kproj | 3 +++ test/AutobahnTestClient/AutobahnTestClient.kproj | 3 +++ test/AutobahnTestServer/AutobahnTestServer.kproj | 3 +++ .../Microsoft.AspNet.WebSockets.Client.Test.kproj | 3 +++ .../Microsoft.AspNet.WebSockets.Protocol.Test.kproj | 3 +++ test/TestClient/TestClient.kproj | 3 +++ 8 files changed, 24 insertions(+) diff --git a/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.kproj b/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.kproj index e73513b9c0..1fb418280e 100644 --- a/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.kproj +++ b/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.kproj @@ -10,5 +10,8 @@ ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ + + 2.0 + diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.kproj b/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.kproj index 3c5b1c7569..d2541e7ed0 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.kproj +++ b/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.kproj @@ -10,5 +10,8 @@ ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ + + 2.0 + diff --git a/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.kproj b/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.kproj index 57cbc94927..7af9d3405f 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.kproj +++ b/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.kproj @@ -10,5 +10,8 @@ ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ + + 2.0 + diff --git a/test/AutobahnTestClient/AutobahnTestClient.kproj b/test/AutobahnTestClient/AutobahnTestClient.kproj index dbce852fbb..59062e8f48 100644 --- a/test/AutobahnTestClient/AutobahnTestClient.kproj +++ b/test/AutobahnTestClient/AutobahnTestClient.kproj @@ -10,5 +10,8 @@ ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ + + 2.0 + diff --git a/test/AutobahnTestServer/AutobahnTestServer.kproj b/test/AutobahnTestServer/AutobahnTestServer.kproj index 43e025b930..884898e2d4 100644 --- a/test/AutobahnTestServer/AutobahnTestServer.kproj +++ b/test/AutobahnTestServer/AutobahnTestServer.kproj @@ -10,5 +10,8 @@ ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ + + 2.0 + diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.kproj b/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.kproj index 74056a4272..48e7651d3d 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.kproj +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.kproj @@ -10,5 +10,8 @@ ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ + + 2.0 + diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.kproj b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.kproj index 6b8f830c59..daf360064c 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.kproj +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.kproj @@ -10,5 +10,8 @@ ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ + + 2.0 + diff --git a/test/TestClient/TestClient.kproj b/test/TestClient/TestClient.kproj index 551c8a3bd9..83a8c2c2da 100644 --- a/test/TestClient/TestClient.kproj +++ b/test/TestClient/TestClient.kproj @@ -10,5 +10,8 @@ ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ + + 2.0 + From 42c2a0a56dd44ef298f8385f006b6f528b74d22e Mon Sep 17 00:00:00 2001 From: Suhas Joshi Date: Mon, 8 Dec 2014 15:16:19 -0800 Subject: [PATCH 065/453] Updating to release NuGet.config --- NuGet.Config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index f41e9c631d..2d3b0cb857 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@  - + From d74c4201f2f4e504ffc70b5554fac3e031d3e838 Mon Sep 17 00:00:00 2001 From: Suhas Joshi Date: Mon, 8 Dec 2014 15:25:11 -0800 Subject: [PATCH 066/453] Updating to dev NuGet.config --- NuGet.Config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index 2d3b0cb857..f41e9c631d 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@  - + From 2cdce758b1daa8cb1f86378a65cf295c0c033505 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Fri, 12 Dec 2014 14:54:01 -0800 Subject: [PATCH 067/453] Fix dependency versions. --- test/AutobahnTestServer/Project.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/AutobahnTestServer/Project.json b/test/AutobahnTestServer/Project.json index 50dfc16dc4..2376bab681 100644 --- a/test/AutobahnTestServer/Project.json +++ b/test/AutobahnTestServer/Project.json @@ -2,10 +2,10 @@ "webroot": "wwwroot", "exclude": "wwwroot/**/*", "dependencies": { - "Microsoft.AspNet.Server.IIS": "1.0.0-beta1-*", - "Microsoft.AspNet.Server.WebListener": "1.0.0-beta1-*", - "Microsoft.AspNet.WebSockets.Server": "1.0.0-beta1-*", - "Kestrel": "1.0.0-beta1-*" + "Microsoft.AspNet.Server.IIS": "1.0.0-*", + "Microsoft.AspNet.Server.WebListener": "1.0.0-*", + "Microsoft.AspNet.WebSockets.Server": "1.0.0-*", + "Kestrel": "1.0.0-*" }, "commands": { "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:12345", From 04fbb076b25ead17cedae9cbfd0490ee01476ada Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Mon, 15 Dec 2014 14:18:58 -0800 Subject: [PATCH 068/453] #22 - Update client tests to use Kestrel so they can run on Win7. --- .../KestrelWebSocketHelpers.cs | 64 ++ .../WebSocketClientTests.cs | 728 ++++++++---------- .../project.json | 4 +- 3 files changed, 370 insertions(+), 426 deletions(-) create mode 100644 test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs new file mode 100644 index 0000000000..5e54941ae4 --- /dev/null +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading.Tasks; +using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Hosting; +using Microsoft.AspNet.Http; +using Microsoft.Framework.ConfigurationModel; +using Microsoft.Framework.DependencyInjection; +using Microsoft.Framework.DependencyInjection.Fallback; +using Microsoft.Framework.Runtime.Infrastructure; + +namespace Microsoft.AspNet.WebSockets.Client.Test +{ + public class KestrelWebSocketHelpers + { + public static IDisposable CreateServer(Func app) + { + Action startup = builder => + { + builder.Use(async (ct, next) => + { + try + { + // Kestrel does not return proper error responses: + // https://github.com/aspnet/KestrelHttpServer/issues/43 + await next(); + } + catch (Exception ex) + { + if (ct.Response.HeadersSent) + { + throw; + } + + ct.Response.StatusCode = 500; + ct.Response.Headers.Clear(); + await ct.Response.WriteAsync(ex.ToString()); + } + }); + builder.UseWebSockets(); + builder.Run(c => app(c)); + }; + + var config = new Configuration(); + config.Add(new MemoryConfigurationSource()); + config.Set("server.urls", "http://localhost:54321"); + var services = HostingServices.Create(CallContextServiceLocator.Locator?.ServiceProvider, config) + .BuildServiceProvider(); + + var context = new HostingContext() + { + Services = services, + Configuration = config, + ServerName = "Kestrel", + ApplicationStartup = startup, + }; + + var engine = services.GetRequiredService(); + return engine.Start(context); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/WebSocketClientTests.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/WebSocketClientTests.cs index 23cf33bee0..2b5bd7d5de 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/WebSocketClientTests.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/WebSocketClientTests.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Net; using System.Net.WebSockets; using System.Text; using System.Threading; @@ -13,235 +12,180 @@ namespace Microsoft.AspNet.WebSockets.Client.Test { public class WebSocketClientTests { - private static string ClientAddress = "ws://localhost:8080/"; - private static string ServerAddress = "http://localhost:8080/"; + private static string ClientAddress = "ws://localhost:54321/"; [Fact] public async Task Connect_Success() { - using (HttpListener listener = new HttpListener()) + using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - listener.Prefixes.Add(ServerAddress); - listener.Start(); - Task serverAccept = listener.GetContextAsync(); - - WebSocketClient client = new WebSocketClient(); - Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - - HttpListenerContext serverContext = await serverAccept; - Assert.True(serverContext.Request.IsWebSocketRequest); - HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); - - WebSocket clientSocket = await clientConnect; - clientSocket.Dispose(); + Assert.True(context.IsWebSocketRequest); + var webSocket = await context.AcceptWebSocketAsync(); + })) + { + var client = new WebSocketClient(); + using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) + { + } } } [Fact] public async Task NegotiateSubProtocol_Success() { - using (HttpListener listener = new HttpListener()) + using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - listener.Prefixes.Add(ServerAddress); - listener.Start(); - Task serverAccept = listener.GetContextAsync(); - - WebSocketClient client = new WebSocketClient(); + Assert.True(context.IsWebSocketRequest); + Assert.Equal("alpha, bravo, charlie", context.Request.Headers["Sec-WebSocket-Protocol"]); + var webSocket = await context.AcceptWebSocketAsync("Bravo"); + })) + { + var client = new WebSocketClient(); client.SubProtocols.Add("alpha"); client.SubProtocols.Add("bravo"); client.SubProtocols.Add("charlie"); - Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - - HttpListenerContext serverContext = await serverAccept; - Assert.True(serverContext.Request.IsWebSocketRequest); - Assert.Equal("alpha, bravo, charlie", serverContext.Request.Headers["Sec-WebSocket-Protocol"]); - HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync("Bravo"); - - WebSocket clientSocket = await clientConnect; - Assert.Equal("Bravo", clientSocket.SubProtocol); - clientSocket.Dispose(); + using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) + { + Assert.Equal("Bravo", clientSocket.SubProtocol); + } } } [Fact] public async Task SendEmptyData_Success() { - using (HttpListener listener = new HttpListener()) + using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - listener.Prefixes.Add(ServerAddress); - listener.Start(); - Task serverAccept = listener.GetContextAsync(); + Assert.True(context.IsWebSocketRequest); + var webSocket = await context.AcceptWebSocketAsync(); - WebSocketClient client = new WebSocketClient(); - Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - - HttpListenerContext serverContext = await serverAccept; - Assert.True(serverContext.Request.IsWebSocketRequest); - HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); - - WebSocket clientSocket = await clientConnect; - - byte[] orriginalData = new byte[0]; - await clientSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - - byte[] serverBuffer = new byte[orriginalData.Length]; - WebSocketReceiveResult result = await serverWebSocketContext.WebSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + var serverBuffer = new byte[0]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); Assert.True(result.EndOfMessage); - Assert.Equal(orriginalData.Length, result.Count); + Assert.Equal(0, result.Count); Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - Assert.Equal(orriginalData, serverBuffer); - - clientSocket.Dispose(); + })) + { + var client = new WebSocketClient(); + using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) + { + var orriginalData = new byte[0]; + await clientSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + } } } [Fact] public async Task SendShortData_Success() { - using (HttpListener listener = new HttpListener()) + var orriginalData = Encoding.UTF8.GetBytes("Hello World"); + using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - listener.Prefixes.Add(ServerAddress); - listener.Start(); - Task serverAccept = listener.GetContextAsync(); + Assert.True(context.IsWebSocketRequest); + var webSocket = await context.AcceptWebSocketAsync(); - WebSocketClient client = new WebSocketClient(); - Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - - HttpListenerContext serverContext = await serverAccept; - Assert.True(serverContext.Request.IsWebSocketRequest); - HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); - - WebSocket clientSocket = await clientConnect; - - byte[] orriginalData = Encoding.UTF8.GetBytes("Hello World"); - await clientSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - - byte[] serverBuffer = new byte[orriginalData.Length]; - WebSocketReceiveResult result = await serverWebSocketContext.WebSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + var serverBuffer = new byte[orriginalData.Length]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); Assert.True(result.EndOfMessage); Assert.Equal(orriginalData.Length, result.Count); Assert.Equal(WebSocketMessageType.Binary, result.MessageType); Assert.Equal(orriginalData, serverBuffer); - - clientSocket.Dispose(); + })) + { + var client = new WebSocketClient(); + using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) + { + await clientSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + } } } [Fact] public async Task SendMediumData_Success() { - using (HttpListener listener = new HttpListener()) + var orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); + using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - listener.Prefixes.Add(ServerAddress); - listener.Start(); - Task serverAccept = listener.GetContextAsync(); + Assert.True(context.IsWebSocketRequest); + var webSocket = await context.AcceptWebSocketAsync(); - WebSocketClient client = new WebSocketClient(); - Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - - HttpListenerContext serverContext = await serverAccept; - Assert.True(serverContext.Request.IsWebSocketRequest); - HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); - - WebSocket clientSocket = await clientConnect; - - byte[] orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); - await clientSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Text, true, CancellationToken.None); - - byte[] serverBuffer = new byte[orriginalData.Length]; - WebSocketReceiveResult result = await serverWebSocketContext.WebSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + var serverBuffer = new byte[orriginalData.Length]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); Assert.True(result.EndOfMessage); Assert.Equal(orriginalData.Length, result.Count); - Assert.Equal(WebSocketMessageType.Text, result.MessageType); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); Assert.Equal(orriginalData, serverBuffer); - - clientSocket.Dispose(); + })) + { + var client = new WebSocketClient(); + using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) + { + await clientSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + } } } [Fact] public async Task SendLongData_Success() { - using (HttpListener listener = new HttpListener()) + var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); + using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - listener.Prefixes.Add(ServerAddress); - listener.Start(); - Task serverAccept = listener.GetContextAsync(); + Assert.True(context.IsWebSocketRequest); + var webSocket = await context.AcceptWebSocketAsync(); - WebSocketClient client = new WebSocketClient(); - Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - - HttpListenerContext serverContext = await serverAccept; - Assert.True(serverContext.Request.IsWebSocketRequest); - HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null, 0xFFFF, TimeSpan.FromMinutes(100)); - - WebSocket clientSocket = await clientConnect; - - byte[] orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); - await clientSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Text, true, CancellationToken.None); - - byte[] serverBuffer = new byte[orriginalData.Length]; - WebSocketReceiveResult result = await serverWebSocketContext.WebSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + var serverBuffer = new byte[orriginalData.Length]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); int intermediateCount = result.Count; Assert.False(result.EndOfMessage); Assert.Equal(WebSocketMessageType.Text, result.MessageType); - result = await serverWebSocketContext.WebSocket.ReceiveAsync(new ArraySegment(serverBuffer, intermediateCount, orriginalData.Length - intermediateCount), CancellationToken.None); + result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer, intermediateCount, orriginalData.Length - intermediateCount), CancellationToken.None); intermediateCount += result.Count; Assert.False(result.EndOfMessage); Assert.Equal(WebSocketMessageType.Text, result.MessageType); - result = await serverWebSocketContext.WebSocket.ReceiveAsync(new ArraySegment(serverBuffer, intermediateCount, orriginalData.Length - intermediateCount), CancellationToken.None); + result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer, intermediateCount, orriginalData.Length - intermediateCount), CancellationToken.None); intermediateCount += result.Count; Assert.True(result.EndOfMessage); Assert.Equal(orriginalData.Length, intermediateCount); Assert.Equal(WebSocketMessageType.Text, result.MessageType); Assert.Equal(orriginalData, serverBuffer); - - clientSocket.Dispose(); + })) + { + var client = new WebSocketClient(); + using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) + { + await clientSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + } } } [Fact] public async Task SendFragmentedData_Success() { - using (HttpListener listener = new HttpListener()) + var orriginalData = Encoding.UTF8.GetBytes("Hello World"); + using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - listener.Prefixes.Add(ServerAddress); - listener.Start(); - Task serverAccept = listener.GetContextAsync(); + Assert.True(context.IsWebSocketRequest); + var webSocket = await context.AcceptWebSocketAsync(); - WebSocketClient client = new WebSocketClient(); - Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - - HttpListenerContext serverContext = await serverAccept; - Assert.True(serverContext.Request.IsWebSocketRequest); - HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); - WebSocket serverSocket = serverWebSocketContext.WebSocket; - - WebSocket clientSocket = await clientConnect; - - byte[] orriginalData = Encoding.UTF8.GetBytes("Hello World"); - await clientSocket.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); - await clientSocket.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); - await clientSocket.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); - - byte[] serverBuffer = new byte[orriginalData.Length]; - WebSocketReceiveResult result = await serverSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + var serverBuffer = new byte[orriginalData.Length]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); Assert.False(result.EndOfMessage); Assert.Equal(2, result.Count); int totalReceived = result.Count; Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - result = await serverSocket.ReceiveAsync( + result = await webSocket.ReceiveAsync( new ArraySegment(serverBuffer, totalReceived, serverBuffer.Length - totalReceived), CancellationToken.None); Assert.False(result.EndOfMessage); Assert.Equal(2, result.Count); totalReceived += result.Count; Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - result = await serverSocket.ReceiveAsync( + result = await webSocket.ReceiveAsync( new ArraySegment(serverBuffer, totalReceived, serverBuffer.Length - totalReceived), CancellationToken.None); Assert.True(result.EndOfMessage); Assert.Equal(7, result.Count); @@ -249,414 +193,348 @@ namespace Microsoft.AspNet.WebSockets.Client.Test Assert.Equal(WebSocketMessageType.Binary, result.MessageType); Assert.Equal(orriginalData, serverBuffer); - - clientSocket.Dispose(); + })) + { + var client = new WebSocketClient(); + using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) + { + await clientSocket.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); + await clientSocket.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); + await clientSocket.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); + } } } [Fact] public async Task ReceiveEmptyData_Success() { - using (HttpListener listener = new HttpListener()) + var orriginalData = Encoding.UTF8.GetBytes("Hello World"); + using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - listener.Prefixes.Add(ServerAddress); - listener.Start(); - Task serverAccept = listener.GetContextAsync(); + Assert.True(context.IsWebSocketRequest); + var webSocket = await context.AcceptWebSocketAsync(); - WebSocketClient client = new WebSocketClient(); - Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - - HttpListenerContext serverContext = await serverAccept; - Assert.True(serverContext.Request.IsWebSocketRequest); - HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); - - WebSocket clientSocket = await clientConnect; - - byte[] orriginalData = Encoding.UTF8.GetBytes("Hello World"); - await serverWebSocketContext.WebSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - - byte[] clientBuffer = new byte[0]; - WebSocketReceiveResult result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); - Assert.False(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - - clientSocket.Dispose(); + await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + })) + { + var client = new WebSocketClient(); + using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) + { + var clientBuffer = new byte[0]; + var result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.False(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + } } } [Fact] public async Task ReceiveShortData_Success() { - using (HttpListener listener = new HttpListener()) + var orriginalData = Encoding.UTF8.GetBytes("Hello World"); + using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - listener.Prefixes.Add(ServerAddress); - listener.Start(); - Task serverAccept = listener.GetContextAsync(); + Assert.True(context.IsWebSocketRequest); + var webSocket = await context.AcceptWebSocketAsync(); - WebSocketClient client = new WebSocketClient(); - Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - - HttpListenerContext serverContext = await serverAccept; - Assert.True(serverContext.Request.IsWebSocketRequest); - HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); - - WebSocket clientSocket = await clientConnect; - - byte[] orriginalData = Encoding.UTF8.GetBytes("Hello World"); - await serverWebSocketContext.WebSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - - byte[] clientBuffer = new byte[orriginalData.Length]; - WebSocketReceiveResult result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(orriginalData.Length, result.Count); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - Assert.Equal(orriginalData, clientBuffer); - - clientSocket.Dispose(); + await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + })) + { + var client = new WebSocketClient(); + using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) + { + var clientBuffer = new byte[orriginalData.Length]; + var result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, clientBuffer); + } } } [Fact] public async Task ReceiveMediumData_Success() { - using (HttpListener listener = new HttpListener()) + var orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); + using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - listener.Prefixes.Add(ServerAddress); - listener.Start(); - Task serverAccept = listener.GetContextAsync(); + Assert.True(context.IsWebSocketRequest); + var webSocket = await context.AcceptWebSocketAsync(); - WebSocketClient client = new WebSocketClient(); - Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - - HttpListenerContext serverContext = await serverAccept; - Assert.True(serverContext.Request.IsWebSocketRequest); - HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); - - WebSocket clientSocket = await clientConnect; - - byte[] orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); - await serverWebSocketContext.WebSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - - byte[] clientBuffer = new byte[orriginalData.Length]; - WebSocketReceiveResult result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(orriginalData.Length, result.Count); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - Assert.Equal(orriginalData, clientBuffer); - - clientSocket.Dispose(); + await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + })) + { + var client = new WebSocketClient(); + using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) + { + var clientBuffer = new byte[orriginalData.Length]; + var result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, clientBuffer); + } } } [Fact] public async Task ReceiveLongDataInSmallBuffer_Success() { - using (HttpListener listener = new HttpListener()) + var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); + using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - listener.Prefixes.Add(ServerAddress); - listener.Start(); - Task serverAccept = listener.GetContextAsync(); + Assert.True(context.IsWebSocketRequest); + var webSocket = await context.AcceptWebSocketAsync(); - WebSocketClient client = new WebSocketClient(); - Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - - HttpListenerContext serverContext = await serverAccept; - Assert.True(serverContext.Request.IsWebSocketRequest); - HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); - - WebSocket clientSocket = await clientConnect; - - byte[] orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); - await serverWebSocketContext.WebSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - - byte[] clientBuffer = new byte[orriginalData.Length]; - WebSocketReceiveResult result; - int receivedCount = 0; - do + await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + })) + { + var client = new WebSocketClient(); + using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) { - result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer, receivedCount, clientBuffer.Length - receivedCount), CancellationToken.None); - receivedCount += result.Count; + var clientBuffer = new byte[orriginalData.Length]; + WebSocketReceiveResult result; + int receivedCount = 0; + do + { + result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer, receivedCount, clientBuffer.Length - receivedCount), CancellationToken.None); + receivedCount += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + } + while (!result.EndOfMessage); + + Assert.Equal(orriginalData.Length, receivedCount); Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, clientBuffer); } - while (!result.EndOfMessage); - - Assert.Equal(orriginalData.Length, receivedCount); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - Assert.Equal(orriginalData, clientBuffer); - - clientSocket.Dispose(); } } [Fact] public async Task ReceiveLongDataInLargeBuffer_Success() { - using (HttpListener listener = new HttpListener()) + var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); + using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - listener.Prefixes.Add(ServerAddress); - listener.Start(); - Task serverAccept = listener.GetContextAsync(); + Assert.True(context.IsWebSocketRequest); + var webSocket = await context.AcceptWebSocketAsync(); - WebSocketClient client = new WebSocketClient() { ReceiveBufferSize = 0xFFFFFF }; - Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - - HttpListenerContext serverContext = await serverAccept; - Assert.True(serverContext.Request.IsWebSocketRequest); - HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); - - WebSocket clientSocket = await clientConnect; - - byte[] orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); - await serverWebSocketContext.WebSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - - byte[] clientBuffer = new byte[orriginalData.Length]; - WebSocketReceiveResult result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(orriginalData.Length, result.Count); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - Assert.Equal(orriginalData, clientBuffer); - - clientSocket.Dispose(); + await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + })) + { + var client = new WebSocketClient() { ReceiveBufferSize = 0xFFFFFF }; + using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) + { + var clientBuffer = new byte[orriginalData.Length]; + var result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, clientBuffer); + } } } [Fact] public async Task ReceiveFragmentedData_Success() { - using (HttpListener listener = new HttpListener()) + var orriginalData = Encoding.UTF8.GetBytes("Hello World"); + using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - listener.Prefixes.Add(ServerAddress); - listener.Start(); - Task serverAccept = listener.GetContextAsync(); + Assert.True(context.IsWebSocketRequest); + var webSocket = await context.AcceptWebSocketAsync(); - WebSocketClient client = new WebSocketClient(); - Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await webSocket.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); + await webSocket.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); + await webSocket.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); + })) + { + var client = new WebSocketClient(); + using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) + { + var clientBuffer = new byte[orriginalData.Length]; + var result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.False(result.EndOfMessage); + Assert.Equal(2, result.Count); + int totalReceived = result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - HttpListenerContext serverContext = await serverAccept; - Assert.True(serverContext.Request.IsWebSocketRequest); - HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); - WebSocket serverSocket = serverWebSocketContext.WebSocket; + result = await clientSocket.ReceiveAsync( + new ArraySegment(clientBuffer, totalReceived, clientBuffer.Length - totalReceived), CancellationToken.None); + Assert.False(result.EndOfMessage); + Assert.Equal(2, result.Count); + totalReceived += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - WebSocket clientSocket = await clientConnect; + result = await clientSocket.ReceiveAsync( + new ArraySegment(clientBuffer, totalReceived, clientBuffer.Length - totalReceived), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(7, result.Count); + totalReceived += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - byte[] orriginalData = Encoding.UTF8.GetBytes("Hello World"); - await serverSocket.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); - await serverSocket.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); - await serverSocket.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); - - byte[] serverBuffer = new byte[orriginalData.Length]; - WebSocketReceiveResult result = await clientSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.False(result.EndOfMessage); - Assert.Equal(2, result.Count); - int totalReceived = result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - - result = await clientSocket.ReceiveAsync( - new ArraySegment(serverBuffer, totalReceived, serverBuffer.Length - totalReceived), CancellationToken.None); - Assert.False(result.EndOfMessage); - Assert.Equal(2, result.Count); - totalReceived += result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - - result = await clientSocket.ReceiveAsync( - new ArraySegment(serverBuffer, totalReceived, serverBuffer.Length - totalReceived), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(7, result.Count); - totalReceived += result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - - Assert.Equal(orriginalData, serverBuffer); - - clientSocket.Dispose(); + Assert.Equal(orriginalData, clientBuffer); + } } } [Fact] public async Task SendClose_Success() { - using (HttpListener listener = new HttpListener()) + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - listener.Prefixes.Add(ServerAddress); - listener.Start(); - Task serverAccept = listener.GetContextAsync(); + Assert.True(context.IsWebSocketRequest); + var webSocket = await context.AcceptWebSocketAsync(); - WebSocketClient client = new WebSocketClient(); - Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - - HttpListenerContext serverContext = await serverAccept; - Assert.True(serverContext.Request.IsWebSocketRequest); - HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); - - WebSocket clientSocket = await clientConnect; - - string closeDescription = "Test Closed"; - await clientSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - - byte[] serverBuffer = new byte[1024]; - WebSocketReceiveResult result = await serverWebSocketContext.WebSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + var serverBuffer = new byte[1024]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); Assert.True(result.EndOfMessage); Assert.Equal(0, result.Count); Assert.Equal(WebSocketMessageType.Close, result.MessageType); Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); Assert.Equal(closeDescription, result.CloseStatusDescription); + })) + { + var client = new WebSocketClient(); + using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) + { + await clientSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - Assert.Equal(WebSocketState.CloseSent, clientSocket.State); - - clientSocket.Dispose(); + Assert.Equal(WebSocketState.CloseSent, clientSocket.State); + } } } [Fact] public async Task ReceiveClose_Success() { - using (HttpListener listener = new HttpListener()) + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - listener.Prefixes.Add(ServerAddress); - listener.Start(); - Task serverAccept = listener.GetContextAsync(); + Assert.True(context.IsWebSocketRequest); + var webSocket = await context.AcceptWebSocketAsync(); - WebSocketClient client = new WebSocketClient(); - Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + })) + { + var client = new WebSocketClient(); + using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) + { + var clientBuffer = new byte[1024]; + var result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); - HttpListenerContext serverContext = await serverAccept; - Assert.True(serverContext.Request.IsWebSocketRequest); - HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); - - WebSocket clientSocket = await clientConnect; - - string closeDescription = "Test Closed"; - await serverWebSocketContext.WebSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - - byte[] serverBuffer = new byte[1024]; - WebSocketReceiveResult result = await clientSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Close, result.MessageType); - Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); - Assert.Equal(closeDescription, result.CloseStatusDescription); - - Assert.Equal(WebSocketState.CloseReceived, clientSocket.State); - - clientSocket.Dispose(); + Assert.Equal(WebSocketState.CloseReceived, clientSocket.State); + } } } [Fact] public async Task CloseFromOpen_Success() { - using (HttpListener listener = new HttpListener()) + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - listener.Prefixes.Add(ServerAddress); - listener.Start(); - Task serverAccept = listener.GetContextAsync(); + Assert.True(context.IsWebSocketRequest); + var webSocket = await context.AcceptWebSocketAsync(); - WebSocketClient client = new WebSocketClient(); - Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - - HttpListenerContext serverContext = await serverAccept; - Assert.True(serverContext.Request.IsWebSocketRequest); - HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); - - WebSocket clientSocket = await clientConnect; - - string closeDescription = "Test Closed"; - Task closeTask = clientSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - - byte[] serverBuffer = new byte[1024]; - WebSocketReceiveResult result = await serverWebSocketContext.WebSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + var serverBuffer = new byte[1024]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); Assert.True(result.EndOfMessage); Assert.Equal(0, result.Count); Assert.Equal(WebSocketMessageType.Close, result.MessageType); Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); Assert.Equal(closeDescription, result.CloseStatusDescription); - await serverWebSocketContext.WebSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + })) + { + var client = new WebSocketClient(); + using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) + { + await clientSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - await closeTask; - - Assert.Equal(WebSocketState.Closed, clientSocket.State); - - clientSocket.Dispose(); + Assert.Equal(WebSocketState.Closed, clientSocket.State); + } } } [Fact] public async Task CloseFromCloseSent_Success() { - using (HttpListener listener = new HttpListener()) + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - listener.Prefixes.Add(ServerAddress); - listener.Start(); - Task serverAccept = listener.GetContextAsync(); + Assert.True(context.IsWebSocketRequest); + var webSocket = await context.AcceptWebSocketAsync(); - WebSocketClient client = new WebSocketClient(); - Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - - HttpListenerContext serverContext = await serverAccept; - Assert.True(serverContext.Request.IsWebSocketRequest); - HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); - - WebSocket clientSocket = await clientConnect; - - string closeDescription = "Test Closed"; - await clientSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - Assert.Equal(WebSocketState.CloseSent, clientSocket.State); - - byte[] serverBuffer = new byte[1024]; - WebSocketReceiveResult result = await serverWebSocketContext.WebSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + var serverBuffer = new byte[1024]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); Assert.True(result.EndOfMessage); Assert.Equal(0, result.Count); Assert.Equal(WebSocketMessageType.Close, result.MessageType); Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); Assert.Equal(closeDescription, result.CloseStatusDescription); - await serverWebSocketContext.WebSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + })) + { + var client = new WebSocketClient(); + using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) + { + await clientSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + Assert.Equal(WebSocketState.CloseSent, clientSocket.State); - await clientSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - - Assert.Equal(WebSocketState.Closed, clientSocket.State); - - clientSocket.Dispose(); + await clientSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + Assert.Equal(WebSocketState.Closed, clientSocket.State); + } } } [Fact] public async Task CloseFromCloseReceived_Success() { - using (HttpListener listener = new HttpListener()) + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - listener.Prefixes.Add(ServerAddress); - listener.Start(); - Task serverAccept = listener.GetContextAsync(); + Assert.True(context.IsWebSocketRequest); + var webSocket = await context.AcceptWebSocketAsync(); - WebSocketClient client = new WebSocketClient(); - Task clientConnect = client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - HttpListenerContext serverContext = await serverAccept; - Assert.True(serverContext.Request.IsWebSocketRequest); - HttpListenerWebSocketContext serverWebSocketContext = await serverContext.AcceptWebSocketAsync(null); - - WebSocket clientSocket = await clientConnect; - - string closeDescription = "Test Closed"; - await serverWebSocketContext.WebSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - - byte[] serverBuffer = new byte[1024]; - WebSocketReceiveResult result = await clientSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + var serverBuffer = new byte[1024]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); Assert.True(result.EndOfMessage); Assert.Equal(0, result.Count); Assert.Equal(WebSocketMessageType.Close, result.MessageType); Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); Assert.Equal(closeDescription, result.CloseStatusDescription); + })) + { + var client = new WebSocketClient(); + using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) + { + var clientBuffer = new byte[1024]; + var result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); - Assert.Equal(WebSocketState.CloseReceived, clientSocket.State); + Assert.Equal(WebSocketState.CloseReceived, clientSocket.State); - await clientSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + await clientSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); - Assert.Equal(WebSocketState.Closed, clientSocket.State); - - clientSocket.Dispose(); + Assert.Equal(WebSocketState.Closed, clientSocket.State); + } } } } diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json index 2513189d82..8dc76e0d68 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json @@ -2,7 +2,9 @@ "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", "Microsoft.AspNet.WebSockets.Client": "1.0.0-*", - "Xunit.KRunner": "1.0.0-*" + "Microsoft.AspNet.WebSockets.Server": "1.0.0-*", + "Xunit.KRunner": "1.0.0-*", + "Kestrel": "1.0.0-*" }, "frameworks": { "aspnet50": { } From 017549aa467639377ef4a737af9509db8a15d079 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 15 Dec 2014 15:10:39 -0800 Subject: [PATCH 069/453] Reacting to System.Threading version changes --- src/Microsoft.AspNet.WebSockets.Protocol/project.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index 9c55c3c266..793b713670 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -14,9 +14,9 @@ "System.Runtime.Extensions": "4.0.10-beta-*", "System.Security.Cryptography.Encryption": "4.0.0-beta-*", "System.Security.Cryptography.Hashing.Algorithms": "4.0.0-beta-*", - "System.Threading": "4.0.0-beta-*", - "System.Threading.Tasks": "4.0.10-beta-*", "System.Text.Encoding.Extensions": "4.0.10-beta-*", + "System.Threading": "4.0.10-beta-*", + "System.Threading.Tasks": "4.0.10-beta-*", "System.Threading.Timer": "4.0.0-beta-*" } } From 372cedda69f093c69028d262c4cdaf4911646e43 Mon Sep 17 00:00:00 2001 From: Brennan Date: Mon, 15 Dec 2014 14:01:50 -0800 Subject: [PATCH 070/453] Update tests to use official xunit --- test/Microsoft.AspNet.WebSockets.Client.Test/project.json | 4 ++-- test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json index 8dc76e0d68..256a7857af 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json @@ -3,13 +3,13 @@ "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", "Microsoft.AspNet.WebSockets.Client": "1.0.0-*", "Microsoft.AspNet.WebSockets.Server": "1.0.0-*", - "Xunit.KRunner": "1.0.0-*", "Kestrel": "1.0.0-*" + "xunit.runner.kre": "1.0.0-*" }, "frameworks": { "aspnet50": { } }, "commands": { - "test": "Xunit.KRunner" + "test": "xunit.runner.kre" } } diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json index e33d7f4d0d..d774c720d6 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json @@ -1,12 +1,12 @@ { "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", - "Xunit.KRunner": "1.0.0-*" + "xunit.runner.kre": "1.0.0-*" }, "frameworks": { "aspnet50": { } }, "commands": { - "test": "Xunit.KRunner" + "test": "xunit.runner.kre" } } From 32ff0e14a1df9df01c4961b4265283e9a7ce30bf Mon Sep 17 00:00:00 2001 From: Brennan Date: Tue, 16 Dec 2014 10:24:47 -0800 Subject: [PATCH 071/453] Missed a comma, whoops --- test/Microsoft.AspNet.WebSockets.Client.Test/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json index 256a7857af..ad24bf8df0 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json @@ -3,7 +3,7 @@ "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", "Microsoft.AspNet.WebSockets.Client": "1.0.0-*", "Microsoft.AspNet.WebSockets.Server": "1.0.0-*", - "Kestrel": "1.0.0-*" + "Kestrel": "1.0.0-*", "xunit.runner.kre": "1.0.0-*" }, "frameworks": { From 48e8f92aab273c9a14e83d016946671c85a537fc Mon Sep 17 00:00:00 2001 From: Stephen Halter Date: Sun, 18 Jan 2015 21:01:48 -0800 Subject: [PATCH 072/453] Handle HttpFeature rename --- .../WebSocketAcceptContext.cs | 2 +- src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs | 2 +- src/Microsoft.AspNet.WebSockets.Server/project.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketAcceptContext.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketAcceptContext.cs index 0762d79eff..c8f09dd34f 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/WebSocketAcceptContext.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketAcceptContext.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.HttpFeature; +using Microsoft.AspNet.Http.Interfaces; namespace Microsoft.AspNet.WebSockets.Server { diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs index 51e735674a..30ac76d09f 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs @@ -8,7 +8,7 @@ using System.Net.WebSockets; using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; -using Microsoft.AspNet.HttpFeature; +using Microsoft.AspNet.Http.Interfaces; using Microsoft.AspNet.WebSockets.Protocol; namespace Microsoft.AspNet.WebSockets.Server diff --git a/src/Microsoft.AspNet.WebSockets.Server/project.json b/src/Microsoft.AspNet.WebSockets.Server/project.json index 6e272f6213..24227af55b 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/project.json +++ b/src/Microsoft.AspNet.WebSockets.Server/project.json @@ -3,7 +3,7 @@ "description": "ASP.NET 5 web socket middleware for use on top of opaque servers.", "dependencies": { "Microsoft.AspNet.Http": "1.0.0-*", - "Microsoft.AspNet.HttpFeature": { "version": "1.0.0-*", "type": "build" }, + "Microsoft.AspNet.Http.Interfaces": { "version": "1.0.0-*", "type": "build" }, "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*" }, "frameworks": { From e041a3b13350079f5b2d9cfcb4b0a917e55f6d7b Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 20 Jan 2015 01:37:17 -0800 Subject: [PATCH 073/453] Updating build.cmd and build.sh to use dotnetsdk --- build.cmd | 6 +++--- build.sh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.cmd b/build.cmd index 86ca5bbbf1..c8041fdd9d 100644 --- a/build.cmd +++ b/build.cmd @@ -20,9 +20,9 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion IF "%SKIP_KRE_INSTALL%"=="1" goto run -CALL packages\KoreBuild\build\kvm upgrade -runtime CLR -x86 -CALL packages\KoreBuild\build\kvm install default -runtime CoreCLR -x86 +CALL packages\KoreBuild\build\dotnetsdk upgrade -runtime CLR -x86 +CALL packages\KoreBuild\build\dotnetsdk install default -runtime CoreCLR -x86 :run -CALL packages\KoreBuild\build\kvm use default -runtime CLR -x86 +CALL packages\KoreBuild\build\dotnetsdk use default -runtime CLR -x86 packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* diff --git a/build.sh b/build.sh index c7873ef58e..350d7e389a 100644 --- a/build.sh +++ b/build.sh @@ -28,11 +28,11 @@ if test ! -d packages/KoreBuild; then fi if ! type k > /dev/null 2>&1; then - source packages/KoreBuild/build/kvm.sh + source packages/KoreBuild/build/dotnetsdk.sh fi if ! type k > /dev/null 2>&1; then - kvm upgrade + dotnetsdk upgrade fi mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" From 8a28fbb6b574644c6a42e0af41618fba18f16a5c Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Tue, 20 Jan 2015 18:42:26 -0800 Subject: [PATCH 074/453] Rename SKIP_KRE_INSTALL to SKIP_DOTNET_INSTALL --- build.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cmd b/build.cmd index c8041fdd9d..220a1ff561 100644 --- a/build.cmd +++ b/build.cmd @@ -19,7 +19,7 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion -IF "%SKIP_KRE_INSTALL%"=="1" goto run +IF "%SKIP_DOTNET_INSTALL%"=="1" goto run CALL packages\KoreBuild\build\dotnetsdk upgrade -runtime CLR -x86 CALL packages\KoreBuild\build\dotnetsdk install default -runtime CoreCLR -x86 From 27cde37107a838f5604cf7696abaacda9551082c Mon Sep 17 00:00:00 2001 From: Aligned Date: Wed, 21 Jan 2015 11:52:16 -0600 Subject: [PATCH 075/453] Change ASP.NET vNext to ASP.Net 5 in the Readme.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2a9add8342..edaa040954 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ WebSockets Contains a managed implementation of the WebSocket protocol, along with client and server integration components. -This project is part of ASP.NET vNext. You can find samples, documentation and getting started instructions for ASP.NET vNext at the [Home](https://github.com/aspnet/home) repo. +This project is part of ASP.NET 5. You can find samples, documentation and getting started instructions for ASP.NET 5 at the [Home](https://github.com/aspnet/home) repo. From f945f03714ffce015e526f27cf7b6be4e2672904 Mon Sep 17 00:00:00 2001 From: Suhas Joshi Date: Wed, 21 Jan 2015 15:55:58 -0800 Subject: [PATCH 076/453] Updating to release NuGet.config --- NuGet.Config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index f41e9c631d..2d3b0cb857 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@  - + From eb644da0d86143938883bb6a3096e537318b74fe Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Wed, 28 Jan 2015 18:50:38 -0800 Subject: [PATCH 077/453] Update build.cmd and build.sh to use kvm --- build.cmd | 6 +++--- build.sh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.cmd b/build.cmd index 220a1ff561..5885abe388 100644 --- a/build.cmd +++ b/build.cmd @@ -20,9 +20,9 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion IF "%SKIP_DOTNET_INSTALL%"=="1" goto run -CALL packages\KoreBuild\build\dotnetsdk upgrade -runtime CLR -x86 -CALL packages\KoreBuild\build\dotnetsdk install default -runtime CoreCLR -x86 +CALL packages\KoreBuild\build\kvm upgrade -runtime CLR -x86 +CALL packages\KoreBuild\build\kvm install default -runtime CoreCLR -x86 :run -CALL packages\KoreBuild\build\dotnetsdk use default -runtime CLR -x86 +CALL packages\KoreBuild\build\kvm use default -runtime CLR -x86 packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* diff --git a/build.sh b/build.sh index 350d7e389a..c7873ef58e 100644 --- a/build.sh +++ b/build.sh @@ -28,11 +28,11 @@ if test ! -d packages/KoreBuild; then fi if ! type k > /dev/null 2>&1; then - source packages/KoreBuild/build/dotnetsdk.sh + source packages/KoreBuild/build/kvm.sh fi if ! type k > /dev/null 2>&1; then - dotnetsdk upgrade + kvm upgrade fi mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" From 334fa34e0cd409698b9fdd56bbf1cef1dd3a83dc Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Wed, 28 Jan 2015 18:50:50 -0800 Subject: [PATCH 078/453] Change SKIP_DOTNET_INSTALL to SKIP_KRE_INSTALL --- build.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cmd b/build.cmd index 5885abe388..86ca5bbbf1 100644 --- a/build.cmd +++ b/build.cmd @@ -19,7 +19,7 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion -IF "%SKIP_DOTNET_INSTALL%"=="1" goto run +IF "%SKIP_KRE_INSTALL%"=="1" goto run CALL packages\KoreBuild\build\kvm upgrade -runtime CLR -x86 CALL packages\KoreBuild\build\kvm install default -runtime CoreCLR -x86 From 42aedab4ec4655e7e37608aa5ff116ed89199d99 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Mon, 16 Feb 2015 14:17:41 -0800 Subject: [PATCH 079/453] Add project.lock.json to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e3c5c21725..c1d75776c9 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ nuget.exe *.*sdf *.ipch *.sln.ide +project.lock.json From e1301925c0ecfe9e41045ab5a1569716aa6383db Mon Sep 17 00:00:00 2001 From: Praburaj Date: Thu, 26 Feb 2015 12:26:50 -0800 Subject: [PATCH 080/453] Reacting to hosting api changes --- .../KestrelWebSocketHelpers.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index 5e54941ae4..203e9d2722 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -48,12 +48,13 @@ namespace Microsoft.AspNet.WebSockets.Client.Test config.Set("server.urls", "http://localhost:54321"); var services = HostingServices.Create(CallContextServiceLocator.Locator?.ServiceProvider, config) .BuildServiceProvider(); + var applicationLifetime = services.GetRequiredService(); var context = new HostingContext() { - Services = services, + ApplicationLifetime = applicationLifetime, Configuration = config, - ServerName = "Kestrel", + ServerFactoryLocation = "Kestrel", ApplicationStartup = startup, }; From a2e1110b7a5f792816570a893d9eb1e435709b31 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 4 Mar 2015 18:44:34 -0800 Subject: [PATCH 081/453] React to DI changes --- .../KestrelWebSocketHelpers.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index 203e9d2722..f0cc35fd72 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -8,7 +8,6 @@ using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; using Microsoft.Framework.ConfigurationModel; using Microsoft.Framework.DependencyInjection; -using Microsoft.Framework.DependencyInjection.Fallback; using Microsoft.Framework.Runtime.Infrastructure; namespace Microsoft.AspNet.WebSockets.Client.Test From 9bcc8633219c3a77b0c6a38bf951b82724fc094b Mon Sep 17 00:00:00 2001 From: Praburaj Date: Thu, 5 Mar 2015 16:36:21 -0800 Subject: [PATCH 082/453] Rename Microsoft.AspNet.Http.Interfaces => Microsoft.AspNet.Http --- .../WebSocketAcceptContext.cs | 2 +- src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketAcceptContext.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketAcceptContext.cs index c8f09dd34f..d1227d41bd 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/WebSocketAcceptContext.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketAcceptContext.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Http.Interfaces; +using Microsoft.AspNet.Http; namespace Microsoft.AspNet.WebSockets.Server { diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs index 30ac76d09f..d03a183a72 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs @@ -8,7 +8,6 @@ using System.Net.WebSockets; using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Interfaces; using Microsoft.AspNet.WebSockets.Protocol; namespace Microsoft.AspNet.WebSockets.Server From 00a38659d5165db7954d20f3b3d59ca7c4dad416 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Sun, 8 Mar 2015 13:00:50 -0700 Subject: [PATCH 083/453] Update aspnet50/aspnetcore50 => dnx451/dnxcore50. --- src/Microsoft.AspNet.WebSockets.Protocol/project.json | 4 ++-- src/Microsoft.AspNet.WebSockets.Server/project.json | 6 +++--- test/AutobahnTestClient/Project.json | 2 +- test/AutobahnTestServer/Project.json | 4 ++-- test/Microsoft.AspNet.WebSockets.Client.Test/project.json | 4 ++-- test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json | 4 ++-- test/TestClient/project.json | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index 793b713670..9a560080d3 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -1,9 +1,9 @@ -{ +{ "version": "1.0.0-*", "description": "Managed web socket protocol parser.", "frameworks": { "net45": { }, - "aspnetcore50": { + "dnxcore50": { "dependencies": { "Microsoft.Net.WebSocketAbstractions": "1.0.0-*", "System.Diagnostics.Contracts": "4.0.0-beta-*", diff --git a/src/Microsoft.AspNet.WebSockets.Server/project.json b/src/Microsoft.AspNet.WebSockets.Server/project.json index 24227af55b..7e404de566 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/project.json +++ b/src/Microsoft.AspNet.WebSockets.Server/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "description": "ASP.NET 5 web socket middleware for use on top of opaque servers.", "dependencies": { @@ -7,8 +7,8 @@ "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*" }, "frameworks": { - "aspnet50": { }, - "aspnetcore50": { + "dnx451": { }, + "dnxcore50": { "dependencies": { "System.Runtime": "4.0.20-beta-*" } diff --git a/test/AutobahnTestClient/Project.json b/test/AutobahnTestClient/Project.json index ecb3dd00df..d43caeca15 100644 --- a/test/AutobahnTestClient/Project.json +++ b/test/AutobahnTestClient/Project.json @@ -6,6 +6,6 @@ "run" : "run" }, "frameworks" : { - "aspnet50" : { } + "dnx451" : { } } } diff --git a/test/AutobahnTestServer/Project.json b/test/AutobahnTestServer/Project.json index 2376bab681..f844afe598 100644 --- a/test/AutobahnTestServer/Project.json +++ b/test/AutobahnTestServer/Project.json @@ -12,7 +12,7 @@ "kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:12344" }, "frameworks" : { - "aspnet50" : { }, - "aspnetcore50" : { } + "dnx451" : { }, + "dnxcore50" : { } } } diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json index ad24bf8df0..5fd2e99a76 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json @@ -1,4 +1,4 @@ -{ +{ "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", "Microsoft.AspNet.WebSockets.Client": "1.0.0-*", @@ -7,7 +7,7 @@ "xunit.runner.kre": "1.0.0-*" }, "frameworks": { - "aspnet50": { } + "dnx451": { } }, "commands": { "test": "xunit.runner.kre" diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json index d774c720d6..75234775c8 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json @@ -1,10 +1,10 @@ -{ +{ "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", "xunit.runner.kre": "1.0.0-*" }, "frameworks": { - "aspnet50": { } + "dnx451": { } }, "commands": { "test": "xunit.runner.kre" diff --git a/test/TestClient/project.json b/test/TestClient/project.json index ec5d45197c..388ac477ff 100644 --- a/test/TestClient/project.json +++ b/test/TestClient/project.json @@ -1,9 +1,9 @@ -{ +{ "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", "Microsoft.AspNet.WebSockets.Client": "1.0.0-*" }, "frameworks": { - "aspnet50": { } + "dnx451": { } } } From 9ff40bf4f003c84f9972637c2b3d107aa98b9f60 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Sun, 8 Mar 2015 13:00:50 -0700 Subject: [PATCH 084/453] Update K_BUILD_VERSION/kre/KRE/.k => DNX_BUILD_VERSION/dnx/DNX/.dnx. --- build.cmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.cmd b/build.cmd index 86ca5bbbf1..49ba0692de 100644 --- a/build.cmd +++ b/build.cmd @@ -1,4 +1,4 @@ -@echo off +@echo off cd %~dp0 SETLOCAL @@ -19,7 +19,7 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion -IF "%SKIP_KRE_INSTALL%"=="1" goto run +IF "%SKIP_DNX_INSTALL%"=="1" goto run CALL packages\KoreBuild\build\kvm upgrade -runtime CLR -x86 CALL packages\KoreBuild\build\kvm install default -runtime CoreCLR -x86 From 1869fa33110b1589464cef05125b10af089f3b6a Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Sun, 8 Mar 2015 13:00:51 -0700 Subject: [PATCH 085/453] Update kvm/KVM/Kvm => dnvm/DNVM/Dnvm. --- build.cmd | 6 +++--- build.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build.cmd b/build.cmd index 49ba0692de..77be0a6627 100644 --- a/build.cmd +++ b/build.cmd @@ -20,9 +20,9 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion IF "%SKIP_DNX_INSTALL%"=="1" goto run -CALL packages\KoreBuild\build\kvm upgrade -runtime CLR -x86 -CALL packages\KoreBuild\build\kvm install default -runtime CoreCLR -x86 +CALL packages\KoreBuild\build\dnvm upgrade -runtime CLR -x86 +CALL packages\KoreBuild\build\dnvm install default -runtime CoreCLR -x86 :run -CALL packages\KoreBuild\build\kvm use default -runtime CLR -x86 +CALL packages\KoreBuild\build\dnvm use default -runtime CLR -x86 packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* diff --git a/build.sh b/build.sh index c7873ef58e..74cb3421e6 100644 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash if test `uname` = Darwin; then cachedir=~/Library/Caches/KBuild @@ -28,11 +28,11 @@ if test ! -d packages/KoreBuild; then fi if ! type k > /dev/null 2>&1; then - source packages/KoreBuild/build/kvm.sh + source packages/KoreBuild/build/dnvm.sh fi if ! type k > /dev/null 2>&1; then - kvm upgrade + dnvm upgrade fi mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" From 0424843229e80f20e7153a6d2b580754ffdbd52d Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Sun, 8 Mar 2015 13:00:51 -0700 Subject: [PATCH 086/453] Update build.sh to use dnvm correctly. --- build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 74cb3421e6..a9ce06d087 100644 --- a/build.sh +++ b/build.sh @@ -27,7 +27,7 @@ if test ! -d packages/KoreBuild; then mono .nuget/nuget.exe install Sake -version 0.2 -o packages -ExcludeVersion fi -if ! type k > /dev/null 2>&1; then +if ! type dnvm > /dev/null 2>&1; then source packages/KoreBuild/build/dnvm.sh fi @@ -36,3 +36,4 @@ if ! type k > /dev/null 2>&1; then fi mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" + From 37a3c7f2a62fec2b7b766f1e616fa68f910e626f Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Mon, 9 Mar 2015 13:02:12 -0700 Subject: [PATCH 087/453] Remove BOM from project.json, *.cmd, *.sh and *.shade files. --- build.cmd | 2 +- build.sh | 2 +- src/Microsoft.AspNet.WebSockets.Protocol/project.json | 2 +- src/Microsoft.AspNet.WebSockets.Server/project.json | 2 +- test/AutobahnTestClient/Project.json | 2 +- test/AutobahnTestServer/Project.json | 2 +- test/Microsoft.AspNet.WebSockets.Client.Test/project.json | 2 +- test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json | 2 +- test/TestClient/project.json | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build.cmd b/build.cmd index 77be0a6627..68a732c182 100644 --- a/build.cmd +++ b/build.cmd @@ -1,4 +1,4 @@ -@echo off +@echo off cd %~dp0 SETLOCAL diff --git a/build.sh b/build.sh index a9ce06d087..ec3263114a 100644 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash if test `uname` = Darwin; then cachedir=~/Library/Caches/KBuild diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index 9a560080d3..b8854b70d3 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "description": "Managed web socket protocol parser.", "frameworks": { diff --git a/src/Microsoft.AspNet.WebSockets.Server/project.json b/src/Microsoft.AspNet.WebSockets.Server/project.json index 7e404de566..629e90d389 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/project.json +++ b/src/Microsoft.AspNet.WebSockets.Server/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "description": "ASP.NET 5 web socket middleware for use on top of opaque servers.", "dependencies": { diff --git a/test/AutobahnTestClient/Project.json b/test/AutobahnTestClient/Project.json index d43caeca15..a671b8f913 100644 --- a/test/AutobahnTestClient/Project.json +++ b/test/AutobahnTestClient/Project.json @@ -1,4 +1,4 @@ -{ +{ "dependencies": { "Microsoft.AspNet.WebSockets.Client": "1.0.0-*" }, diff --git a/test/AutobahnTestServer/Project.json b/test/AutobahnTestServer/Project.json index f844afe598..cb434f8072 100644 --- a/test/AutobahnTestServer/Project.json +++ b/test/AutobahnTestServer/Project.json @@ -1,4 +1,4 @@ -{ +{ "webroot": "wwwroot", "exclude": "wwwroot/**/*", "dependencies": { diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json index 5fd2e99a76..0af268592b 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json @@ -1,4 +1,4 @@ -{ +{ "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", "Microsoft.AspNet.WebSockets.Client": "1.0.0-*", diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json index 75234775c8..8365d78d13 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json @@ -1,4 +1,4 @@ -{ +{ "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", "xunit.runner.kre": "1.0.0-*" diff --git a/test/TestClient/project.json b/test/TestClient/project.json index 388ac477ff..f4c2b0131d 100644 --- a/test/TestClient/project.json +++ b/test/TestClient/project.json @@ -1,4 +1,4 @@ -{ +{ "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", "Microsoft.AspNet.WebSockets.Client": "1.0.0-*" From 167b7b931786099eb9677d31fd90153ec45c37fe Mon Sep 17 00:00:00 2001 From: Praburaj Date: Tue, 10 Mar 2015 11:48:47 -0700 Subject: [PATCH 088/453] Renaming Nuget.org feed key name to Nuget. fixes https://github.com/aspnet/Universe/issues/174 --- NuGet.Config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index f41e9c631d..da57d47267 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -2,6 +2,6 @@ - + - + \ No newline at end of file From a43664286a3def971b08a998dcc80504cccce9a0 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Wed, 11 Mar 2015 14:09:20 -0700 Subject: [PATCH 089/453] Update .kproj => .xproj. --- WebSockets.sln | 16 ++++++++-------- ... => Microsoft.AspNet.WebSockets.Client.xproj} | 0 ...> Microsoft.AspNet.WebSockets.Protocol.xproj} | 0 ... => Microsoft.AspNet.WebSockets.Server.xproj} | 0 ...TestClient.kproj => AutobahnTestClient.xproj} | 0 ...TestServer.kproj => AutobahnTestServer.xproj} | 0 ...icrosoft.AspNet.WebSockets.Client.Test.xproj} | 0 ...rosoft.AspNet.WebSockets.Protocol.Test.xproj} | 0 .../{TestClient.kproj => TestClient.xproj} | 0 9 files changed, 8 insertions(+), 8 deletions(-) rename src/Microsoft.AspNet.WebSockets.Client/{Microsoft.AspNet.WebSockets.Client.kproj => Microsoft.AspNet.WebSockets.Client.xproj} (100%) rename src/Microsoft.AspNet.WebSockets.Protocol/{Microsoft.AspNet.WebSockets.Protocol.kproj => Microsoft.AspNet.WebSockets.Protocol.xproj} (100%) rename src/Microsoft.AspNet.WebSockets.Server/{Microsoft.AspNet.WebSockets.Server.kproj => Microsoft.AspNet.WebSockets.Server.xproj} (100%) rename test/AutobahnTestClient/{AutobahnTestClient.kproj => AutobahnTestClient.xproj} (100%) rename test/AutobahnTestServer/{AutobahnTestServer.kproj => AutobahnTestServer.xproj} (100%) rename test/Microsoft.AspNet.WebSockets.Client.Test/{Microsoft.AspNet.WebSockets.Client.Test.kproj => Microsoft.AspNet.WebSockets.Client.Test.xproj} (100%) rename test/Microsoft.AspNet.WebSockets.Protocol.Test/{Microsoft.AspNet.WebSockets.Protocol.Test.kproj => Microsoft.AspNet.WebSockets.Protocol.Test.xproj} (100%) rename test/TestClient/{TestClient.kproj => TestClient.xproj} (100%) diff --git a/WebSockets.sln b/WebSockets.sln index 6b9df02739..dbe1d22aaf 100644 --- a/WebSockets.sln +++ b/WebSockets.sln @@ -11,26 +11,26 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{C45106D0-7 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Protocol", "src\Microsoft.AspNet.WebSockets.Protocol\Microsoft.AspNet.WebSockets.Protocol.kproj", "{E0C10DEC-3339-4A47-85BC-3100C5D34AD4}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Protocol", "src\Microsoft.AspNet.WebSockets.Protocol\Microsoft.AspNet.WebSockets.Protocol.xproj", "{E0C10DEC-3339-4A47-85BC-3100C5D34AD4}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Protocol.Test", "test\Microsoft.AspNet.WebSockets.Protocol.Test\Microsoft.AspNet.WebSockets.Protocol.Test.kproj", "{62A07A24-4D06-4DDA-B6BF-02D0C9CB7D32}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Protocol.Test", "test\Microsoft.AspNet.WebSockets.Protocol.Test\Microsoft.AspNet.WebSockets.Protocol.Test.xproj", "{62A07A24-4D06-4DDA-B6BF-02D0C9CB7D32}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestClient", "test\TestClient\TestClient.kproj", "{8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestClient", "test\TestClient\TestClient.xproj", "{8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Client", "src\Microsoft.AspNet.WebSockets.Client\Microsoft.AspNet.WebSockets.Client.kproj", "{4A1C4875-AE21-4A78-979A-F0E4DF5EB518}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Client", "src\Microsoft.AspNet.WebSockets.Client\Microsoft.AspNet.WebSockets.Client.xproj", "{4A1C4875-AE21-4A78-979A-F0E4DF5EB518}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Client.Test", "test\Microsoft.AspNet.WebSockets.Client.Test\Microsoft.AspNet.WebSockets.Client.Test.kproj", "{6604D154-817F-4BC5-BE95-FF7E851179D9}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Client.Test", "test\Microsoft.AspNet.WebSockets.Client.Test\Microsoft.AspNet.WebSockets.Client.Test.xproj", "{6604D154-817F-4BC5-BE95-FF7E851179D9}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Server", "src\Microsoft.AspNet.WebSockets.Server\Microsoft.AspNet.WebSockets.Server.kproj", "{78A097D0-C0A4-4AED-93E2-84A65392FB52}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Server", "src\Microsoft.AspNet.WebSockets.Server\Microsoft.AspNet.WebSockets.Server.xproj", "{78A097D0-C0A4-4AED-93E2-84A65392FB52}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{86E1ADA2-631C-484F-906C-2D0BCF628E65}" ProjectSection(SolutionItems) = preProject global.json = global.json EndProjectSection EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AutobahnTestServer", "test\AutobahnTestServer\AutobahnTestServer.kproj", "{C03C43FE-9201-48A6-B434-AD67EF627D67}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AutobahnTestServer", "test\AutobahnTestServer\AutobahnTestServer.xproj", "{C03C43FE-9201-48A6-B434-AD67EF627D67}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AutobahnTestClient", "test\AutobahnTestClient\AutobahnTestClient.kproj", "{BC4D2BB1-05A8-4816-8BC1-3A664F09EE32}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AutobahnTestClient", "test\AutobahnTestClient\AutobahnTestClient.xproj", "{BC4D2BB1-05A8-4816-8BC1-3A664F09EE32}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.kproj b/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.xproj similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.kproj rename to src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.xproj diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.kproj b/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.xproj similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.kproj rename to src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.xproj diff --git a/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.kproj b/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.xproj similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.kproj rename to src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.xproj diff --git a/test/AutobahnTestClient/AutobahnTestClient.kproj b/test/AutobahnTestClient/AutobahnTestClient.xproj similarity index 100% rename from test/AutobahnTestClient/AutobahnTestClient.kproj rename to test/AutobahnTestClient/AutobahnTestClient.xproj diff --git a/test/AutobahnTestServer/AutobahnTestServer.kproj b/test/AutobahnTestServer/AutobahnTestServer.xproj similarity index 100% rename from test/AutobahnTestServer/AutobahnTestServer.kproj rename to test/AutobahnTestServer/AutobahnTestServer.xproj diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.kproj b/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.xproj similarity index 100% rename from test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.kproj rename to test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.xproj diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.kproj b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.xproj similarity index 100% rename from test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.kproj rename to test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.xproj diff --git a/test/TestClient/TestClient.kproj b/test/TestClient/TestClient.xproj similarity index 100% rename from test/TestClient/TestClient.kproj rename to test/TestClient/TestClient.xproj From 07f78bab6f777d1831bd0e705dc0bc2350b2adb3 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Wed, 11 Mar 2015 16:58:37 -0700 Subject: [PATCH 090/453] Do not use deprecated `dnvm -x86` switch --- build.cmd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.cmd b/build.cmd index 68a732c182..41025afb26 100644 --- a/build.cmd +++ b/build.cmd @@ -20,9 +20,9 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion IF "%SKIP_DNX_INSTALL%"=="1" goto run -CALL packages\KoreBuild\build\dnvm upgrade -runtime CLR -x86 -CALL packages\KoreBuild\build\dnvm install default -runtime CoreCLR -x86 +CALL packages\KoreBuild\build\dnvm upgrade -runtime CLR -arch x86 +CALL packages\KoreBuild\build\dnvm install default -runtime CoreCLR -arch x86 :run -CALL packages\KoreBuild\build\dnvm use default -runtime CLR -x86 +CALL packages\KoreBuild\build\dnvm use default -runtime CLR -arch x86 packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* From 8fb42e4d169dfa88a24415f97a76253ec5e4bc93 Mon Sep 17 00:00:00 2001 From: Brennan Date: Thu, 12 Mar 2015 16:14:29 -0700 Subject: [PATCH 091/453] Update xunit.runner.kre => xunit.runner.aspnet. --- test/Microsoft.AspNet.WebSockets.Client.Test/project.json | 4 ++-- test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json index 0af268592b..c0d28348f2 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json @@ -4,12 +4,12 @@ "Microsoft.AspNet.WebSockets.Client": "1.0.0-*", "Microsoft.AspNet.WebSockets.Server": "1.0.0-*", "Kestrel": "1.0.0-*", - "xunit.runner.kre": "1.0.0-*" + "xunit.runner.aspnet": "2.0.0-aspnet-*" }, "frameworks": { "dnx451": { } }, "commands": { - "test": "xunit.runner.kre" + "test": "xunit.runner.aspnet" } } diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json index 8365d78d13..182337015c 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json @@ -1,12 +1,12 @@ { "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", - "xunit.runner.kre": "1.0.0-*" + "xunit.runner.aspnet": "2.0.0-aspnet-*" }, "frameworks": { "dnx451": { } }, "commands": { - "test": "xunit.runner.kre" + "test": "xunit.runner.aspnet" } } From 226257020be4fd04536fc699ab349b118efc12aa Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 19 Mar 2015 12:11:02 -0700 Subject: [PATCH 092/453] React to hosting --- .../KestrelWebSocketHelpers.cs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index f0cc35fd72..86686dab39 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -5,10 +5,9 @@ using System; using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Hosting; +using Microsoft.AspNet.Hosting.Startup; using Microsoft.AspNet.Http; using Microsoft.Framework.ConfigurationModel; -using Microsoft.Framework.DependencyInjection; -using Microsoft.Framework.Runtime.Infrastructure; namespace Microsoft.AspNet.WebSockets.Client.Test { @@ -45,20 +44,14 @@ namespace Microsoft.AspNet.WebSockets.Client.Test var config = new Configuration(); config.Add(new MemoryConfigurationSource()); config.Set("server.urls", "http://localhost:54321"); - var services = HostingServices.Create(CallContextServiceLocator.Locator?.ServiceProvider, config) - .BuildServiceProvider(); - var applicationLifetime = services.GetRequiredService(); var context = new HostingContext() { - ApplicationLifetime = applicationLifetime, Configuration = config, ServerFactoryLocation = "Kestrel", - ApplicationStartup = startup, + StartupMethods = new StartupMethods(startup, configureServices: null) }; - - var engine = services.GetRequiredService(); - return engine.Start(context); + return new HostingEngine().Start(context); } } } \ No newline at end of file From 10cfee154be8985a160e448b004262045aebf9b0 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Tue, 24 Mar 2015 21:47:31 -0700 Subject: [PATCH 093/453] Remove k command and use dnx instead --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index ec3263114a..d81164353c 100644 --- a/build.sh +++ b/build.sh @@ -31,7 +31,7 @@ if ! type dnvm > /dev/null 2>&1; then source packages/KoreBuild/build/dnvm.sh fi -if ! type k > /dev/null 2>&1; then +if ! type dnx > /dev/null 2>&1; then dnvm upgrade fi From 7b163470796635b1b52aa65a0573d7b6fdedd5c4 Mon Sep 17 00:00:00 2001 From: suhasj Date: Wed, 25 Mar 2015 11:48:08 -0700 Subject: [PATCH 094/453] Updating to release NuGet.config --- NuGet.Config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index da57d47267..1978dc065a 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@  - + - \ No newline at end of file + From f3de0948150e41902c768b503e20a984fbb2b904 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Mon, 30 Mar 2015 18:19:35 -0700 Subject: [PATCH 095/453] React to hosting --- .../KestrelWebSocketHelpers.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index 86686dab39..c770695eaa 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -8,6 +8,7 @@ using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Hosting.Startup; using Microsoft.AspNet.Http; using Microsoft.Framework.ConfigurationModel; +using Microsoft.Framework.Runtime.Infrastructure; namespace Microsoft.AspNet.WebSockets.Client.Test { @@ -45,13 +46,11 @@ namespace Microsoft.AspNet.WebSockets.Client.Test config.Add(new MemoryConfigurationSource()); config.Set("server.urls", "http://localhost:54321"); - var context = new HostingContext() - { - Configuration = config, - ServerFactoryLocation = "Kestrel", - StartupMethods = new StartupMethods(startup, configureServices: null) - }; - return new HostingEngine().Start(context); + var engine = WebHost.CreateEngine(config) + .UseServer("Kestrel") + .UseStartup(startup); + + return engine.Start(); } } } \ No newline at end of file From 13eae9bb47eed9c97ea2b5bec807bf2b32c2ef94 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Wed, 1 Apr 2015 15:59:29 -0700 Subject: [PATCH 096/453] Add travis and appveyor CI support. --- .travis.yml | 3 +++ appveyor.yml | 5 +++++ build.sh | 0 3 files changed, 8 insertions(+) create mode 100644 .travis.yml create mode 100644 appveyor.yml mode change 100644 => 100755 build.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..0f4cb93e59 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: csharp +script: + - ./build.sh verify \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000000..88cb9ef145 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,5 @@ +build_script: + - build.cmd verify +clone_depth: 1 +test: off +deploy: off \ No newline at end of file diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 From 5b4ddc90824212cca31c2a653bad3bfa1ec7fae5 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Wed, 1 Apr 2015 17:09:59 -0700 Subject: [PATCH 097/453] Turn off sudo for .travis.yml. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 0f4cb93e59..5939a529e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ language: csharp +sudo: false script: - ./build.sh verify \ No newline at end of file From 5826cd901429aa2d14e228420a3151d2b751decb Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Thu, 2 Apr 2015 09:20:50 -0700 Subject: [PATCH 098/453] Update global.json, sources=>projects --- global.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/global.json b/global.json index 840c36f6ad..983ba0401e 100644 --- a/global.json +++ b/global.json @@ -1,3 +1,3 @@ { - "sources": ["src"] -} \ No newline at end of file + "projects": ["src"] +} From cf2ba5aa25aa923196f4d2071fb99034a2467804 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Thu, 2 Apr 2015 13:49:31 -0700 Subject: [PATCH 099/453] Update .xproj files for Microsoft.Web.AspNet.* -> Microsoft.DNX.* rename --- .../Microsoft.AspNet.WebSockets.Client.xproj | 8 ++++---- .../Microsoft.AspNet.WebSockets.Protocol.xproj | 8 ++++---- .../Microsoft.AspNet.WebSockets.Server.xproj | 8 ++++---- test/AutobahnTestClient/AutobahnTestClient.xproj | 8 ++++---- test/AutobahnTestServer/AutobahnTestServer.xproj | 8 ++++---- .../Microsoft.AspNet.WebSockets.Client.Test.xproj | 8 ++++---- .../Microsoft.AspNet.WebSockets.Protocol.Test.xproj | 8 ++++---- test/TestClient/TestClient.xproj | 8 ++++---- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.xproj b/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.xproj index 1fb418280e..307cbf106e 100644 --- a/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.xproj +++ b/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.xproj @@ -1,10 +1,10 @@ - + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + 4a1c4875-ae21-4a78-979a-f0e4df5eb518 ..\..\artifacts\obj\$(MSBuildProjectName) @@ -13,5 +13,5 @@ 2.0 - - + + \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.xproj b/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.xproj index d2541e7ed0..a0179fbe4e 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.xproj +++ b/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.xproj @@ -1,10 +1,10 @@ - + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + e0c10dec-3339-4a47-85bc-3100c5d34ad4 ..\..\artifacts\obj\$(MSBuildProjectName) @@ -13,5 +13,5 @@ 2.0 - - + + \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.xproj b/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.xproj index 7af9d3405f..2fdc3122ed 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.xproj +++ b/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.xproj @@ -1,10 +1,10 @@ - + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + 78a097d0-c0a4-4aed-93e2-84a65392fb52 ..\..\artifacts\obj\$(MSBuildProjectName) @@ -13,5 +13,5 @@ 2.0 - - + + \ No newline at end of file diff --git a/test/AutobahnTestClient/AutobahnTestClient.xproj b/test/AutobahnTestClient/AutobahnTestClient.xproj index 59062e8f48..3c518c8c0c 100644 --- a/test/AutobahnTestClient/AutobahnTestClient.xproj +++ b/test/AutobahnTestClient/AutobahnTestClient.xproj @@ -1,10 +1,10 @@ - + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + bc4d2bb1-05a8-4816-8bc1-3a664f09ee32 ..\..\artifacts\obj\$(MSBuildProjectName) @@ -13,5 +13,5 @@ 2.0 - - + + \ No newline at end of file diff --git a/test/AutobahnTestServer/AutobahnTestServer.xproj b/test/AutobahnTestServer/AutobahnTestServer.xproj index 884898e2d4..9ae4693c51 100644 --- a/test/AutobahnTestServer/AutobahnTestServer.xproj +++ b/test/AutobahnTestServer/AutobahnTestServer.xproj @@ -1,10 +1,10 @@ - + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + c03c43fe-9201-48a6-b434-ad67ef627d67 ..\..\artifacts\obj\$(MSBuildProjectName) @@ -13,5 +13,5 @@ 2.0 - - + + \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.xproj b/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.xproj index 48e7651d3d..8111420e1d 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.xproj +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.xproj @@ -1,10 +1,10 @@ - + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + 6604d154-817f-4bc5-be95-ff7e851179d9 ..\..\artifacts\obj\$(MSBuildProjectName) @@ -13,5 +13,5 @@ 2.0 - - + + \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.xproj b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.xproj index daf360064c..73851f8030 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.xproj +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.xproj @@ -1,10 +1,10 @@ - + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + 62a07a24-4d06-4dda-b6bf-02d0c9cb7d32 ..\..\artifacts\obj\$(MSBuildProjectName) @@ -13,5 +13,5 @@ 2.0 - - + + \ No newline at end of file diff --git a/test/TestClient/TestClient.xproj b/test/TestClient/TestClient.xproj index 83a8c2c2da..a30c5b238d 100644 --- a/test/TestClient/TestClient.xproj +++ b/test/TestClient/TestClient.xproj @@ -1,10 +1,10 @@ - + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + 8c8eac01-dc49-4c5e-b348-e4e46fe675f9 ..\..\artifacts\obj\$(MSBuildProjectName) @@ -13,5 +13,5 @@ 2.0 - - + + \ No newline at end of file From 558ac5a31675f065549d91ddf6e656cebeb51899 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Fri, 3 Apr 2015 17:36:41 -0700 Subject: [PATCH 100/453] Fix AppVeyor git line ending config --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 88cb9ef145..3fab83e134 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,3 +1,5 @@ +init: + - git config --global core.autocrlf true build_script: - build.cmd verify clone_depth: 1 From e0a651e9a643746c0eb83daa8b11cf4b81859a1c Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Tue, 7 Apr 2015 14:54:43 -0700 Subject: [PATCH 101/453] Add serviceable attribute to projects. aspnet/DNX#1600 --- .../Properties/AssemblyInfo.cs | 6 ++++++ .../Properties/AssemblyInfo.cs | 3 ++- .../Properties/AssemblyInfo.cs | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/Microsoft.AspNet.WebSockets.Client/Properties/AssemblyInfo.cs create mode 100644 src/Microsoft.AspNet.WebSockets.Server/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNet.WebSockets.Client/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.WebSockets.Client/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..f5c6f4a83a --- /dev/null +++ b/src/Microsoft.AspNet.WebSockets.Client/Properties/AssemblyInfo.cs @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Reflection; + +[assembly: AssemblyMetadata("Serviceable", "True")] \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.WebSockets.Protocol/Properties/AssemblyInfo.cs index b8a0860d30..f2450e304f 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -34,3 +34,4 @@ using System.Runtime.InteropServices; // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyMetadata("Serviceable", "True")] diff --git a/src/Microsoft.AspNet.WebSockets.Server/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.WebSockets.Server/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..f5c6f4a83a --- /dev/null +++ b/src/Microsoft.AspNet.WebSockets.Server/Properties/AssemblyInfo.cs @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Reflection; + +[assembly: AssemblyMetadata("Serviceable", "True")] \ No newline at end of file From dbbf62cb6b8eb32dd942c8c83d19a670251ac8f7 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Tue, 7 Apr 2015 16:18:08 -0700 Subject: [PATCH 102/453] Update .travis.yml and appveyor.yml to build quietly. --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5939a529e5..947bf868ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ language: csharp sudo: false script: - - ./build.sh verify \ No newline at end of file + - ./build.sh --quiet verify \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 3fab83e134..636a7618d3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ init: - git config --global core.autocrlf true build_script: - - build.cmd verify + - build.cmd --quiet verify clone_depth: 1 test: off deploy: off \ No newline at end of file From a10245d39f83a5e69e003bf0dc32bfd266253cc3 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Wed, 8 Apr 2015 14:50:42 -0700 Subject: [PATCH 103/453] Replace WebSocket dependency. --- src/Microsoft.AspNet.WebSockets.Protocol/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index b8854b70d3..0e0cd0d784 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -5,10 +5,10 @@ "net45": { }, "dnxcore50": { "dependencies": { - "Microsoft.Net.WebSocketAbstractions": "1.0.0-*", "System.Diagnostics.Contracts": "4.0.0-beta-*", "System.IO": "4.0.10-beta-*", "System.Linq": "4.0.0-beta-*", + "System.Net.WebSockets": "4.0.0-beta-*", "System.Runtime": "4.0.20-beta-*", "System.Runtime.InteropServices": "4.0.20-beta-*", "System.Runtime.Extensions": "4.0.10-beta-*", From f71d49744e2bdcdf248abc3ad1866177543225fa Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 15 Apr 2015 12:45:28 -0700 Subject: [PATCH 104/453] React to WebHostingBuilder --- .../KestrelWebSocketHelpers.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index c770695eaa..11474e5221 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -46,11 +46,12 @@ namespace Microsoft.AspNet.WebSockets.Client.Test config.Add(new MemoryConfigurationSource()); config.Set("server.urls", "http://localhost:54321"); - var engine = WebHost.CreateEngine(config) + var host = new WebHostBuilder(CallContextServiceLocator.Locator.ServiceProvider, config) .UseServer("Kestrel") - .UseStartup(startup); + .UseStartup(startup) + .Build(); - return engine.Start(); + return host.Start(); } } } \ No newline at end of file From 66b669aa22a50a51b5ae9e1a7d21a84e8d47c170 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Fri, 24 Apr 2015 10:52:06 -0700 Subject: [PATCH 105/453] React to WebSocket feature API changes. --- ...t.cs => ExtendedWebSocketAcceptContext.cs} | 4 +- .../WebSocketMiddleware.cs | 6 +- .../project.json | 1 - test/AutobahnTestServer/Startup.cs | 8 +-- .../WebSocketClientTests.cs | 72 +++++++++---------- 5 files changed, 45 insertions(+), 46 deletions(-) rename src/Microsoft.AspNet.WebSockets.Server/{WebSocketAcceptContext.cs => ExtendedWebSocketAcceptContext.cs} (78%) diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketAcceptContext.cs b/src/Microsoft.AspNet.WebSockets.Server/ExtendedWebSocketAcceptContext.cs similarity index 78% rename from src/Microsoft.AspNet.WebSockets.Server/WebSocketAcceptContext.cs rename to src/Microsoft.AspNet.WebSockets.Server/ExtendedWebSocketAcceptContext.cs index d1227d41bd..e0377b7d4b 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/WebSocketAcceptContext.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/ExtendedWebSocketAcceptContext.cs @@ -6,9 +6,9 @@ using Microsoft.AspNet.Http; namespace Microsoft.AspNet.WebSockets.Server { - public class WebSocketAcceptContext : IWebSocketAcceptContext + public class ExtendedWebSocketAcceptContext : WebSocketAcceptContext { - public string SubProtocol { get; set; } + public override string SubProtocol { get; set; } public int? ReceiveBufferSize { get; set; } public TimeSpan? KeepAliveInterval { get; set; } diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs index d03a183a72..0dc597bf0f 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs @@ -73,13 +73,13 @@ namespace Microsoft.AspNet.WebSockets.Server } } - public async Task AcceptAsync(IWebSocketAcceptContext acceptContext) + public async Task AcceptAsync(WebSocketAcceptContext acceptContext) { if (!IsWebSocketRequest) { throw new InvalidOperationException("Not a WebSocket request."); // TODO: LOC } - + string subProtocol = null; if (acceptContext != null) { @@ -88,7 +88,7 @@ namespace Microsoft.AspNet.WebSockets.Server TimeSpan keepAliveInterval = _options.KeepAliveInterval; int receiveBufferSize = _options.ReceiveBufferSize; - var advancedAcceptContext = acceptContext as WebSocketAcceptContext; + var advancedAcceptContext = acceptContext as ExtendedWebSocketAcceptContext; if (advancedAcceptContext != null) { if (advancedAcceptContext.ReceiveBufferSize.HasValue) diff --git a/src/Microsoft.AspNet.WebSockets.Server/project.json b/src/Microsoft.AspNet.WebSockets.Server/project.json index 629e90d389..51fab63e5e 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/project.json +++ b/src/Microsoft.AspNet.WebSockets.Server/project.json @@ -3,7 +3,6 @@ "description": "ASP.NET 5 web socket middleware for use on top of opaque servers.", "dependencies": { "Microsoft.AspNet.Http": "1.0.0-*", - "Microsoft.AspNet.Http.Interfaces": { "version": "1.0.0-*", "type": "build" }, "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*" }, "frameworks": { diff --git a/test/AutobahnTestServer/Startup.cs b/test/AutobahnTestServer/Startup.cs index 3a5692aadf..34ff549764 100644 --- a/test/AutobahnTestServer/Startup.cs +++ b/test/AutobahnTestServer/Startup.cs @@ -25,10 +25,10 @@ namespace AutobahnTestServer managedWebSocketsApp.Use(async (context, next) => { - if (context.IsWebSocketRequest) + if (context.WebSockets.IsWebSocketRequest) { Console.WriteLine("Echo: " + context.Request.Path); - var webSocket = await context.AcceptWebSocketAsync(); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); await Echo(webSocket); return; } @@ -40,10 +40,10 @@ namespace AutobahnTestServer { nativeWebSocketsApp.Use(async (context, next) => { - if (context.IsWebSocketRequest) + if (context.WebSockets.IsWebSocketRequest) { Console.WriteLine("Echo: " + context.Request.Path); - var webSocket = await context.AcceptWebSocketAsync(); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); await Echo(webSocket); return; } diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/WebSocketClientTests.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/WebSocketClientTests.cs index 2b5bd7d5de..eecb1adf50 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/WebSocketClientTests.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/WebSocketClientTests.cs @@ -19,8 +19,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test { using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - Assert.True(context.IsWebSocketRequest); - var webSocket = await context.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); })) { var client = new WebSocketClient(); @@ -35,9 +35,9 @@ namespace Microsoft.AspNet.WebSockets.Client.Test { using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - Assert.True(context.IsWebSocketRequest); + Assert.True(context.WebSockets.IsWebSocketRequest); Assert.Equal("alpha, bravo, charlie", context.Request.Headers["Sec-WebSocket-Protocol"]); - var webSocket = await context.AcceptWebSocketAsync("Bravo"); + var webSocket = await context.WebSockets.AcceptWebSocketAsync("Bravo"); })) { var client = new WebSocketClient(); @@ -56,8 +56,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test { using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - Assert.True(context.IsWebSocketRequest); - var webSocket = await context.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); var serverBuffer = new byte[0]; var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); @@ -81,8 +81,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test var orriginalData = Encoding.UTF8.GetBytes("Hello World"); using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - Assert.True(context.IsWebSocketRequest); - var webSocket = await context.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); var serverBuffer = new byte[orriginalData.Length]; var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); @@ -106,8 +106,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test var orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - Assert.True(context.IsWebSocketRequest); - var webSocket = await context.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); var serverBuffer = new byte[orriginalData.Length]; var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); @@ -131,8 +131,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - Assert.True(context.IsWebSocketRequest); - var webSocket = await context.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); var serverBuffer = new byte[orriginalData.Length]; var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); @@ -168,8 +168,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test var orriginalData = Encoding.UTF8.GetBytes("Hello World"); using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - Assert.True(context.IsWebSocketRequest); - var webSocket = await context.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); var serverBuffer = new byte[orriginalData.Length]; var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); @@ -211,8 +211,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test var orriginalData = Encoding.UTF8.GetBytes("Hello World"); using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - Assert.True(context.IsWebSocketRequest); - var webSocket = await context.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); })) @@ -235,8 +235,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test var orriginalData = Encoding.UTF8.GetBytes("Hello World"); using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - Assert.True(context.IsWebSocketRequest); - var webSocket = await context.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); })) @@ -260,8 +260,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test var orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - Assert.True(context.IsWebSocketRequest); - var webSocket = await context.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); })) @@ -285,8 +285,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - Assert.True(context.IsWebSocketRequest); - var webSocket = await context.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); })) @@ -318,8 +318,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - Assert.True(context.IsWebSocketRequest); - var webSocket = await context.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); })) @@ -343,8 +343,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test var orriginalData = Encoding.UTF8.GetBytes("Hello World"); using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - Assert.True(context.IsWebSocketRequest); - var webSocket = await context.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); await webSocket.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); await webSocket.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); @@ -386,8 +386,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test string closeDescription = "Test Closed"; using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - Assert.True(context.IsWebSocketRequest); - var webSocket = await context.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); var serverBuffer = new byte[1024]; var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); @@ -414,8 +414,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test string closeDescription = "Test Closed"; using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - Assert.True(context.IsWebSocketRequest); - var webSocket = await context.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); })) @@ -442,8 +442,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test string closeDescription = "Test Closed"; using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - Assert.True(context.IsWebSocketRequest); - var webSocket = await context.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); var serverBuffer = new byte[1024]; var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); @@ -472,8 +472,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test string closeDescription = "Test Closed"; using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - Assert.True(context.IsWebSocketRequest); - var webSocket = await context.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); var serverBuffer = new byte[1024]; var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); @@ -504,8 +504,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test string closeDescription = "Test Closed"; using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - Assert.True(context.IsWebSocketRequest); - var webSocket = await context.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); From 552b336a78c4835e7f84a94b1e5a07df4bc09b39 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Fri, 1 May 2015 14:07:00 -0700 Subject: [PATCH 106/453] Update LICENSE.txt and license header on files. --- LICENSE.txt | 2 +- src/Microsoft.AspNet.WebSockets.Client/Constants.cs | 2 +- .../Properties/AssemblyInfo.cs | 2 +- src/Microsoft.AspNet.WebSockets.Client/WebSocketClient.cs | 2 +- src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs | 2 +- src/Microsoft.AspNet.WebSockets.Protocol/Constants.cs | 2 +- src/Microsoft.AspNet.WebSockets.Protocol/FrameHeader.cs | 2 +- src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs | 2 +- src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs | 2 +- .../ExtendedWebSocketAcceptContext.cs | 2 +- .../Properties/AssemblyInfo.cs | 2 +- src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs | 2 +- .../WebSocketMiddlewareExtensions.cs | 2 +- src/Microsoft.AspNet.WebSockets.Server/WebSocketOptions.cs | 2 +- test/AutobahnTestClient/Program.cs | 2 +- test/AutobahnTestServer/Startup.cs | 2 +- .../KestrelWebSocketHelpers.cs | 2 +- .../WebSocketClientTests.cs | 2 +- test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs | 2 +- test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexStream.cs | 2 +- test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexTests.cs | 2 +- .../Utf8ValidationTests.cs | 2 +- .../Microsoft.AspNet.WebSockets.Protocol.Test/UtilitiesTests.cs | 2 +- 23 files changed, 23 insertions(+), 23 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index d85a1524ad..0bdc1962b6 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +Copyright (c) .NET Foundation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use these files except in compliance with the License. You may obtain a copy of the diff --git a/src/Microsoft.AspNet.WebSockets.Client/Constants.cs b/src/Microsoft.AspNet.WebSockets.Client/Constants.cs index 0178e7d75f..7cc48a9baf 100644 --- a/src/Microsoft.AspNet.WebSockets.Client/Constants.cs +++ b/src/Microsoft.AspNet.WebSockets.Client/Constants.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. namespace Microsoft.AspNet.WebSockets.Client diff --git a/src/Microsoft.AspNet.WebSockets.Client/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.WebSockets.Client/Properties/AssemblyInfo.cs index f5c6f4a83a..025a94598c 100644 --- a/src/Microsoft.AspNet.WebSockets.Client/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNet.WebSockets.Client/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Reflection; diff --git a/src/Microsoft.AspNet.WebSockets.Client/WebSocketClient.cs b/src/Microsoft.AspNet.WebSockets.Client/WebSocketClient.cs index f886e53987..3ba9c3963f 100644 --- a/src/Microsoft.AspNet.WebSockets.Client/WebSocketClient.cs +++ b/src/Microsoft.AspNet.WebSockets.Client/WebSocketClient.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs index c6d82a573b..ea74b29133 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/Constants.cs b/src/Microsoft.AspNet.WebSockets.Protocol/Constants.cs index 60a9340b67..80a3bf8983 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/Constants.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/Constants.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. namespace Microsoft.AspNet.WebSockets.Protocol diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/FrameHeader.cs b/src/Microsoft.AspNet.WebSockets.Protocol/FrameHeader.cs index 5d9d693763..749bf13d68 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/FrameHeader.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/FrameHeader.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs b/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs index f8e3c22712..15998f2afd 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs b/src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs index 7b0b3186da..385f4003a0 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/src/Microsoft.AspNet.WebSockets.Server/ExtendedWebSocketAcceptContext.cs b/src/Microsoft.AspNet.WebSockets.Server/ExtendedWebSocketAcceptContext.cs index e0377b7d4b..8b7d901aaf 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/ExtendedWebSocketAcceptContext.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/ExtendedWebSocketAcceptContext.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/src/Microsoft.AspNet.WebSockets.Server/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.WebSockets.Server/Properties/AssemblyInfo.cs index f5c6f4a83a..025a94598c 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Reflection; diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs index 0dc597bf0f..7432567bb0 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs index 91c69080ba..c676331771 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNet.WebSockets.Server; diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketOptions.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketOptions.cs index 5f46a23558..09a155da46 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/WebSocketOptions.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketOptions.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/test/AutobahnTestClient/Program.cs b/test/AutobahnTestClient/Program.cs index 15300f825b..67df22e3ff 100644 --- a/test/AutobahnTestClient/Program.cs +++ b/test/AutobahnTestClient/Program.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/test/AutobahnTestServer/Startup.cs b/test/AutobahnTestServer/Startup.cs index 34ff549764..bd69da7644 100644 --- a/test/AutobahnTestServer/Startup.cs +++ b/test/AutobahnTestServer/Startup.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index 11474e5221..ea019f256b 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/WebSocketClientTests.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/WebSocketClientTests.cs index eecb1adf50..9f298a9dbb 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/WebSocketClientTests.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/WebSocketClientTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs b/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs index 604aea7671..556bb42052 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. +// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. using System; using System.Collections.Concurrent; diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexStream.cs b/test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexStream.cs index bfada4b0ab..102ccbd0c3 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexStream.cs +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexStream.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. +// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. using System; using System.IO; diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexTests.cs b/test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexTests.cs index 5e0c4473dd..2e5cc15d83 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexTests.cs +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Utf8ValidationTests.cs b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Utf8ValidationTests.cs index ffd990b5e2..f42339a77f 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Utf8ValidationTests.cs +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/Utf8ValidationTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/UtilitiesTests.cs b/test/Microsoft.AspNet.WebSockets.Protocol.Test/UtilitiesTests.cs index ca07522b04..9f221f197b 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/UtilitiesTests.cs +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/UtilitiesTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; From ff406ecdf1899c0f9485d7f91dc428aed819b15a Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 7 May 2015 14:16:46 -0700 Subject: [PATCH 107/453] React to Http namespace changes. --- .../ExtendedWebSocketAcceptContext.cs | 2 +- src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.WebSockets.Server/ExtendedWebSocketAcceptContext.cs b/src/Microsoft.AspNet.WebSockets.Server/ExtendedWebSocketAcceptContext.cs index 8b7d901aaf..6c6fa97f16 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/ExtendedWebSocketAcceptContext.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/ExtendedWebSocketAcceptContext.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Http; +using Microsoft.AspNet.Http.Features; namespace Microsoft.AspNet.WebSockets.Server { diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs index 7432567bb0..8d13d9be0e 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs @@ -8,6 +8,7 @@ using System.Net.WebSockets; using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; +using Microsoft.AspNet.Http.Features; using Microsoft.AspNet.WebSockets.Protocol; namespace Microsoft.AspNet.WebSockets.Server From e1aa94bf397f0da7c1eba3f92c49f3c55b04f927 Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Tue, 12 May 2015 11:47:36 -0700 Subject: [PATCH 108/453] Update Home master -> Home dev --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index eac4268e4c..64ff041d5c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ Contributing ====== -Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/master/CONTRIBUTING.md) in the Home repo. +Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/dev/CONTRIBUTING.md) in the Home repo. From 74c83638558e006477b54fcbcea0c200cc0f2fec Mon Sep 17 00:00:00 2001 From: Chris R Date: Fri, 15 May 2015 11:34:15 -0700 Subject: [PATCH 109/453] React to CoreClr dependency changes. --- src/Microsoft.AspNet.WebSockets.Protocol/project.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index 0e0cd0d784..b525974346 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -13,6 +13,7 @@ "System.Runtime.InteropServices": "4.0.20-beta-*", "System.Runtime.Extensions": "4.0.10-beta-*", "System.Security.Cryptography.Encryption": "4.0.0-beta-*", + "System.Security.Cryptography.Hashing": "4.0.0-beta-*", "System.Security.Cryptography.Hashing.Algorithms": "4.0.0-beta-*", "System.Text.Encoding.Extensions": "4.0.10-beta-*", "System.Threading": "4.0.10-beta-*", From 9ba11ee04ad056e851f5758645deea95ca837d5d Mon Sep 17 00:00:00 2001 From: Kirthi Krishnamraju Date: Wed, 20 May 2015 18:43:12 -0700 Subject: [PATCH 110/453] React to aspnet/Configuration #195,#198 --- .../KestrelWebSocketHelpers.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index ea019f256b..1359a5ada9 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -7,7 +7,7 @@ using Microsoft.AspNet.Builder; using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Hosting.Startup; using Microsoft.AspNet.Http; -using Microsoft.Framework.ConfigurationModel; +using Microsoft.Framework.Configuration; using Microsoft.Framework.Runtime.Infrastructure; namespace Microsoft.AspNet.WebSockets.Client.Test @@ -42,7 +42,7 @@ namespace Microsoft.AspNet.WebSockets.Client.Test builder.Run(c => app(c)); }; - var config = new Configuration(); + var config = new ConfigurationSection(); config.Add(new MemoryConfigurationSource()); config.Set("server.urls", "http://localhost:54321"); From 58c7eb1826ebcd3eafcfd24ca99a192ead03d8f9 Mon Sep 17 00:00:00 2001 From: Kirthi Krishnamraju Date: Fri, 22 May 2015 05:28:05 -0700 Subject: [PATCH 111/453] React to aspnet/Configuration #194 --- .../KestrelWebSocketHelpers.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index 1359a5ada9..eb4eec2824 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -42,8 +42,9 @@ namespace Microsoft.AspNet.WebSockets.Client.Test builder.Run(c => app(c)); }; - var config = new ConfigurationSection(); - config.Add(new MemoryConfigurationSource()); + var builder = new ConfigurationBuilder(); + builder.Add(new MemoryConfigurationSource()); + var config = builder.Build(); config.Set("server.urls", "http://localhost:54321"); var host = new WebHostBuilder(CallContextServiceLocator.Locator.ServiceProvider, config) From f09dec143843d764b458d845e2c09af36fa0066c Mon Sep 17 00:00:00 2001 From: Kirthi Krishnamraju Date: Fri, 22 May 2015 06:59:23 -0700 Subject: [PATCH 112/453] fix build break --- .../KestrelWebSocketHelpers.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index eb4eec2824..9967c6dbf7 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -42,9 +42,9 @@ namespace Microsoft.AspNet.WebSockets.Client.Test builder.Run(c => app(c)); }; - var builder = new ConfigurationBuilder(); - builder.Add(new MemoryConfigurationSource()); - var config = builder.Build(); + var configBuilder = new ConfigurationBuilder(); + configBuilder.Add(new MemoryConfigurationSource()); + var config = configBuilder.Build(); config.Set("server.urls", "http://localhost:54321"); var host = new WebHostBuilder(CallContextServiceLocator.Locator.ServiceProvider, config) From b7db5b2fbecd28b4ee2f6703600cbb3c989c2e40 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 27 May 2015 16:32:58 -0700 Subject: [PATCH 113/453] Updating to release NuGet.config --- NuGet.Config | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index da57d47267..0e74a4912d 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,8 @@  - + + - \ No newline at end of file + From 208fa4af366e23b51f2b943f709e00b6d48eec22 Mon Sep 17 00:00:00 2001 From: Hisham Abdullah Bin Ateya Date: Thu, 11 Jun 2015 22:44:11 +0300 Subject: [PATCH 114/453] Using 'nameof' operator instead of magic strings --- .../CommonWebSocket.cs | 8 ++++---- .../BufferStream.cs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs index ea74b29133..02a040af77 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs @@ -117,7 +117,7 @@ namespace Microsoft.AspNet.WebSockets.Protocol if (messageType != WebSocketMessageType.Binary && messageType != WebSocketMessageType.Text) { // Block control frames - throw new ArgumentOutOfRangeException("messageType", messageType, string.Empty); + throw new ArgumentOutOfRangeException(nameof(messageType), messageType, string.Empty); } // Check concurrent writes, pings & pongs, or closes @@ -588,15 +588,15 @@ namespace Microsoft.AspNet.WebSockets.Protocol { if (buffer.Array == null) { - throw new ArgumentNullException("buffer"); + throw new ArgumentNullException(nameof(buffer)); } if (buffer.Offset < 0 || buffer.Offset > buffer.Array.Length) { - throw new ArgumentOutOfRangeException("buffer.Offset", buffer.Offset, string.Empty); + throw new ArgumentOutOfRangeException(nameof(buffer.Offset), buffer.Offset, string.Empty); } if (buffer.Count < 0 || buffer.Count > buffer.Array.Length - buffer.Offset) { - throw new ArgumentOutOfRangeException("buffer.Count", buffer.Count, string.Empty); + throw new ArgumentOutOfRangeException(nameof(buffer.Count), buffer.Count, string.Empty); } } diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs b/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs index 556bb42052..ca1c1c969f 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs @@ -263,12 +263,12 @@ namespace Microsoft.AspNet.WebSockets.Protocol.Test } if (offset < 0 || offset > buffer.Length) { - throw new ArgumentOutOfRangeException("offset", offset, string.Empty); + throw new ArgumentOutOfRangeException(nameof(offset), offset, string.Empty); } if (count < 0 || count > buffer.Length - offset || (!allowEmpty && count == 0)) { - throw new ArgumentOutOfRangeException("count", count, string.Empty); + throw new ArgumentOutOfRangeException(nameof(count), count, string.Empty); } } From e632831c09429aaa0ccb18bfc028987247f1e898 Mon Sep 17 00:00:00 2001 From: Hisham Abdullah Bin Ateya Date: Thu, 11 Jun 2015 22:49:17 +0300 Subject: [PATCH 115/453] Using [NotNull] --- .../HandshakeHelpers.cs | 8 ++------ src/Microsoft.AspNet.WebSockets.Protocol/project.json | 3 +++ .../BufferStream.cs | 7 ++----- .../project.json | 1 + 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs b/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs index 15998f2afd..b3aa119609 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Security.Cryptography; using System.Text; +using Microsoft.Framework.Internal; namespace Microsoft.AspNet.WebSockets.Protocol { @@ -123,13 +124,8 @@ namespace Microsoft.AspNet.WebSockets.Protocol /// /// /// - public static string CreateResponseKey(string requestKey) + public static string CreateResponseKey([NotNull] string requestKey) { - if (string.IsNullOrWhiteSpace(requestKey)) - { - throw new ArgumentNullException("requestKey"); - } - using (var algorithm = SHA1.Create()) { string merged = requestKey + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index b525974346..a0fce33e1d 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -1,6 +1,9 @@ { "version": "1.0.0-*", "description": "Managed web socket protocol parser.", + "dependencies": { + "Microsoft.Framework.NotNullAttribute.Internal": { "type": "build", "version": "1.0.0-*" } + }, "frameworks": { "net45": { }, "dnxcore50": { diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs b/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs index ca1c1c969f..e2ff11e792 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs @@ -7,6 +7,7 @@ using System.Diagnostics.Contracts; using System.IO; using System.Threading; using System.Threading.Tasks; +using Microsoft.Framework.Internal; namespace Microsoft.AspNet.WebSockets.Protocol.Test { @@ -255,12 +256,8 @@ namespace Microsoft.AspNet.WebSockets.Protocol.Test return Task.FromResult(null); } - private static void VerifyBuffer(byte[] buffer, int offset, int count, bool allowEmpty) + private static void VerifyBuffer([NotNull] byte[] buffer, int offset, int count, bool allowEmpty) { - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } if (offset < 0 || offset > buffer.Length) { throw new ArgumentOutOfRangeException(nameof(offset), offset, string.Empty); diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json index 182337015c..86111c50e7 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json @@ -1,6 +1,7 @@ { "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", + "Microsoft.Framework.NotNullAttribute.Internal": { "type": "build", "version": "1.0.0-*" }, "xunit.runner.aspnet": "2.0.0-aspnet-*" }, "frameworks": { From a1409e02946eb62ffd5e5171f9821770a72cb652 Mon Sep 17 00:00:00 2001 From: Hisham Abdullah Bin Ateya Date: Thu, 11 Jun 2015 23:42:32 +0300 Subject: [PATCH 116/453] React to common package name change --- src/Microsoft.AspNet.WebSockets.Protocol/project.json | 2 +- test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index a0fce33e1d..ae5cd3be66 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -2,7 +2,7 @@ "version": "1.0.0-*", "description": "Managed web socket protocol parser.", "dependencies": { - "Microsoft.Framework.NotNullAttribute.Internal": { "type": "build", "version": "1.0.0-*" } + "Microsoft.Framework.NotNullAttribute.Sources": { "type": "build", "version": "1.0.0-*" } }, "frameworks": { "net45": { }, diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json index 86111c50e7..7db25a7abe 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json @@ -1,7 +1,7 @@ { "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", - "Microsoft.Framework.NotNullAttribute.Internal": { "type": "build", "version": "1.0.0-*" }, + "Microsoft.Framework.NotNullAttribute.Sources": { "type": "build", "version": "1.0.0-*" }, "xunit.runner.aspnet": "2.0.0-aspnet-*" }, "frameworks": { From 1639ee07e7e42b438ca0b67cb12af0deeb1b3039 Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 15 Jun 2015 17:49:20 -0700 Subject: [PATCH 117/453] React to HttpResponse.HeadersSent rename. --- .../KestrelWebSocketHelpers.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index 9967c6dbf7..9ebe9e3e24 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -28,7 +28,7 @@ namespace Microsoft.AspNet.WebSockets.Client.Test } catch (Exception ex) { - if (ct.Response.HeadersSent) + if (ct.Response.HasStarted) { throw; } @@ -55,4 +55,4 @@ namespace Microsoft.AspNet.WebSockets.Client.Test return host.Start(); } } -} \ No newline at end of file +} From ba952b83727c9c72b11bd5318bc0fd14db8aa7a2 Mon Sep 17 00:00:00 2001 From: Hisham Abdullah Bin Ateya Date: Sat, 20 Jun 2015 23:19:08 +0300 Subject: [PATCH 118/453] Add AppVeyor, Travis build status --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index edaa040954..981faf141a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ WebSockets ================ +AppVeyor: [![AppVeyor](https://ci.appveyor.com/api/projects/status/lk5hyg6gki03hdqe/branch/dev?svg=true)](https://ci.appveyor.com/project/aspnetci/WebSockets/branch/dev) + +Travis: [![Travis](https://travis-ci.org/aspnet/WebSockets.svg?branch=dev)](https://travis-ci.org/aspnet/WebSockets) + Contains a managed implementation of the WebSocket protocol, along with client and server integration components. This project is part of ASP.NET 5. You can find samples, documentation and getting started instructions for ASP.NET 5 at the [Home](https://github.com/aspnet/home) repo. From 210c73279cf7ad57a4815ec2b384af6b1514d676 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Tue, 23 Jun 2015 11:44:10 -0700 Subject: [PATCH 119/453] Change hardcoded `bash` shebang to `env` - aspnet/Home#695 - support various `bash` installation locations - in particular, enable building on FreeBSD --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index d81164353c..3ef874f9bd 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash if test `uname` = Darwin; then cachedir=~/Library/Caches/KBuild From cc1b0c36acf9949254bee08d75a0ac2f074c7641 Mon Sep 17 00:00:00 2001 From: anurse Date: Mon, 29 Jun 2015 10:45:04 -0700 Subject: [PATCH 120/453] fix #26 by using RNGCryptoServiceProvider on net45 --- .../CommonWebSocket.cs | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs index 02a040af77..17d9118153 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs @@ -6,6 +6,7 @@ using System.Diagnostics.Contracts; using System.IO; using System.Linq; using System.Net.WebSockets; +using System.Security.Cryptography; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -15,7 +16,6 @@ namespace Microsoft.AspNet.WebSockets.Protocol // https://tools.ietf.org/html/rfc6455 public class CommonWebSocket : WebSocket { - private readonly static Random Random = new Random(); private readonly static byte[] PingBuffer = Encoding.ASCII.GetBytes("abcdefghijklmnopqrstuvwxyz"); private readonly Stream _stream; @@ -59,6 +59,22 @@ namespace Microsoft.AspNet.WebSockets.Protocol } } + // NOTE(anurse): Normally we don't group fields and methods like this but I'd rather do this than have two sections of #ifs. +#if NET45 + private readonly static RandomNumberGenerator Random = new RNGCryptoServiceProvider(); + private static void GetRandomBytes(byte[] buffer) + { + Random.GetBytes(buffer); + } +#else + // No RandomNumberGenerator in CoreCLR :(. Use System.Random until it's available + private readonly static Random Random = new Random(); + private static void GetRandomBytes(byte[] buffer) + { + Random.NextBytes(buffer); + } +#endif + public static CommonWebSocket CreateClientWebSocket(Stream stream, string subProtocol, TimeSpan keepAliveInterval, int receiveBufferSize, bool useZeroMask) { return new CommonWebSocket(stream, subProtocol, keepAliveInterval, receiveBufferSize, maskOutput: true, useZeroMask: useZeroMask, unmaskInput: false); @@ -107,8 +123,11 @@ namespace Microsoft.AspNet.WebSockets.Protocol { return 0; } - // TODO: Doesn't include negative numbers so it's only 31 bits, not 32. - return Random.Next(); + + // Get 32-bits of randomness and convert it to an int + var buffer = new byte[sizeof(int)]; + GetRandomBytes(buffer); + return BitConverter.ToInt32(buffer, 0); } public override async Task SendAsync(ArraySegment buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken) From 61894cb4e041fa97d6f5e9bfc5b1a422f5693f61 Mon Sep 17 00:00:00 2001 From: anurse Date: Mon, 29 Jun 2015 12:20:16 -0700 Subject: [PATCH 121/453] attempt 57: just don't support web socket client from dnxcore --- .../CommonWebSocket.cs | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs index 17d9118153..a63800c536 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs @@ -59,22 +59,6 @@ namespace Microsoft.AspNet.WebSockets.Protocol } } - // NOTE(anurse): Normally we don't group fields and methods like this but I'd rather do this than have two sections of #ifs. -#if NET45 - private readonly static RandomNumberGenerator Random = new RNGCryptoServiceProvider(); - private static void GetRandomBytes(byte[] buffer) - { - Random.GetBytes(buffer); - } -#else - // No RandomNumberGenerator in CoreCLR :(. Use System.Random until it's available - private readonly static Random Random = new Random(); - private static void GetRandomBytes(byte[] buffer) - { - Random.NextBytes(buffer); - } -#endif - public static CommonWebSocket CreateClientWebSocket(Stream stream, string subProtocol, TimeSpan keepAliveInterval, int receiveBufferSize, bool useZeroMask) { return new CommonWebSocket(stream, subProtocol, keepAliveInterval, receiveBufferSize, maskOutput: true, useZeroMask: useZeroMask, unmaskInput: false); @@ -117,6 +101,9 @@ namespace Microsoft.AspNet.WebSockets.Protocol // the bytes that appear on the wire. RFC 4086 [RFC4086] discusses what // entails a suitable source of entropy for security-sensitive // applications. +#if NET45 + // Normally we don't group methods and fields like this but I want to centralize the #if :) + private static readonly RandomNumberGenerator _rng = new RNGCryptoServiceProvider(); private int GetNextMask() { if (_useZeroMask) @@ -126,9 +113,15 @@ namespace Microsoft.AspNet.WebSockets.Protocol // Get 32-bits of randomness and convert it to an int var buffer = new byte[sizeof(int)]; - GetRandomBytes(buffer); + _rng.GetBytes(buffer); return BitConverter.ToInt32(buffer, 0); } +#else + private int GetNextMask() + { + throw new PlatformNotSupportedException("The WebSocket client is not supported on this platform."); + } +#endif public override async Task SendAsync(ArraySegment buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken) { From 1c50ec7166438cc67ba49764735cb3b4d4c1d5ac Mon Sep 17 00:00:00 2001 From: anurse Date: Mon, 29 Jun 2015 12:21:46 -0700 Subject: [PATCH 122/453] clean-up --- src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs index a63800c536..2c9c53bb7f 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs @@ -6,7 +6,6 @@ using System.Diagnostics.Contracts; using System.IO; using System.Linq; using System.Net.WebSockets; -using System.Security.Cryptography; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -103,7 +102,8 @@ namespace Microsoft.AspNet.WebSockets.Protocol // applications. #if NET45 // Normally we don't group methods and fields like this but I want to centralize the #if :) - private static readonly RandomNumberGenerator _rng = new RNGCryptoServiceProvider(); + // Same for using full namespace names. + private static readonly System.Security.Cryptography.RandomNumberGenerator _rng = new System.Security.Cryptography.RNGCryptoServiceProvider(); private int GetNextMask() { if (_useZeroMask) From f65ad82c6baf52ed679159b4d317ec857e90028f Mon Sep 17 00:00:00 2001 From: anurse Date: Mon, 29 Jun 2015 12:39:57 -0700 Subject: [PATCH 123/453] use the factory method to create RNG --- .../CommonWebSocket.cs | 12 ++---------- .../project.json | 1 + 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs index 2c9c53bb7f..f7e803ab08 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs @@ -6,6 +6,7 @@ using System.Diagnostics.Contracts; using System.IO; using System.Linq; using System.Net.WebSockets; +using System.Security.Cryptography; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -16,6 +17,7 @@ namespace Microsoft.AspNet.WebSockets.Protocol public class CommonWebSocket : WebSocket { private readonly static byte[] PingBuffer = Encoding.ASCII.GetBytes("abcdefghijklmnopqrstuvwxyz"); + private static readonly RandomNumberGenerator _rng = RandomNumberGenerator.Create(); private readonly Stream _stream; private readonly string _subProtocl; @@ -100,10 +102,6 @@ namespace Microsoft.AspNet.WebSockets.Protocol // the bytes that appear on the wire. RFC 4086 [RFC4086] discusses what // entails a suitable source of entropy for security-sensitive // applications. -#if NET45 - // Normally we don't group methods and fields like this but I want to centralize the #if :) - // Same for using full namespace names. - private static readonly System.Security.Cryptography.RandomNumberGenerator _rng = new System.Security.Cryptography.RNGCryptoServiceProvider(); private int GetNextMask() { if (_useZeroMask) @@ -116,12 +114,6 @@ namespace Microsoft.AspNet.WebSockets.Protocol _rng.GetBytes(buffer); return BitConverter.ToInt32(buffer, 0); } -#else - private int GetNextMask() - { - throw new PlatformNotSupportedException("The WebSocket client is not supported on this platform."); - } -#endif public override async Task SendAsync(ArraySegment buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken) { diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index ae5cd3be66..2a29888541 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -18,6 +18,7 @@ "System.Security.Cryptography.Encryption": "4.0.0-beta-*", "System.Security.Cryptography.Hashing": "4.0.0-beta-*", "System.Security.Cryptography.Hashing.Algorithms": "4.0.0-beta-*", + "System.Security.Cryptography.RandomNumberGenerator": "4.0.0-beta-*", "System.Text.Encoding.Extensions": "4.0.10-beta-*", "System.Threading": "4.0.10-beta-*", "System.Threading.Tasks": "4.0.10-beta-*", From 6438362e0a6c9c1f7db33dff78a9ec408d76f9df Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Wed, 1 Jul 2015 20:34:07 -0700 Subject: [PATCH 124/453] Add repository information to project files --- src/Microsoft.AspNet.WebSockets.Client/project.json | 4 ++++ src/Microsoft.AspNet.WebSockets.Protocol/project.json | 4 ++++ src/Microsoft.AspNet.WebSockets.Server/project.json | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/src/Microsoft.AspNet.WebSockets.Client/project.json b/src/Microsoft.AspNet.WebSockets.Client/project.json index 4fb8819f32..5e6c360503 100644 --- a/src/Microsoft.AspNet.WebSockets.Client/project.json +++ b/src/Microsoft.AspNet.WebSockets.Client/project.json @@ -1,6 +1,10 @@ { "version": "1.0.0-*", "description": "Client for communicating over web sockets.", + "repository": { + "type": "git", + "url": "git://github.com/aspnet/websockets" + }, "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*" }, diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index 2a29888541..17d05ea979 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -1,6 +1,10 @@ { "version": "1.0.0-*", "description": "Managed web socket protocol parser.", + "repository": { + "type": "git", + "url": "git://github.com/aspnet/websockets" + }, "dependencies": { "Microsoft.Framework.NotNullAttribute.Sources": { "type": "build", "version": "1.0.0-*" } }, diff --git a/src/Microsoft.AspNet.WebSockets.Server/project.json b/src/Microsoft.AspNet.WebSockets.Server/project.json index 51fab63e5e..1818c554a4 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/project.json +++ b/src/Microsoft.AspNet.WebSockets.Server/project.json @@ -1,6 +1,10 @@ { "version": "1.0.0-*", "description": "ASP.NET 5 web socket middleware for use on top of opaque servers.", + "repository": { + "type": "git", + "url": "git://github.com/aspnet/websockets" + }, "dependencies": { "Microsoft.AspNet.Http": "1.0.0-*", "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*" From be3275d4a511059bc7f74d856a7e9d06746f2f6b Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 16 Jul 2015 09:01:55 -0700 Subject: [PATCH 125/453] Updating to release NuGet.config --- NuGet.Config | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index da57d47267..0e74a4912d 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,8 @@  - + + - \ No newline at end of file + From 6e45aecbc62273ee623d09c780821ded66f60a7a Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Fri, 24 Jul 2015 08:54:49 -0700 Subject: [PATCH 126/453] Update KestrelWebSocketHelpers.cs Fixing build break. --- .../KestrelWebSocketHelpers.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index 9ebe9e3e24..7d02293b03 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -8,6 +8,7 @@ using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Hosting.Startup; using Microsoft.AspNet.Http; using Microsoft.Framework.Configuration; +using Microsoft.Framework.Configuration.Memory; using Microsoft.Framework.Runtime.Infrastructure; namespace Microsoft.AspNet.WebSockets.Client.Test From 50612d7d7484df9e07231dc43bf3f7e1cafb9ae6 Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Wed, 29 Jul 2015 02:05:08 -0700 Subject: [PATCH 127/453] React to DNX renames --- .../KestrelWebSocketHelpers.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index 7d02293b03..2b751347f6 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -5,11 +5,10 @@ using System; using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.Hosting.Startup; using Microsoft.AspNet.Http; +using Microsoft.Dnx.Runtime.Infrastructure; using Microsoft.Framework.Configuration; using Microsoft.Framework.Configuration.Memory; -using Microsoft.Framework.Runtime.Infrastructure; namespace Microsoft.AspNet.WebSockets.Client.Test { From e174d2e154795c0de3fb978fb8342cd8e3ca9cae Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Tue, 4 Aug 2015 10:15:38 -0700 Subject: [PATCH 128/453] Update CoreCLR versions --- .../project.json | 20 +++++++++---------- .../project.json | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index 17d05ea979..31b239686d 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -12,21 +12,21 @@ "net45": { }, "dnxcore50": { "dependencies": { - "System.Diagnostics.Contracts": "4.0.0-beta-*", - "System.IO": "4.0.10-beta-*", - "System.Linq": "4.0.0-beta-*", + "System.Diagnostics.Contracts": "4.0.1-beta-*", + "System.IO": "4.0.11-beta-*", + "System.Linq": "4.0.1-beta-*", "System.Net.WebSockets": "4.0.0-beta-*", - "System.Runtime": "4.0.20-beta-*", - "System.Runtime.InteropServices": "4.0.20-beta-*", - "System.Runtime.Extensions": "4.0.10-beta-*", + "System.Runtime": "4.0.21-beta-*", + "System.Runtime.InteropServices": "4.0.21-beta-*", + "System.Runtime.Extensions": "4.0.11-beta-*", "System.Security.Cryptography.Encryption": "4.0.0-beta-*", "System.Security.Cryptography.Hashing": "4.0.0-beta-*", "System.Security.Cryptography.Hashing.Algorithms": "4.0.0-beta-*", "System.Security.Cryptography.RandomNumberGenerator": "4.0.0-beta-*", - "System.Text.Encoding.Extensions": "4.0.10-beta-*", - "System.Threading": "4.0.10-beta-*", - "System.Threading.Tasks": "4.0.10-beta-*", - "System.Threading.Timer": "4.0.0-beta-*" + "System.Text.Encoding.Extensions": "4.0.11-beta-*", + "System.Threading": "4.0.11-beta-*", + "System.Threading.Tasks": "4.0.11-beta-*", + "System.Threading.Timer": "4.0.1-beta-*" } } } diff --git a/src/Microsoft.AspNet.WebSockets.Server/project.json b/src/Microsoft.AspNet.WebSockets.Server/project.json index 1818c554a4..e2b82ebb9d 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/project.json +++ b/src/Microsoft.AspNet.WebSockets.Server/project.json @@ -13,7 +13,7 @@ "dnx451": { }, "dnxcore50": { "dependencies": { - "System.Runtime": "4.0.20-beta-*" + "System.Runtime": "4.0.21-beta-*" } } } From b51cf63637d1a56e6d05d5b063ba23b9647022b6 Mon Sep 17 00:00:00 2001 From: Chris R Date: Tue, 11 Aug 2015 14:43:06 -0700 Subject: [PATCH 129/453] #49 React to CoreCLR Cryptography package changes. --- src/Microsoft.AspNet.WebSockets.Protocol/project.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index 31b239686d..74e06c88de 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -19,10 +19,7 @@ "System.Runtime": "4.0.21-beta-*", "System.Runtime.InteropServices": "4.0.21-beta-*", "System.Runtime.Extensions": "4.0.11-beta-*", - "System.Security.Cryptography.Encryption": "4.0.0-beta-*", - "System.Security.Cryptography.Hashing": "4.0.0-beta-*", - "System.Security.Cryptography.Hashing.Algorithms": "4.0.0-beta-*", - "System.Security.Cryptography.RandomNumberGenerator": "4.0.0-beta-*", + "System.Security.Cryptography.Algorithms": "4.0.0-beta-*", "System.Text.Encoding.Extensions": "4.0.11-beta-*", "System.Threading": "4.0.11-beta-*", "System.Threading.Tasks": "4.0.11-beta-*", From 6474c9934393cd019a1c136de694126f8c8ff390 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Wed, 12 Aug 2015 05:37:36 -0700 Subject: [PATCH 130/453] Enable pinning build script --- build.cmd | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/build.cmd b/build.cmd index 41025afb26..ccf195aee8 100644 --- a/build.cmd +++ b/build.cmd @@ -3,6 +3,8 @@ cd %~dp0 SETLOCAL SET CACHED_NUGET=%LocalAppData%\NuGet\NuGet.exe +SET BUILDCMD_KOREBUILD_VERSION="" +SET BUILDCMD_DNX_VERSION="" IF EXIST %CACHED_NUGET% goto copynuget echo Downloading latest version of NuGet.exe... @@ -16,13 +18,21 @@ copy %CACHED_NUGET% .nuget\nuget.exe > nul :restore IF EXIST packages\KoreBuild goto run -.nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre +IF %BUILDCMD_KOREBUILD_VERSION%=="" ( + .nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre +) ELSE ( + .nuget\NuGet.exe install KoreBuild -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre +) .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion IF "%SKIP_DNX_INSTALL%"=="1" goto run -CALL packages\KoreBuild\build\dnvm upgrade -runtime CLR -arch x86 +IF %BUILDCMD_DNX_VERSION%=="" ( + CALL packages\KoreBuild\build\dnvm upgrade -runtime CLR -arch x86 +) ELSE ( + CALL packages\KoreBuild\build\dnvm install %BUILDCMD_DNX_VERSION% -runtime CLR -arch x86 -a default +) CALL packages\KoreBuild\build\dnvm install default -runtime CoreCLR -arch x86 :run CALL packages\KoreBuild\build\dnvm use default -runtime CLR -arch x86 -packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* +packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* \ No newline at end of file From e2be1a164fe271931a3728cf1e5edb3f6f5feb0a Mon Sep 17 00:00:00 2001 From: Stephen Halter Date: Wed, 12 Aug 2015 11:55:36 -0700 Subject: [PATCH 131/453] React to Kestrel rename aspnet/KestrelHttpServer#11 --- test/AutobahnTestServer/Project.json | 4 ++-- .../KestrelWebSocketHelpers.cs | 2 +- test/Microsoft.AspNet.WebSockets.Client.Test/project.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/AutobahnTestServer/Project.json b/test/AutobahnTestServer/Project.json index cb434f8072..84d418c1db 100644 --- a/test/AutobahnTestServer/Project.json +++ b/test/AutobahnTestServer/Project.json @@ -5,11 +5,11 @@ "Microsoft.AspNet.Server.IIS": "1.0.0-*", "Microsoft.AspNet.Server.WebListener": "1.0.0-*", "Microsoft.AspNet.WebSockets.Server": "1.0.0-*", - "Kestrel": "1.0.0-*" + "Microsoft.AspNet.Server.Kestrel": "1.0.0-*" }, "commands": { "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:12345", - "kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:12344" + "kestrel": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:12344" }, "frameworks" : { "dnx451" : { }, diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index 2b751347f6..0158c24cce 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -48,7 +48,7 @@ namespace Microsoft.AspNet.WebSockets.Client.Test config.Set("server.urls", "http://localhost:54321"); var host = new WebHostBuilder(CallContextServiceLocator.Locator.ServiceProvider, config) - .UseServer("Kestrel") + .UseServer("Microsoft.AspNet.Server.Kestrel") .UseStartup(startup) .Build(); diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json index c0d28348f2..3ae8fee114 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json @@ -3,7 +3,7 @@ "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", "Microsoft.AspNet.WebSockets.Client": "1.0.0-*", "Microsoft.AspNet.WebSockets.Server": "1.0.0-*", - "Kestrel": "1.0.0-*", + "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", "xunit.runner.aspnet": "2.0.0-aspnet-*" }, "frameworks": { From d487a709e54e3374e38d1a8fd2bed8498b6175cf Mon Sep 17 00:00:00 2001 From: Kirthi Krishnamraju Date: Fri, 14 Aug 2015 10:04:49 -0700 Subject: [PATCH 132/453] fix build break due to aspnet/configuration #246 --- .../KestrelWebSocketHelpers.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index 0158c24cce..0a4546148f 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -45,7 +45,7 @@ namespace Microsoft.AspNet.WebSockets.Client.Test var configBuilder = new ConfigurationBuilder(); configBuilder.Add(new MemoryConfigurationSource()); var config = configBuilder.Build(); - config.Set("server.urls", "http://localhost:54321"); + config["server.urls"] = "http://localhost:54321"; var host = new WebHostBuilder(CallContextServiceLocator.Locator.ServiceProvider, config) .UseServer("Microsoft.AspNet.Server.Kestrel") From 412b4b9d69b29437a08dbfe045b1701967e2c755 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Sat, 15 Aug 2015 03:25:42 -0700 Subject: [PATCH 133/453] Use the same libuv install script on travis as kestrel --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index 947bf868ee..1218a0fc0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,12 @@ language: csharp sudo: false +install: + - curl -sSL https://github.com/libuv/libuv/archive/v1.4.2.tar.gz | tar zxfv - -C /tmp && cd /tmp/libuv-1.4.2/ + - sh autogen.sh + - ./configure --prefix=$HOME/libuvinstall + - make + - make install + - export LD_LIBRARY_PATH="$HOME/libuvinstall/lib" + - cd $OLDPWD script: - ./build.sh --quiet verify \ No newline at end of file From 4b7c990b3eaf6949abd8efbdddf8833f8cc05d2e Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 17 Aug 2015 14:49:21 -0700 Subject: [PATCH 134/453] Updating to release NuGet.config. --- NuGet.Config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index da57d47267..3b8d545754 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@ - + - + \ No newline at end of file From c3825f86c399e19338810c18825e1c84f9439f17 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 18 Aug 2015 14:00:26 -0700 Subject: [PATCH 135/453] Updating to aspnetliterelease. --- NuGet.Config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index 3b8d545754..e2378fe359 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@ - + \ No newline at end of file From c3c3b7791b1aaec6d6921377fbff104f586e99ba Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 18 Aug 2015 14:00:27 -0700 Subject: [PATCH 136/453] Updating to aspnetlitedev. --- NuGet.Config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index da57d47267..6685c5330a 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@ - + - + \ No newline at end of file From a9365e48c277267882d7164f4a2d9d710fddc984 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Wed, 19 Aug 2015 14:55:07 -0700 Subject: [PATCH 137/453] Update NuGet feed from v2 => v3. --- NuGet.Config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index 6685c5330a..10cec18a32 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -2,6 +2,6 @@ - + \ No newline at end of file From e43e3c7b5234a3f3b0a36a4dcb6e558bac3b35b4 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Thu, 20 Aug 2015 15:38:31 -0700 Subject: [PATCH 138/453] Update 'build.cmd' to pull Sake from v2 NuGet feed. --- build.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cmd b/build.cmd index ccf195aee8..b54d91cf74 100644 --- a/build.cmd +++ b/build.cmd @@ -23,7 +23,7 @@ IF %BUILDCMD_KOREBUILD_VERSION%=="" ( ) ELSE ( .nuget\NuGet.exe install KoreBuild -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre ) -.nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion +.nuget\NuGet.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages IF "%SKIP_DNX_INSTALL%"=="1" goto run IF %BUILDCMD_DNX_VERSION%=="" ( From ad0dbe73143814e1abe38549c243c4e484a2e551 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Thu, 20 Aug 2015 20:47:37 -0700 Subject: [PATCH 139/453] Update 'build.sh' to pull Sake from v2 NuGet feed. --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 3ef874f9bd..68c3e8cb52 100755 --- a/build.sh +++ b/build.sh @@ -24,7 +24,7 @@ fi if test ! -d packages/KoreBuild; then mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre - mono .nuget/nuget.exe install Sake -version 0.2 -o packages -ExcludeVersion + mono .nuget/nuget.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages fi if ! type dnvm > /dev/null 2>&1; then From 02fefd8b3158dbea3aca4de141330f0a804d5e8e Mon Sep 17 00:00:00 2001 From: Anthony van der Hoorn Date: Thu, 20 Aug 2015 13:33:19 -0700 Subject: [PATCH 140/453] Fix problem with client not connecting on the correct port --- test/TestClient/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/TestClient/Program.cs b/test/TestClient/Program.cs index a268f1000e..37072d144d 100644 --- a/test/TestClient/Program.cs +++ b/test/TestClient/Program.cs @@ -26,7 +26,7 @@ namespace TestClient private static async Task RunTestAsync() { WebSocketClient client = new WebSocketClient(); - WebSocket socket = await client.ConnectAsync(new Uri("ws://localhost:8080/"), CancellationToken.None); + WebSocket socket = await client.ConnectAsync(new Uri("ws://localhost:12345/"), CancellationToken.None); byte[] data = new byte[100]; // Encoding.UTF8.GetBytes( // TODO: Hangs after 10 seconds // "Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World" From a984ea77a8c58df6aa703b5c615e451eac9f20b5 Mon Sep 17 00:00:00 2001 From: Anthony van der Hoorn Date: Thu, 20 Aug 2015 13:40:07 -0700 Subject: [PATCH 141/453] Switch over target on which server is open for --- test/TestServer/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/TestServer/Program.cs b/test/TestServer/Program.cs index c3c9384aab..b365247e40 100644 --- a/test/TestServer/Program.cs +++ b/test/TestServer/Program.cs @@ -19,7 +19,7 @@ namespace TestServer private static async Task RunEchoServer() { HttpListener listener = new HttpListener(); - listener.Prefixes.Add("http://*:12345/"); + listener.Prefixes.Add("http://localhost:12345/"); listener.Start(); Console.WriteLine("Started"); From 92dc38ffd1f6727c921aaef9e3f3f9b7fbfb0d44 Mon Sep 17 00:00:00 2001 From: Anthony van der Hoorn Date: Thu, 20 Aug 2015 12:52:53 -0700 Subject: [PATCH 142/453] Missing "commands" from project.json This was stopping the project running in VS --- test/TestClient/project.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/TestClient/project.json b/test/TestClient/project.json index f4c2b0131d..2c1c4ae5e9 100644 --- a/test/TestClient/project.json +++ b/test/TestClient/project.json @@ -1,4 +1,7 @@ { + "commands": { + "TestClient": "TestClient" + }, "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", "Microsoft.AspNet.WebSockets.Client": "1.0.0-*" From 821f470bb5fed7bdcb188cfd295b5748d7b2a74b Mon Sep 17 00:00:00 2001 From: Chris R Date: Fri, 28 Aug 2015 14:40:15 -0700 Subject: [PATCH 143/453] React to string[] -> StringValues changes. --- src/Microsoft.AspNet.WebSockets.Server/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.WebSockets.Server/project.json b/src/Microsoft.AspNet.WebSockets.Server/project.json index e2b82ebb9d..05c6020ea6 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/project.json +++ b/src/Microsoft.AspNet.WebSockets.Server/project.json @@ -6,7 +6,7 @@ "url": "git://github.com/aspnet/websockets" }, "dependencies": { - "Microsoft.AspNet.Http": "1.0.0-*", + "Microsoft.AspNet.Http.Extensions": "1.0.0-*", "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*" }, "frameworks": { From 6bc7df851fde79cb58ff594eb16a62f21401511c Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 31 Aug 2015 09:45:21 -0700 Subject: [PATCH 144/453] Use new HttpContext.Features API. --- .../WebSocketMiddleware.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs index 8d13d9be0e..c3c48d91e9 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs @@ -29,12 +29,12 @@ namespace Microsoft.AspNet.WebSockets.Server public Task Invoke(HttpContext context) { // Detect if an opaque upgrade is available. If so, add a websocket upgrade. - var upgradeFeature = context.GetFeature(); + var upgradeFeature = context.Features.Get(); if (upgradeFeature != null) { - if (_options.ReplaceFeature || context.GetFeature() == null) + if (_options.ReplaceFeature || context.Features.Get() == null) { - context.SetFeature(new UpgradeHandshake(context, upgradeFeature, _options)); + context.Features.Set(new UpgradeHandshake(context, upgradeFeature, _options)); } } From 0ab178cead2073c64f5f9f913cf52344c635054c Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 3 Sep 2015 16:20:52 -0700 Subject: [PATCH 145/453] Ignore WebSocketClient tests on Mono. --- .../WebSocketClientTests.cs | 55 +++++++++++++------ .../project.json | 1 + 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/WebSocketClientTests.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/WebSocketClientTests.cs index 9f298a9dbb..1d5ccf1f58 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/WebSocketClientTests.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/WebSocketClientTests.cs @@ -6,6 +6,7 @@ using System.Net.WebSockets; using System.Text; using System.Threading; using System.Threading.Tasks; +using Microsoft.AspNet.Testing.xunit; using Xunit; namespace Microsoft.AspNet.WebSockets.Client.Test @@ -14,7 +15,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test { private static string ClientAddress = "ws://localhost:54321/"; - [Fact] + [ConditionalFact] + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task Connect_Success() { using (var server = KestrelWebSocketHelpers.CreateServer(async context => @@ -30,7 +32,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test } } - [Fact] + [ConditionalFact] + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task NegotiateSubProtocol_Success() { using (var server = KestrelWebSocketHelpers.CreateServer(async context => @@ -51,7 +54,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test } } - [Fact] + [ConditionalFact] + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task SendEmptyData_Success() { using (var server = KestrelWebSocketHelpers.CreateServer(async context => @@ -75,7 +79,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test } } - [Fact] + [ConditionalFact] + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task SendShortData_Success() { var orriginalData = Encoding.UTF8.GetBytes("Hello World"); @@ -100,7 +105,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test } } - [Fact] + [ConditionalFact] + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task SendMediumData_Success() { var orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); @@ -125,7 +131,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test } } - [Fact] + [ConditionalFact] + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task SendLongData_Success() { var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); @@ -162,7 +169,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test } } - [Fact] + [ConditionalFact] + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task SendFragmentedData_Success() { var orriginalData = Encoding.UTF8.GetBytes("Hello World"); @@ -205,7 +213,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test } } - [Fact] + [ConditionalFact] + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ReceiveEmptyData_Success() { var orriginalData = Encoding.UTF8.GetBytes("Hello World"); @@ -229,7 +238,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test } } - [Fact] + [ConditionalFact] + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ReceiveShortData_Success() { var orriginalData = Encoding.UTF8.GetBytes("Hello World"); @@ -254,7 +264,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test } } - [Fact] + [ConditionalFact] + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ReceiveMediumData_Success() { var orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); @@ -279,7 +290,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test } } - [Fact] + [ConditionalFact] + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ReceiveLongDataInSmallBuffer_Success() { var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); @@ -312,7 +324,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test } } - [Fact] + [ConditionalFact] + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ReceiveLongDataInLargeBuffer_Success() { var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); @@ -337,7 +350,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test } } - [Fact] + [ConditionalFact] + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ReceiveFragmentedData_Success() { var orriginalData = Encoding.UTF8.GetBytes("Hello World"); @@ -380,7 +394,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test } } - [Fact] + [ConditionalFact] + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task SendClose_Success() { string closeDescription = "Test Closed"; @@ -408,7 +423,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test } } - [Fact] + [ConditionalFact] + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ReceiveClose_Success() { string closeDescription = "Test Closed"; @@ -436,7 +452,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test } } - [Fact] + [ConditionalFact] + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task CloseFromOpen_Success() { string closeDescription = "Test Closed"; @@ -466,7 +483,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test } } - [Fact] + [ConditionalFact] + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task CloseFromCloseSent_Success() { string closeDescription = "Test Closed"; @@ -498,7 +516,8 @@ namespace Microsoft.AspNet.WebSockets.Client.Test } } - [Fact] + [ConditionalFact] + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task CloseFromCloseReceived_Success() { string closeDescription = "Test Closed"; diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json index 3ae8fee114..9ffd597ef0 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/project.json @@ -4,6 +4,7 @@ "Microsoft.AspNet.WebSockets.Client": "1.0.0-*", "Microsoft.AspNet.WebSockets.Server": "1.0.0-*", "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", + "Microsoft.AspNet.Testing": "1.0.0-*", "xunit.runner.aspnet": "2.0.0-aspnet-*" }, "frameworks": { From 98af679b0bfc0c1862f6102a270976cf5d778a1a Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 10 Sep 2015 18:45:23 -0700 Subject: [PATCH 146/453] Adding NeutralResourcesLanguageAttribute --- .../Properties/AssemblyInfo.cs | 4 +++- .../Properties/AssemblyInfo.cs | 2 ++ .../Properties/AssemblyInfo.cs | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Client/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.WebSockets.Client/Properties/AssemblyInfo.cs index 025a94598c..b2437d9ad6 100644 --- a/src/Microsoft.AspNet.WebSockets.Client/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNet.WebSockets.Client/Properties/AssemblyInfo.cs @@ -2,5 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Reflection; +using System.Resources; -[assembly: AssemblyMetadata("Serviceable", "True")] \ No newline at end of file +[assembly: AssemblyMetadata("Serviceable", "True")] +[assembly: NeutralResourcesLanguage("en-us")] \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.WebSockets.Protocol/Properties/AssemblyInfo.cs index f2450e304f..1a71cec2c5 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/Properties/AssemblyInfo.cs @@ -1,4 +1,5 @@ using System.Reflection; +using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -35,3 +36,4 @@ using System.Runtime.InteropServices; [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyMetadata("Serviceable", "True")] +[assembly: NeutralResourcesLanguage("en-us")] diff --git a/src/Microsoft.AspNet.WebSockets.Server/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.WebSockets.Server/Properties/AssemblyInfo.cs index 025a94598c..b2437d9ad6 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/Properties/AssemblyInfo.cs @@ -2,5 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Reflection; +using System.Resources; -[assembly: AssemblyMetadata("Serviceable", "True")] \ No newline at end of file +[assembly: AssemblyMetadata("Serviceable", "True")] +[assembly: NeutralResourcesLanguage("en-us")] \ No newline at end of file From 3f8b94b9bbff6b4e6ee32697c051382543cf05e4 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Thu, 17 Sep 2015 18:33:38 -0700 Subject: [PATCH 147/453] Update nuget.exe and corresponding feeds to v3. --- NuGet.Config => NuGet.config | 2 +- build.cmd | 11 ++++++----- build.sh | 12 +++++++----- 3 files changed, 14 insertions(+), 11 deletions(-) rename NuGet.Config => NuGet.config (83%) diff --git a/NuGet.Config b/NuGet.config similarity index 83% rename from NuGet.Config rename to NuGet.config index 10cec18a32..1707938c61 100644 --- a/NuGet.Config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + \ No newline at end of file diff --git a/build.cmd b/build.cmd index b54d91cf74..177997c42e 100644 --- a/build.cmd +++ b/build.cmd @@ -2,14 +2,15 @@ cd %~dp0 SETLOCAL -SET CACHED_NUGET=%LocalAppData%\NuGet\NuGet.exe +SET NUGET_VERSION=latest +SET CACHED_NUGET=%LocalAppData%\NuGet\nuget.%NUGET_VERSION%.exe SET BUILDCMD_KOREBUILD_VERSION="" SET BUILDCMD_DNX_VERSION="" IF EXIST %CACHED_NUGET% goto copynuget echo Downloading latest version of NuGet.exe... IF NOT EXIST %LocalAppData%\NuGet md %LocalAppData%\NuGet -@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://www.nuget.org/nuget.exe' -OutFile '%CACHED_NUGET%'" +@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/%NUGET_VERSION%/nuget.exe' -OutFile '%CACHED_NUGET%'" :copynuget IF EXIST .nuget\nuget.exe goto restore @@ -19,11 +20,11 @@ copy %CACHED_NUGET% .nuget\nuget.exe > nul :restore IF EXIST packages\KoreBuild goto run IF %BUILDCMD_KOREBUILD_VERSION%=="" ( - .nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre + .nuget\nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre ) ELSE ( - .nuget\NuGet.exe install KoreBuild -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre + .nuget\nuget.exe install KoreBuild -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre ) -.nuget\NuGet.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages +.nuget\nuget.exe install Sake -ExcludeVersion -Out packages IF "%SKIP_DNX_INSTALL%"=="1" goto run IF %BUILDCMD_DNX_VERSION%=="" ( diff --git a/build.sh b/build.sh index 68c3e8cb52..0c66139817 100755 --- a/build.sh +++ b/build.sh @@ -10,21 +10,23 @@ else fi fi mkdir -p $cachedir +nugetVersion=latest +cachePath=$cachedir/nuget.$nugetVersion.exe -url=https://www.nuget.org/nuget.exe +url=https://dist.nuget.org/win-x86-commandline/$nugetVersion/nuget.exe -if test ! -f $cachedir/nuget.exe; then - wget -O $cachedir/nuget.exe $url 2>/dev/null || curl -o $cachedir/nuget.exe --location $url /dev/null +if test ! -f $cachePath; then + wget -O $cachePath $url 2>/dev/null || curl -o $cachePath --location $url /dev/null fi if test ! -e .nuget; then mkdir .nuget - cp $cachedir/nuget.exe .nuget/nuget.exe + cp $cachePath .nuget/nuget.exe fi if test ! -d packages/KoreBuild; then mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre - mono .nuget/nuget.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages + mono .nuget/nuget.exe install Sake -ExcludeVersion -Out packages fi if ! type dnvm > /dev/null 2>&1; then From 9b1558dddddb3ccefa4cae6a51d612e9aa1d9bbc Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Wed, 23 Sep 2015 14:56:00 -0700 Subject: [PATCH 148/453] Enabling NuGetPackageVerifier --- NuGetPackageVerifier.json | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 NuGetPackageVerifier.json diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json new file mode 100644 index 0000000000..fb6dff2589 --- /dev/null +++ b/NuGetPackageVerifier.json @@ -0,0 +1,27 @@ +{ + "adx": { // Packages written by the ADX team and that ship on NuGet.org + "rules": [ + "AssemblyHasDocumentFileRule", + "AssemblyHasVersionAttributesRule", + "AssemblyHasServicingAttributeRule", + "AssemblyHasNeutralResourcesLanguageAttributeRule", + "SatellitePackageRule", + "StrictSemanticVersionValidationRule" + ], + "packages": { + "Microsoft.AspNet.WebSockets.Client": { }, + "Microsoft.AspNet.WebSockets.Protocol": { }, + "Microsoft.AspNet.WebSockets.Server": { } + } + }, + "Default": { // Ru les to run for packages not listed in any other set. + "rules": [ + "AssemblyHasDocumentFileRule", + "AssemblyHasVersionAttributesRule", + "AssemblyHasServicingAttributeRule", + "AssemblyHasNeutralResourcesLanguageAttributeRule", + "SatellitePackageRule", + "StrictSemanticVersionValidationRule" + ] + } +} \ No newline at end of file From 822ee7caf8661a9cababfe3fd795bad302971845 Mon Sep 17 00:00:00 2001 From: Chris R Date: Fri, 25 Sep 2015 20:54:56 -0700 Subject: [PATCH 149/453] React to configuration API changes. --- .../KestrelWebSocketHelpers.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index 0a4546148f..fe12587685 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -8,7 +8,6 @@ using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; using Microsoft.Dnx.Runtime.Infrastructure; using Microsoft.Framework.Configuration; -using Microsoft.Framework.Configuration.Memory; namespace Microsoft.AspNet.WebSockets.Client.Test { @@ -43,7 +42,7 @@ namespace Microsoft.AspNet.WebSockets.Client.Test }; var configBuilder = new ConfigurationBuilder(); - configBuilder.Add(new MemoryConfigurationSource()); + configBuilder.AddInMemoryCollection(); var config = configBuilder.Build(); config["server.urls"] = "http://localhost:54321"; From 8930b6474cab7fb67453ada4ea5a625baffa8c0f Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 28 Sep 2015 23:16:08 -0700 Subject: [PATCH 150/453] Updating to release NuGet.config. --- NuGet.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.config b/NuGet.config index 1707938c61..9db87a421e 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + \ No newline at end of file From 7f7ad3479ab96b3777ab7948b07db2ce9c9f2c15 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Thu, 1 Oct 2015 11:58:52 -0700 Subject: [PATCH 151/453] Update 'build.cmd' alias parameter to use full name. --- build.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cmd b/build.cmd index 177997c42e..70d974a61f 100644 --- a/build.cmd +++ b/build.cmd @@ -30,7 +30,7 @@ IF "%SKIP_DNX_INSTALL%"=="1" goto run IF %BUILDCMD_DNX_VERSION%=="" ( CALL packages\KoreBuild\build\dnvm upgrade -runtime CLR -arch x86 ) ELSE ( - CALL packages\KoreBuild\build\dnvm install %BUILDCMD_DNX_VERSION% -runtime CLR -arch x86 -a default + CALL packages\KoreBuild\build\dnvm install %BUILDCMD_DNX_VERSION% -runtime CLR -arch x86 -alias default ) CALL packages\KoreBuild\build\dnvm install default -runtime CoreCLR -arch x86 From aea8716df6ac1ebaa01abc597c9526c1c13d6aea Mon Sep 17 00:00:00 2001 From: Pranav K Date: Sat, 3 Oct 2015 15:44:48 -0700 Subject: [PATCH 152/453] Renaming Microsoft.Framework.* -> Microsoft.Extensions.* --- src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs | 2 +- src/Microsoft.AspNet.WebSockets.Protocol/project.json | 2 +- .../KestrelWebSocketHelpers.cs | 2 +- test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs | 2 +- test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs b/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs index b3aa119609..3b283232ca 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Security.Cryptography; using System.Text; -using Microsoft.Framework.Internal; +using Microsoft.Extensions.Internal; namespace Microsoft.AspNet.WebSockets.Protocol { diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index 74e06c88de..875c58019f 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -6,7 +6,7 @@ "url": "git://github.com/aspnet/websockets" }, "dependencies": { - "Microsoft.Framework.NotNullAttribute.Sources": { "type": "build", "version": "1.0.0-*" } + "Microsoft.Extensions.NotNullAttribute.Sources": { "type": "build", "version": "1.0.0-*" } }, "frameworks": { "net45": { }, diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index fe12587685..e82f7889a7 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -7,7 +7,7 @@ using Microsoft.AspNet.Builder; using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; using Microsoft.Dnx.Runtime.Infrastructure; -using Microsoft.Framework.Configuration; +using Microsoft.Extensions.Configuration; namespace Microsoft.AspNet.WebSockets.Client.Test { diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs b/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs index e2ff11e792..0e23875e66 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs @@ -7,7 +7,7 @@ using System.Diagnostics.Contracts; using System.IO; using System.Threading; using System.Threading.Tasks; -using Microsoft.Framework.Internal; +using Microsoft.Extensions.Internal; namespace Microsoft.AspNet.WebSockets.Protocol.Test { diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json index 7db25a7abe..d335696765 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json @@ -1,7 +1,7 @@ { "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", - "Microsoft.Framework.NotNullAttribute.Sources": { "type": "build", "version": "1.0.0-*" }, + "Microsoft.Extensions.NotNullAttribute.Sources": { "type": "build", "version": "1.0.0-*" }, "xunit.runner.aspnet": "2.0.0-aspnet-*" }, "frameworks": { From bc6502825f9937c0a6df9d899999808f185a3094 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 7 Oct 2015 17:44:11 -0700 Subject: [PATCH 153/453] Replacing NotNullAttribute with thrown exceptions --- src/Microsoft.AspNet.WebSockets.Client/project.json | 3 +++ .../HandshakeHelpers.cs | 8 ++++++-- src/Microsoft.AspNet.WebSockets.Protocol/project.json | 4 ++-- .../BufferStream.cs | 3 +-- .../project.json | 1 - 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Client/project.json b/src/Microsoft.AspNet.WebSockets.Client/project.json index 5e6c360503..33d5fce580 100644 --- a/src/Microsoft.AspNet.WebSockets.Client/project.json +++ b/src/Microsoft.AspNet.WebSockets.Client/project.json @@ -5,6 +5,9 @@ "type": "git", "url": "git://github.com/aspnet/websockets" }, + "compilationOptions": { + "warningsAsErrors": true + }, "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*" }, diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs b/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs index 3b283232ca..478b61bfe5 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Security.Cryptography; using System.Text; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNet.WebSockets.Protocol { @@ -124,8 +123,13 @@ namespace Microsoft.AspNet.WebSockets.Protocol /// /// /// - public static string CreateResponseKey([NotNull] string requestKey) + public static string CreateResponseKey(string requestKey) { + if (requestKey == null) + { + throw new ArgumentNullException(nameof(requestKey)); + } + using (var algorithm = SHA1.Create()) { string merged = requestKey + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index 875c58019f..75a20b973d 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -5,8 +5,8 @@ "type": "git", "url": "git://github.com/aspnet/websockets" }, - "dependencies": { - "Microsoft.Extensions.NotNullAttribute.Sources": { "type": "build", "version": "1.0.0-*" } + "compilationOptions": { + "warningsAsErrors": true }, "frameworks": { "net45": { }, diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs b/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs index 0e23875e66..f06f4889eb 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs @@ -7,7 +7,6 @@ using System.Diagnostics.Contracts; using System.IO; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNet.WebSockets.Protocol.Test { @@ -256,7 +255,7 @@ namespace Microsoft.AspNet.WebSockets.Protocol.Test return Task.FromResult(null); } - private static void VerifyBuffer([NotNull] byte[] buffer, int offset, int count, bool allowEmpty) + private static void VerifyBuffer(byte[] buffer, int offset, int count, bool allowEmpty) { if (offset < 0 || offset > buffer.Length) { diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json index d335696765..182337015c 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json @@ -1,7 +1,6 @@ { "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", - "Microsoft.Extensions.NotNullAttribute.Sources": { "type": "build", "version": "1.0.0-*" }, "xunit.runner.aspnet": "2.0.0-aspnet-*" }, "frameworks": { From 532b96ddd63c1e870152bc5d07542e93eaec2e3a Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Thu, 8 Oct 2015 19:01:15 -0700 Subject: [PATCH 154/453] React to aspnet/Universe#290 fix --- build.cmd | 25 +++++++++++++------------ build.sh | 12 +++++++----- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/build.cmd b/build.cmd index 70d974a61f..84dc87e480 100644 --- a/build.cmd +++ b/build.cmd @@ -18,22 +18,23 @@ md .nuget copy %CACHED_NUGET% .nuget\nuget.exe > nul :restore -IF EXIST packages\KoreBuild goto run +IF EXIST packages\Sake goto getdnx IF %BUILDCMD_KOREBUILD_VERSION%=="" ( - .nuget\nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre + .nuget\nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre ) ELSE ( - .nuget\nuget.exe install KoreBuild -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre + .nuget\nuget.exe install KoreBuild -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre ) -.nuget\nuget.exe install Sake -ExcludeVersion -Out packages +.nuget\NuGet.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages -IF "%SKIP_DNX_INSTALL%"=="1" goto run -IF %BUILDCMD_DNX_VERSION%=="" ( - CALL packages\KoreBuild\build\dnvm upgrade -runtime CLR -arch x86 +:getdnx +IF "%SKIP_DNX_INSTALL%"=="" ( + IF "%BUILDCMD_DNX_VERSION%"=="" ( + BUILDCMD_DNX_VERSION=latest + ) + CALL packages\KoreBuild\build\dnvm install %BUILDCMD_DNX_VERSION% -runtime CoreCLR -arch x86 -alias default + CALL packages\KoreBuild\build\dnvm install default -runtime CLR -arch x86 -alias default ) ELSE ( - CALL packages\KoreBuild\build\dnvm install %BUILDCMD_DNX_VERSION% -runtime CLR -arch x86 -alias default + CALL packages\KoreBuild\build\dnvm use default -runtime CLR -arch x86 ) -CALL packages\KoreBuild\build\dnvm install default -runtime CoreCLR -arch x86 -:run -CALL packages\KoreBuild\build\dnvm use default -runtime CLR -arch x86 -packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* \ No newline at end of file +packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* diff --git a/build.sh b/build.sh index 0c66139817..da4e3fcd1c 100755 --- a/build.sh +++ b/build.sh @@ -24,18 +24,20 @@ if test ! -e .nuget; then cp $cachePath .nuget/nuget.exe fi -if test ! -d packages/KoreBuild; then +if test ! -d packages/Sake; then mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre - mono .nuget/nuget.exe install Sake -ExcludeVersion -Out packages + mono .nuget/nuget.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages fi if ! type dnvm > /dev/null 2>&1; then source packages/KoreBuild/build/dnvm.sh fi -if ! type dnx > /dev/null 2>&1; then - dnvm upgrade +if ! type dnx > /dev/null 2>&1 || [ -z "$SKIP_DNX_INSTALL" ]; then + dnvm install latest -runtime coreclr -alias default + dnvm install default -runtime mono -alias default +else + dnvm use default -runtime mono fi mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" - From 187221fcd8bc8d61572c35dce3670279f54e74e4 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Mon, 12 Oct 2015 13:06:31 -0700 Subject: [PATCH 155/453] Fix local build break --- build.cmd | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build.cmd b/build.cmd index 84dc87e480..553e3929a0 100644 --- a/build.cmd +++ b/build.cmd @@ -4,8 +4,8 @@ cd %~dp0 SETLOCAL SET NUGET_VERSION=latest SET CACHED_NUGET=%LocalAppData%\NuGet\nuget.%NUGET_VERSION%.exe -SET BUILDCMD_KOREBUILD_VERSION="" -SET BUILDCMD_DNX_VERSION="" +SET BUILDCMD_KOREBUILD_VERSION= +SET BUILDCMD_DNX_VERSION= IF EXIST %CACHED_NUGET% goto copynuget echo Downloading latest version of NuGet.exe... @@ -19,7 +19,7 @@ copy %CACHED_NUGET% .nuget\nuget.exe > nul :restore IF EXIST packages\Sake goto getdnx -IF %BUILDCMD_KOREBUILD_VERSION%=="" ( +IF "%BUILDCMD_KOREBUILD_VERSION%"=="" ( .nuget\nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre ) ELSE ( .nuget\nuget.exe install KoreBuild -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre @@ -27,10 +27,10 @@ IF %BUILDCMD_KOREBUILD_VERSION%=="" ( .nuget\NuGet.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages :getdnx +IF "%BUILDCMD_DNX_VERSION%"=="" ( + SET BUILDCMD_DNX_VERSION=latest +) IF "%SKIP_DNX_INSTALL%"=="" ( - IF "%BUILDCMD_DNX_VERSION%"=="" ( - BUILDCMD_DNX_VERSION=latest - ) CALL packages\KoreBuild\build\dnvm install %BUILDCMD_DNX_VERSION% -runtime CoreCLR -arch x86 -alias default CALL packages\KoreBuild\build\dnvm install default -runtime CLR -arch x86 -alias default ) ELSE ( From f784b1bf433d96e74e4f1fdf98d3eff1a8490560 Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Fri, 16 Oct 2015 16:47:52 -0700 Subject: [PATCH 156/453] Enable Microsoft.AspNet.WebSockets.Protocol.Test on CoreCLR. --- .../BufferStream.cs | 4 ++++ .../DuplexStream.cs | 14 +++++++++----- .../project.json | 5 ++++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs b/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs index f06f4889eb..9d49f8ec10 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs @@ -138,6 +138,7 @@ namespace Microsoft.AspNet.WebSockets.Protocol.Test } } +#if !DNXCORE50 public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { // TODO: This option doesn't preserve the state object. @@ -197,6 +198,7 @@ namespace Microsoft.AspNet.WebSockets.Protocol.Test _readLock.Release(); } } +#endif // Write with count 0 will still trigger OnFirstWrite public override void Write(byte[] buffer, int offset, int count) @@ -224,6 +226,7 @@ namespace Microsoft.AspNet.WebSockets.Protocol.Test } } +#if !DNXCORE50 public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { Write(buffer, offset, count); @@ -254,6 +257,7 @@ namespace Microsoft.AspNet.WebSockets.Protocol.Test Write(buffer, offset, count); return Task.FromResult(null); } +#endif private static void VerifyBuffer(byte[] buffer, int offset, int count, bool allowEmpty) { diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexStream.cs b/test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexStream.cs index 102ccbd0c3..09e87c660f 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexStream.cs +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexStream.cs @@ -93,6 +93,7 @@ namespace Microsoft.AspNet.WebSockets.Protocol.Test return _readStream.Read(buffer, offset, count); } +#if !DNXCORE50 public override int ReadByte() { return _readStream.ReadByte(); @@ -117,6 +118,7 @@ namespace Microsoft.AspNet.WebSockets.Protocol.Test { return _readStream.CopyToAsync(destination, bufferSize, cancellationToken); } +#endif #endregion Read @@ -127,6 +129,7 @@ namespace Microsoft.AspNet.WebSockets.Protocol.Test _writeStream.Write(buffer, offset, count); } +#if !DNXCORE50 public override void WriteByte(byte value) { _writeStream.WriteByte(value); @@ -147,15 +150,16 @@ namespace Microsoft.AspNet.WebSockets.Protocol.Test return _writeStream.WriteAsync(buffer, offset, count, cancellationToken); } - public override void Flush() - { - _writeStream.Flush(); - } - public override Task FlushAsync(CancellationToken cancellationToken) { return _writeStream.FlushAsync(cancellationToken); } +#endif + + public override void Flush() + { + _writeStream.Flush(); + } #endregion Write diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json index 182337015c..8b6e88160a 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json @@ -4,7 +4,10 @@ "xunit.runner.aspnet": "2.0.0-aspnet-*" }, "frameworks": { - "dnx451": { } + "dnx451": { }, + "dnxcore50": { + "System.IO": "4.0.11-beta-*" + } }, "commands": { "test": "xunit.runner.aspnet" From a098b8ce2bb2947e84ccbfb8fa43b8b1e97bd3a3 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 21 Oct 2015 10:49:31 -0700 Subject: [PATCH 157/453] Reach to Hosting changes --- .../KestrelWebSocketHelpers.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index e82f7889a7..6e8d52cb9c 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -46,7 +46,7 @@ namespace Microsoft.AspNet.WebSockets.Client.Test var config = configBuilder.Build(); config["server.urls"] = "http://localhost:54321"; - var host = new WebHostBuilder(CallContextServiceLocator.Locator.ServiceProvider, config) + var host = new WebHostBuilder(config) .UseServer("Microsoft.AspNet.Server.Kestrel") .UseStartup(startup) .Build(); From c3a24cbe72413871ec273a8d220d2e0869b85c4c Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 22 Oct 2015 01:04:17 -0700 Subject: [PATCH 158/453] Switching to generations TFMs --- .../project.json | 32 +++++------ .../project.json | 56 +++++++++---------- .../project.json | 36 ++++++------ 3 files changed, 62 insertions(+), 62 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Client/project.json b/src/Microsoft.AspNet.WebSockets.Client/project.json index 33d5fce580..5a80b8babd 100644 --- a/src/Microsoft.AspNet.WebSockets.Client/project.json +++ b/src/Microsoft.AspNet.WebSockets.Client/project.json @@ -1,17 +1,17 @@ { - "version": "1.0.0-*", - "description": "Client for communicating over web sockets.", - "repository": { - "type": "git", - "url": "git://github.com/aspnet/websockets" - }, - "compilationOptions": { - "warningsAsErrors": true - }, - "dependencies": { - "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*" - }, - "frameworks": { - "net45": { } - } -} + "version": "1.0.0-*", + "description": "Client for communicating over web sockets.", + "repository": { + "type": "git", + "url": "git://github.com/aspnet/websockets" + }, + "compilationOptions": { + "warningsAsErrors": true + }, + "dependencies": { + "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*" + }, + "frameworks": { + "net451": { } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index 75a20b973d..f1e917cc0b 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -1,30 +1,30 @@ { - "version": "1.0.0-*", - "description": "Managed web socket protocol parser.", - "repository": { - "type": "git", - "url": "git://github.com/aspnet/websockets" - }, - "compilationOptions": { - "warningsAsErrors": true - }, - "frameworks": { - "net45": { }, - "dnxcore50": { - "dependencies": { - "System.Diagnostics.Contracts": "4.0.1-beta-*", - "System.IO": "4.0.11-beta-*", - "System.Linq": "4.0.1-beta-*", - "System.Net.WebSockets": "4.0.0-beta-*", - "System.Runtime": "4.0.21-beta-*", - "System.Runtime.InteropServices": "4.0.21-beta-*", - "System.Runtime.Extensions": "4.0.11-beta-*", - "System.Security.Cryptography.Algorithms": "4.0.0-beta-*", - "System.Text.Encoding.Extensions": "4.0.11-beta-*", - "System.Threading": "4.0.11-beta-*", - "System.Threading.Tasks": "4.0.11-beta-*", - "System.Threading.Timer": "4.0.1-beta-*" - } - } + "version": "1.0.0-*", + "description": "Managed web socket protocol parser.", + "repository": { + "type": "git", + "url": "git://github.com/aspnet/websockets" + }, + "compilationOptions": { + "warningsAsErrors": true + }, + "frameworks": { + "net451": {}, + "dotnet5.4": { + "dependencies": { + "System.Diagnostics.Contracts": "4.0.1-beta-*", + "System.IO": "4.0.11-beta-*", + "System.Linq": "4.0.1-beta-*", + "System.Net.WebSockets": "4.0.0-beta-*", + "System.Runtime": "4.0.21-beta-*", + "System.Runtime.InteropServices": "4.0.21-beta-*", + "System.Runtime.Extensions": "4.0.11-beta-*", + "System.Security.Cryptography.Algorithms": "4.0.0-beta-*", + "System.Text.Encoding.Extensions": "4.0.11-beta-*", + "System.Threading": "4.0.11-beta-*", + "System.Threading.Tasks": "4.0.11-beta-*", + "System.Threading.Timer": "4.0.1-beta-*" + } } -} + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebSockets.Server/project.json b/src/Microsoft.AspNet.WebSockets.Server/project.json index 05c6020ea6..57ed313477 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/project.json +++ b/src/Microsoft.AspNet.WebSockets.Server/project.json @@ -1,20 +1,20 @@ { - "version": "1.0.0-*", - "description": "ASP.NET 5 web socket middleware for use on top of opaque servers.", - "repository": { - "type": "git", - "url": "git://github.com/aspnet/websockets" - }, - "dependencies": { - "Microsoft.AspNet.Http.Extensions": "1.0.0-*", - "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*" - }, - "frameworks": { - "dnx451": { }, - "dnxcore50": { - "dependencies": { - "System.Runtime": "4.0.21-beta-*" - } - } + "version": "1.0.0-*", + "description": "ASP.NET 5 web socket middleware for use on top of opaque servers.", + "repository": { + "type": "git", + "url": "git://github.com/aspnet/websockets" + }, + "dependencies": { + "Microsoft.AspNet.Http.Extensions": "1.0.0-*", + "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*" + }, + "frameworks": { + "net451": {}, + "dotnet5.4": { + "dependencies": { + "System.Runtime": "4.0.21-beta-*" + } } -} + } +} \ No newline at end of file From 812609843f23316fb6fb240b4e8433b1e215b957 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Fri, 23 Oct 2015 02:10:08 -0700 Subject: [PATCH 159/453] Removed unused using --- .../KestrelWebSocketHelpers.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index 6e8d52cb9c..4fd33d8eb6 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -6,7 +6,6 @@ using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; -using Microsoft.Dnx.Runtime.Infrastructure; using Microsoft.Extensions.Configuration; namespace Microsoft.AspNet.WebSockets.Client.Test From d0a2a8687ea5b9d11ca4df5fcdc148ee36faf5f7 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 28 Oct 2015 12:43:09 -0700 Subject: [PATCH 160/453] Updating to release NuGet.config. --- NuGet.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.config b/NuGet.config index 1707938c61..9db87a421e 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + \ No newline at end of file From 5f91ce2f2b020d15024bc8aa20508b1296da62a3 Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 30 Oct 2015 16:51:16 -0700 Subject: [PATCH 161/453] Reacting to Hosting changes --- .../KestrelWebSocketHelpers.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index 4fd33d8eb6..d07e108c82 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -46,7 +46,7 @@ namespace Microsoft.AspNet.WebSockets.Client.Test config["server.urls"] = "http://localhost:54321"; var host = new WebHostBuilder(config) - .UseServer("Microsoft.AspNet.Server.Kestrel") + .UseServerFactory("Microsoft.AspNet.Server.Kestrel") .UseStartup(startup) .Build(); From 7770e5f4dbb09d36760f5ed4f6062747ae56829e Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Tue, 3 Nov 2015 12:05:40 -0800 Subject: [PATCH 162/453] Strong name everything. --- .../project.json | 3 ++- .../project.json | 3 ++- .../project.json | 4 ++++ tools/Key.snk | Bin 0 -> 596 bytes 4 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 tools/Key.snk diff --git a/src/Microsoft.AspNet.WebSockets.Client/project.json b/src/Microsoft.AspNet.WebSockets.Client/project.json index 5a80b8babd..87056bc28c 100644 --- a/src/Microsoft.AspNet.WebSockets.Client/project.json +++ b/src/Microsoft.AspNet.WebSockets.Client/project.json @@ -6,7 +6,8 @@ "url": "git://github.com/aspnet/websockets" }, "compilationOptions": { - "warningsAsErrors": true + "warningsAsErrors": true, + "keyFile": "../../tools/Key.snk" }, "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*" diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index f1e917cc0b..0fded7d836 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -6,7 +6,8 @@ "url": "git://github.com/aspnet/websockets" }, "compilationOptions": { - "warningsAsErrors": true + "warningsAsErrors": true, + "keyFile": "../../tools/Key.snk" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNet.WebSockets.Server/project.json b/src/Microsoft.AspNet.WebSockets.Server/project.json index 57ed313477..9e795b8304 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/project.json +++ b/src/Microsoft.AspNet.WebSockets.Server/project.json @@ -1,5 +1,9 @@ { "version": "1.0.0-*", + "compilationOptions": { + "warningsAsErrors": true, + "keyFile": "../../tools/Key.snk" + }, "description": "ASP.NET 5 web socket middleware for use on top of opaque servers.", "repository": { "type": "git", diff --git a/tools/Key.snk b/tools/Key.snk new file mode 100644 index 0000000000000000000000000000000000000000..e10e4889c125d3120cd9e81582243d70f7cbb806 GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50098=Iw=HCsnz~#iVhm& zj%TU(_THUee?3yHBjk$37ysB?i5#7WD$={H zV4B!OxRPrb|8)HPg~A}8P>^=#y<)56#=E&NzcjOtPK~<4n6GHt=K$ro*T(lhby_@U zEk(hLzk1H)0yXj{A_5>fk-TgNoP|q6(tP2xo8zt8i%212CWM#AeCd?`hS|4~L({h~Moo(~vy&3Z z1uI}`fd^*>o=rwbAGymj6RM^pZm(*Kfhs+Y1#`-2JPWZMK8@;ZWCk2+9bX4YP);~fj-BU*R zQPvWv$89!{Rl9wM+zR>_TSkn^voYxA?2G iKnV#iZ6Ah`K>b=@=IjYJXrxL124zR(38)nxe+&q_$QXwJ literal 0 HcmV?d00001 From 37e4a8016016a4534fba765788c57bc821039b7a Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Thu, 12 Nov 2015 12:24:19 -0800 Subject: [PATCH 163/453] Remove System beta tag in project.json for coreclr packages. --- .../project.json | 26 +++++++++---------- .../project.json | 4 +-- .../project.json | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index 0fded7d836..be38440635 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -13,19 +13,19 @@ "net451": {}, "dotnet5.4": { "dependencies": { - "System.Diagnostics.Contracts": "4.0.1-beta-*", - "System.IO": "4.0.11-beta-*", - "System.Linq": "4.0.1-beta-*", - "System.Net.WebSockets": "4.0.0-beta-*", - "System.Runtime": "4.0.21-beta-*", - "System.Runtime.InteropServices": "4.0.21-beta-*", - "System.Runtime.Extensions": "4.0.11-beta-*", - "System.Security.Cryptography.Algorithms": "4.0.0-beta-*", - "System.Text.Encoding.Extensions": "4.0.11-beta-*", - "System.Threading": "4.0.11-beta-*", - "System.Threading.Tasks": "4.0.11-beta-*", - "System.Threading.Timer": "4.0.1-beta-*" + "System.Diagnostics.Contracts": "4.0.1-*", + "System.IO": "4.0.11-*", + "System.Linq": "4.0.1-*", + "System.Net.WebSockets": "4.0.0-*", + "System.Runtime": "4.0.21-*", + "System.Runtime.InteropServices": "4.0.21-*", + "System.Runtime.Extensions": "4.0.11-*", + "System.Security.Cryptography.Algorithms": "4.0.0-*", + "System.Text.Encoding.Extensions": "4.0.11-*", + "System.Threading": "4.0.11-*", + "System.Threading.Tasks": "4.0.11-*", + "System.Threading.Timer": "4.0.1-*" } } } -} \ No newline at end of file +} diff --git a/src/Microsoft.AspNet.WebSockets.Server/project.json b/src/Microsoft.AspNet.WebSockets.Server/project.json index 9e795b8304..358d798eeb 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/project.json +++ b/src/Microsoft.AspNet.WebSockets.Server/project.json @@ -17,8 +17,8 @@ "net451": {}, "dotnet5.4": { "dependencies": { - "System.Runtime": "4.0.21-beta-*" + "System.Runtime": "4.0.21-*" } } } -} \ No newline at end of file +} diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json index 8b6e88160a..9cc3c1ffdc 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json @@ -6,7 +6,7 @@ "frameworks": { "dnx451": { }, "dnxcore50": { - "System.IO": "4.0.11-beta-*" + "System.IO": "4.0.11-*" } }, "commands": { From 10012f4ee2e3c7e9c2b641bec58d0e3a2748ce87 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Tue, 17 Nov 2015 10:33:21 -0800 Subject: [PATCH 164/453] Explicitly choose Mono 4.0.5 - avoids future problems related to aspnet/External#48 - e.g. when Travis updates default Mono version in `csharp` bundle --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 1218a0fc0f..00937eeead 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,5 +8,7 @@ install: - make install - export LD_LIBRARY_PATH="$HOME/libuvinstall/lib" - cd $OLDPWD +mono: + - 4.0.5 script: - ./build.sh --quiet verify \ No newline at end of file From 042b9d26c619eda41129fbf6542683bb02357da3 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Tue, 17 Nov 2015 14:43:24 -0800 Subject: [PATCH 165/453] Move Travis to supported Linux distribution - use Ubuntu 14.04 (Trusty) - Travis support for Trusty is in Beta and currently requires `sudo` - run `dnu restore` with DNX Core since aspnet/External#49 is not fixed in Mono versions we can use - add required dependencies for DNX Core to `.travis.yml` - addresses part of aspnet/Universe#290 --- .travis.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 00937eeead..4965a261c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,17 @@ language: csharp -sudo: false +sudo: required +dist: trusty +addons: + apt: + packages: + - gettext + - libcurl4-openssl-dev + - libicu-dev + - libssl-dev + - libunwind8 + - zlib1g +env: + - KOREBUILD_DNU_RESTORE_CORECLR=true install: - curl -sSL https://github.com/libuv/libuv/archive/v1.4.2.tar.gz | tar zxfv - -C /tmp && cd /tmp/libuv-1.4.2/ - sh autogen.sh @@ -11,4 +23,4 @@ install: mono: - 4.0.5 script: - - ./build.sh --quiet verify \ No newline at end of file + - ./build.sh --quiet verify From 6ad99c5188ef16b6ea0538ca199f325766840b03 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 11 Dec 2015 12:24:16 -0800 Subject: [PATCH 166/453] Updating to release NuGet.config. --- NuGet.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.config b/NuGet.config index 1707938c61..9db87a421e 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + \ No newline at end of file From cb4c05084b2eb3322a8f2c8b190050c57018d414 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 17 Dec 2015 21:21:15 -0800 Subject: [PATCH 167/453] Reacting to new Hosting API --- test/AutobahnTestServer/Project.json | 31 +++++++++---------- test/AutobahnTestServer/Startup.cs | 11 +++++++ test/AutobahnTestServer/hosting.json | 3 ++ .../KestrelWebSocketHelpers.cs | 7 +++-- 4 files changed, 33 insertions(+), 19 deletions(-) create mode 100644 test/AutobahnTestServer/hosting.json diff --git a/test/AutobahnTestServer/Project.json b/test/AutobahnTestServer/Project.json index 84d418c1db..ff0dac2eba 100644 --- a/test/AutobahnTestServer/Project.json +++ b/test/AutobahnTestServer/Project.json @@ -1,18 +1,17 @@ { - "webroot": "wwwroot", - "exclude": "wwwroot/**/*", - "dependencies": { - "Microsoft.AspNet.Server.IIS": "1.0.0-*", - "Microsoft.AspNet.Server.WebListener": "1.0.0-*", - "Microsoft.AspNet.WebSockets.Server": "1.0.0-*", - "Microsoft.AspNet.Server.Kestrel": "1.0.0-*" - }, - "commands": { - "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:12345", - "kestrel": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:12344" - }, - "frameworks" : { - "dnx451" : { }, - "dnxcore50" : { } - } + "exclude": "wwwroot/**/*", + "dependencies": { + "Microsoft.AspNet.WebSockets.Server": "1.0.0-*", + "Microsoft.AspNet.Server.Kestrel": "1.0.0-*" + }, + "compilationOptions": { + "emitEntryPoint": true + }, + "commands": { + "web": "AutobahnTestServer" + }, + "frameworks": { + "dnx451": { }, + "dnxcore50": { } + } } diff --git a/test/AutobahnTestServer/Startup.cs b/test/AutobahnTestServer/Startup.cs index bd69da7644..4ba3b887b7 100644 --- a/test/AutobahnTestServer/Startup.cs +++ b/test/AutobahnTestServer/Startup.cs @@ -6,6 +6,7 @@ using System.Net.WebSockets; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; using Microsoft.AspNet.WebSockets.Server; @@ -69,5 +70,15 @@ namespace AutobahnTestServer } await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); } + + public static void Main(string[] args) + { + var application = new WebApplicationBuilder() + .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + .UseStartup() + .Build(); + + application.Run(); + } } } diff --git a/test/AutobahnTestServer/hosting.json b/test/AutobahnTestServer/hosting.json new file mode 100644 index 0000000000..f8ef14574d --- /dev/null +++ b/test/AutobahnTestServer/hosting.json @@ -0,0 +1,3 @@ +{ + "server": "Microsoft.AspNet.Server.Kestrel" +} diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index d07e108c82..2b4edd2194 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -45,12 +45,13 @@ namespace Microsoft.AspNet.WebSockets.Client.Test var config = configBuilder.Build(); config["server.urls"] = "http://localhost:54321"; - var host = new WebHostBuilder(config) + var application = new WebApplicationBuilder() + .UseConfiguration(config) .UseServerFactory("Microsoft.AspNet.Server.Kestrel") - .UseStartup(startup) + .Configure(startup) .Build(); - return host.Start(); + return application.Start(); } } } From fe41412eeb78e34f9cfd6dcb113e665e18bd664f Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 21 Dec 2015 16:37:49 -0800 Subject: [PATCH 168/453] Stardardizing option initialization using lambdas --- .../WebSocketMiddlewareExtensions.cs | 22 +++++++++++++++++-- test/AutobahnTestServer/Startup.cs | 5 ++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs index c676331771..b22a09ad7f 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using Microsoft.AspNet.WebSockets.Server; namespace Microsoft.AspNet.Builder @@ -9,11 +10,28 @@ namespace Microsoft.AspNet.Builder { public static IApplicationBuilder UseWebSockets(this IApplicationBuilder builder) { - return builder.UseWebSockets(new WebSocketOptions()); + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + return builder.UseWebSockets(options => { }); } - public static IApplicationBuilder UseWebSockets(this IApplicationBuilder builder, WebSocketOptions options) // TODO: [NotNull] + public static IApplicationBuilder UseWebSockets(this IApplicationBuilder builder, Action configureOptions) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + if (configureOptions == null) + { + throw new ArgumentNullException(nameof(configureOptions)); + } + + var options = new WebSocketOptions(); + configureOptions(options); + return builder.Use(next => new WebSocketMiddleware(next, options).Invoke); } } diff --git a/test/AutobahnTestServer/Startup.cs b/test/AutobahnTestServer/Startup.cs index 4ba3b887b7..22fd8aae83 100644 --- a/test/AutobahnTestServer/Startup.cs +++ b/test/AutobahnTestServer/Startup.cs @@ -8,7 +8,6 @@ using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; -using Microsoft.AspNet.WebSockets.Server; namespace AutobahnTestServer { @@ -19,9 +18,9 @@ namespace AutobahnTestServer app.Map("/Managed", managedWebSocketsApp => { // Comment this out to test native server implementations - managedWebSocketsApp.UseWebSockets(new WebSocketOptions() + managedWebSocketsApp.UseWebSockets(options => { - ReplaceFeature = true, + options.ReplaceFeature = true; }); managedWebSocketsApp.Use(async (context, next) => From 887203781255edd2501db9ccd62b8dc74ab95855 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 23 Dec 2015 15:43:52 -0800 Subject: [PATCH 169/453] Adding back middleware initialization with options instance --- .../WebSocketMiddlewareExtensions.cs | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs index b22a09ad7f..a4cbdc7f61 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs @@ -8,21 +8,21 @@ namespace Microsoft.AspNet.Builder { public static class WebSocketMiddlewareExtensions { - public static IApplicationBuilder UseWebSockets(this IApplicationBuilder builder) + public static IApplicationBuilder UseWebSockets(this IApplicationBuilder app) { - if (builder == null) + if (app == null) { - throw new ArgumentNullException(nameof(builder)); + throw new ArgumentNullException(nameof(app)); } - return builder.UseWebSockets(options => { }); + return app.UseWebSockets(options => { }); } - public static IApplicationBuilder UseWebSockets(this IApplicationBuilder builder, Action configureOptions) + public static IApplicationBuilder UseWebSockets(this IApplicationBuilder app, Action configureOptions) { - if (builder == null) + if (app == null) { - throw new ArgumentNullException(nameof(builder)); + throw new ArgumentNullException(nameof(app)); } if (configureOptions == null) { @@ -32,7 +32,21 @@ namespace Microsoft.AspNet.Builder var options = new WebSocketOptions(); configureOptions(options); - return builder.Use(next => new WebSocketMiddleware(next, options).Invoke); + return app.UseMiddleware(options); + } + + public static IApplicationBuilder UseWebSockets(this IApplicationBuilder app, WebSocketOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); } } } \ No newline at end of file From 07785c9ae010ae7e04e340c5ee014b2bb18ff749 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 7 Jan 2016 13:55:41 -0800 Subject: [PATCH 170/453] Reacting to new hosting API --- .../KestrelWebSocketHelpers.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index 2b4edd2194..132da53e5b 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -47,11 +47,13 @@ namespace Microsoft.AspNet.WebSockets.Client.Test var application = new WebApplicationBuilder() .UseConfiguration(config) - .UseServerFactory("Microsoft.AspNet.Server.Kestrel") + .UseServer("Microsoft.AspNet.Server.Kestrel") .Configure(startup) .Build(); - return application.Start(); + application.Start(); + + return application; } } } From cd813844a0d215401755709729b03aad9a20f790 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 7 Jan 2016 16:37:39 -0800 Subject: [PATCH 171/453] Updating to new options pattern --- .../WebSocketMiddleware.cs | 14 ++++++++++-- .../WebSocketMiddlewareExtensions.cs | 22 +++---------------- .../WebSocketOptions.cs | 2 +- .../project.json | 3 ++- test/AutobahnTestServer/Startup.cs | 5 ++--- 5 files changed, 20 insertions(+), 26 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs index c3c48d91e9..8329d0789e 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs @@ -10,6 +10,7 @@ using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Features; using Microsoft.AspNet.WebSockets.Protocol; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.WebSockets.Server { @@ -18,10 +19,19 @@ namespace Microsoft.AspNet.WebSockets.Server private readonly RequestDelegate _next; private readonly WebSocketOptions _options; - public WebSocketMiddleware(RequestDelegate next, WebSocketOptions options) + public WebSocketMiddleware(RequestDelegate next, IOptions options) { + if (next == null) + { + throw new ArgumentNullException(nameof(next)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + _next = next; - _options = options; + _options = options.Value; // TODO: validate options. } diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs index a4cbdc7f61..8e71aab70a 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNet.WebSockets.Server; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Builder { @@ -15,24 +16,7 @@ namespace Microsoft.AspNet.Builder throw new ArgumentNullException(nameof(app)); } - return app.UseWebSockets(options => { }); - } - - public static IApplicationBuilder UseWebSockets(this IApplicationBuilder app, Action configureOptions) - { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - if (configureOptions == null) - { - throw new ArgumentNullException(nameof(configureOptions)); - } - - var options = new WebSocketOptions(); - configureOptions(options); - - return app.UseMiddleware(options); + return app.UseMiddleware(); } public static IApplicationBuilder UseWebSockets(this IApplicationBuilder app, WebSocketOptions options) @@ -46,7 +30,7 @@ namespace Microsoft.AspNet.Builder throw new ArgumentNullException(nameof(options)); } - return app.UseMiddleware(options); + return app.UseMiddleware(Options.Create(options)); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketOptions.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketOptions.cs index 09a155da46..69cfe2e177 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/WebSocketOptions.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketOptions.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.AspNet.WebSockets.Server +namespace Microsoft.AspNet.Builder { /// /// Configuration options for the WebSocketMiddleware diff --git a/src/Microsoft.AspNet.WebSockets.Server/project.json b/src/Microsoft.AspNet.WebSockets.Server/project.json index 358d798eeb..0c5563092e 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/project.json +++ b/src/Microsoft.AspNet.WebSockets.Server/project.json @@ -11,7 +11,8 @@ }, "dependencies": { "Microsoft.AspNet.Http.Extensions": "1.0.0-*", - "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*" + "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", + "Microsoft.Extensions.Options": "1.0.0-*" }, "frameworks": { "net451": {}, diff --git a/test/AutobahnTestServer/Startup.cs b/test/AutobahnTestServer/Startup.cs index 22fd8aae83..bc2bc28479 100644 --- a/test/AutobahnTestServer/Startup.cs +++ b/test/AutobahnTestServer/Startup.cs @@ -7,7 +7,6 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.Http; namespace AutobahnTestServer { @@ -18,9 +17,9 @@ namespace AutobahnTestServer app.Map("/Managed", managedWebSocketsApp => { // Comment this out to test native server implementations - managedWebSocketsApp.UseWebSockets(options => + managedWebSocketsApp.UseWebSockets(new WebSocketOptions { - options.ReplaceFeature = true; + ReplaceFeature = true }); managedWebSocketsApp.Use(async (context, next) => From eed89cd37cc59eab44e4be6b368e23eafb62c03c Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 8 Jan 2016 17:28:31 -0800 Subject: [PATCH 172/453] Accidentally removed required namespace --- test/AutobahnTestServer/Startup.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/test/AutobahnTestServer/Startup.cs b/test/AutobahnTestServer/Startup.cs index bc2bc28479..f0168a767e 100644 --- a/test/AutobahnTestServer/Startup.cs +++ b/test/AutobahnTestServer/Startup.cs @@ -7,6 +7,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Hosting; +using Microsoft.AspNet.Http; namespace AutobahnTestServer { From 5a284732af689ab2d6856cfa92773d453a196302 Mon Sep 17 00:00:00 2001 From: John Luo Date: Sun, 17 Jan 2016 16:49:26 -0800 Subject: [PATCH 173/453] Reacting to hosting rename --- .gitignore | 1 + test/AutobahnTestServer/Startup.cs | 6 +++--- .../KestrelWebSocketHelpers.cs | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index c1d75776c9..2837d3092b 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ nuget.exe *.ipch *.sln.ide project.lock.json +/.vs/ diff --git a/test/AutobahnTestServer/Startup.cs b/test/AutobahnTestServer/Startup.cs index f0168a767e..5af6589de0 100644 --- a/test/AutobahnTestServer/Startup.cs +++ b/test/AutobahnTestServer/Startup.cs @@ -72,12 +72,12 @@ namespace AutobahnTestServer public static void Main(string[] args) { - var application = new WebApplicationBuilder() - .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + var host = new WebHostBuilder() + .UseDefaultConfiguration(args) .UseStartup() .Build(); - application.Run(); + host.Run(); } } } diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index 132da53e5b..9f2a9b321e 100644 --- a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -45,15 +45,15 @@ namespace Microsoft.AspNet.WebSockets.Client.Test var config = configBuilder.Build(); config["server.urls"] = "http://localhost:54321"; - var application = new WebApplicationBuilder() + var host = new WebHostBuilder() .UseConfiguration(config) .UseServer("Microsoft.AspNet.Server.Kestrel") .Configure(startup) .Build(); - application.Start(); + host.Start(); - return application; + return host; } } } From 91ee0f323bcbb58f896009f975e0dfaca5fef735 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 20 Jan 2016 21:03:04 -0800 Subject: [PATCH 174/453] Reacting to CoreCLR package version change --- src/Microsoft.AspNet.WebSockets.Protocol/project.json | 4 ++-- test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index be38440635..c268656661 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -14,12 +14,12 @@ "dotnet5.4": { "dependencies": { "System.Diagnostics.Contracts": "4.0.1-*", - "System.IO": "4.0.11-*", + "System.IO": "4.1.0-*", "System.Linq": "4.0.1-*", "System.Net.WebSockets": "4.0.0-*", "System.Runtime": "4.0.21-*", "System.Runtime.InteropServices": "4.0.21-*", - "System.Runtime.Extensions": "4.0.11-*", + "System.Runtime.Extensions": "4.1.0-*", "System.Security.Cryptography.Algorithms": "4.0.0-*", "System.Text.Encoding.Extensions": "4.0.11-*", "System.Threading": "4.0.11-*", diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json index 9cc3c1ffdc..af40e33ade 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json @@ -5,9 +5,7 @@ }, "frameworks": { "dnx451": { }, - "dnxcore50": { - "System.IO": "4.0.11-*" - } + "dnxcore50": { } }, "commands": { "test": "xunit.runner.aspnet" From 5227607c58192727a1ae57eba3e4d41d5c0e7e03 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Fri, 22 Jan 2016 12:24:46 -0800 Subject: [PATCH 175/453] Rename AspNet 5 folders and files. See https://github.com/aspnet/Announcements/issues/144 for more information. --- .../Constants.cs | 0 .../Microsoft.AspNetCore.WebSockets.Client.xproj} | 0 .../Properties/AssemblyInfo.cs | 0 .../WebSocketClient.cs | 0 .../project.json | 0 .../CommonWebSocket.cs | 0 .../Constants.cs | 0 .../FrameHeader.cs | 0 .../HandshakeHelpers.cs | 0 .../Microsoft.AspNetCore.WebSockets.Protocol.xproj} | 0 .../Properties/AssemblyInfo.cs | 0 .../Utilities.cs | 0 .../project.json | 0 .../ExtendedWebSocketAcceptContext.cs | 0 .../Microsoft.AspNetCore.WebSockets.Server.xproj} | 0 .../Properties/AssemblyInfo.cs | 0 .../WebSocketMiddleware.cs | 0 .../WebSocketMiddlewareExtensions.cs | 0 .../WebSocketOptions.cs | 0 .../project.json | 0 .../KestrelWebSocketHelpers.cs | 0 .../Microsoft.AspNetCore.WebSockets.Client.Test.xproj} | 0 .../WebSocketClientTests.cs | 0 .../project.json | 0 .../BufferStream.cs | 0 .../DuplexStream.cs | 0 .../DuplexTests.cs | 0 .../Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj} | 0 .../Microsoft.Net.WebSockets.Test.csproj | 0 .../Properties/AssemblyInfo.cs | 0 .../Utf8ValidationTests.cs | 0 .../UtilitiesTests.cs | 0 .../project.json | 0 33 files changed, 0 insertions(+), 0 deletions(-) rename src/{Microsoft.AspNet.WebSockets.Client => Microsoft.AspNetCore.WebSockets.Client}/Constants.cs (100%) rename src/{Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.xproj => Microsoft.AspNetCore.WebSockets.Client/Microsoft.AspNetCore.WebSockets.Client.xproj} (100%) rename src/{Microsoft.AspNet.WebSockets.Client => Microsoft.AspNetCore.WebSockets.Client}/Properties/AssemblyInfo.cs (100%) rename src/{Microsoft.AspNet.WebSockets.Client => Microsoft.AspNetCore.WebSockets.Client}/WebSocketClient.cs (100%) rename src/{Microsoft.AspNet.WebSockets.Client => Microsoft.AspNetCore.WebSockets.Client}/project.json (100%) rename src/{Microsoft.AspNet.WebSockets.Protocol => Microsoft.AspNetCore.WebSockets.Protocol}/CommonWebSocket.cs (100%) rename src/{Microsoft.AspNet.WebSockets.Protocol => Microsoft.AspNetCore.WebSockets.Protocol}/Constants.cs (100%) rename src/{Microsoft.AspNet.WebSockets.Protocol => Microsoft.AspNetCore.WebSockets.Protocol}/FrameHeader.cs (100%) rename src/{Microsoft.AspNet.WebSockets.Protocol => Microsoft.AspNetCore.WebSockets.Protocol}/HandshakeHelpers.cs (100%) rename src/{Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.xproj => Microsoft.AspNetCore.WebSockets.Protocol/Microsoft.AspNetCore.WebSockets.Protocol.xproj} (100%) rename src/{Microsoft.AspNet.WebSockets.Protocol => Microsoft.AspNetCore.WebSockets.Protocol}/Properties/AssemblyInfo.cs (100%) rename src/{Microsoft.AspNet.WebSockets.Protocol => Microsoft.AspNetCore.WebSockets.Protocol}/Utilities.cs (100%) rename src/{Microsoft.AspNet.WebSockets.Protocol => Microsoft.AspNetCore.WebSockets.Protocol}/project.json (100%) rename src/{Microsoft.AspNet.WebSockets.Server => Microsoft.AspNetCore.WebSockets.Server}/ExtendedWebSocketAcceptContext.cs (100%) rename src/{Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.xproj => Microsoft.AspNetCore.WebSockets.Server/Microsoft.AspNetCore.WebSockets.Server.xproj} (100%) rename src/{Microsoft.AspNet.WebSockets.Server => Microsoft.AspNetCore.WebSockets.Server}/Properties/AssemblyInfo.cs (100%) rename src/{Microsoft.AspNet.WebSockets.Server => Microsoft.AspNetCore.WebSockets.Server}/WebSocketMiddleware.cs (100%) rename src/{Microsoft.AspNet.WebSockets.Server => Microsoft.AspNetCore.WebSockets.Server}/WebSocketMiddlewareExtensions.cs (100%) rename src/{Microsoft.AspNet.WebSockets.Server => Microsoft.AspNetCore.WebSockets.Server}/WebSocketOptions.cs (100%) rename src/{Microsoft.AspNet.WebSockets.Server => Microsoft.AspNetCore.WebSockets.Server}/project.json (100%) rename test/{Microsoft.AspNet.WebSockets.Client.Test => Microsoft.AspNetCore.WebSockets.Client.Test}/KestrelWebSocketHelpers.cs (100%) rename test/{Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.xproj => Microsoft.AspNetCore.WebSockets.Client.Test/Microsoft.AspNetCore.WebSockets.Client.Test.xproj} (100%) rename test/{Microsoft.AspNet.WebSockets.Client.Test => Microsoft.AspNetCore.WebSockets.Client.Test}/WebSocketClientTests.cs (100%) rename test/{Microsoft.AspNet.WebSockets.Client.Test => Microsoft.AspNetCore.WebSockets.Client.Test}/project.json (100%) rename test/{Microsoft.AspNet.WebSockets.Protocol.Test => Microsoft.AspNetCore.WebSockets.Protocol.Test}/BufferStream.cs (100%) rename test/{Microsoft.AspNet.WebSockets.Protocol.Test => Microsoft.AspNetCore.WebSockets.Protocol.Test}/DuplexStream.cs (100%) rename test/{Microsoft.AspNet.WebSockets.Protocol.Test => Microsoft.AspNetCore.WebSockets.Protocol.Test}/DuplexTests.cs (100%) rename test/{Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.xproj => Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj} (100%) rename test/{Microsoft.AspNet.WebSockets.Protocol.Test => Microsoft.AspNetCore.WebSockets.Protocol.Test}/Microsoft.Net.WebSockets.Test.csproj (100%) rename test/{Microsoft.AspNet.WebSockets.Protocol.Test => Microsoft.AspNetCore.WebSockets.Protocol.Test}/Properties/AssemblyInfo.cs (100%) rename test/{Microsoft.AspNet.WebSockets.Protocol.Test => Microsoft.AspNetCore.WebSockets.Protocol.Test}/Utf8ValidationTests.cs (100%) rename test/{Microsoft.AspNet.WebSockets.Protocol.Test => Microsoft.AspNetCore.WebSockets.Protocol.Test}/UtilitiesTests.cs (100%) rename test/{Microsoft.AspNet.WebSockets.Protocol.Test => Microsoft.AspNetCore.WebSockets.Protocol.Test}/project.json (100%) diff --git a/src/Microsoft.AspNet.WebSockets.Client/Constants.cs b/src/Microsoft.AspNetCore.WebSockets.Client/Constants.cs similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Client/Constants.cs rename to src/Microsoft.AspNetCore.WebSockets.Client/Constants.cs diff --git a/src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.xproj b/src/Microsoft.AspNetCore.WebSockets.Client/Microsoft.AspNetCore.WebSockets.Client.xproj similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Client/Microsoft.AspNet.WebSockets.Client.xproj rename to src/Microsoft.AspNetCore.WebSockets.Client/Microsoft.AspNetCore.WebSockets.Client.xproj diff --git a/src/Microsoft.AspNet.WebSockets.Client/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.WebSockets.Client/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Client/Properties/AssemblyInfo.cs rename to src/Microsoft.AspNetCore.WebSockets.Client/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNet.WebSockets.Client/WebSocketClient.cs b/src/Microsoft.AspNetCore.WebSockets.Client/WebSocketClient.cs similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Client/WebSocketClient.cs rename to src/Microsoft.AspNetCore.WebSockets.Client/WebSocketClient.cs diff --git a/src/Microsoft.AspNet.WebSockets.Client/project.json b/src/Microsoft.AspNetCore.WebSockets.Client/project.json similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Client/project.json rename to src/Microsoft.AspNetCore.WebSockets.Client/project.json diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/CommonWebSocket.cs similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs rename to src/Microsoft.AspNetCore.WebSockets.Protocol/CommonWebSocket.cs diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/Constants.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/Constants.cs similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Protocol/Constants.cs rename to src/Microsoft.AspNetCore.WebSockets.Protocol/Constants.cs diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/FrameHeader.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/FrameHeader.cs similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Protocol/FrameHeader.cs rename to src/Microsoft.AspNetCore.WebSockets.Protocol/FrameHeader.cs diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/HandshakeHelpers.cs similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs rename to src/Microsoft.AspNetCore.WebSockets.Protocol/HandshakeHelpers.cs diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.xproj b/src/Microsoft.AspNetCore.WebSockets.Protocol/Microsoft.AspNetCore.WebSockets.Protocol.xproj similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Protocol/Microsoft.AspNet.WebSockets.Protocol.xproj rename to src/Microsoft.AspNetCore.WebSockets.Protocol/Microsoft.AspNetCore.WebSockets.Protocol.xproj diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Protocol/Properties/AssemblyInfo.cs rename to src/Microsoft.AspNetCore.WebSockets.Protocol/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/Utilities.cs similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Protocol/Utilities.cs rename to src/Microsoft.AspNetCore.WebSockets.Protocol/Utilities.cs diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Protocol/project.json rename to src/Microsoft.AspNetCore.WebSockets.Protocol/project.json diff --git a/src/Microsoft.AspNet.WebSockets.Server/ExtendedWebSocketAcceptContext.cs b/src/Microsoft.AspNetCore.WebSockets.Server/ExtendedWebSocketAcceptContext.cs similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Server/ExtendedWebSocketAcceptContext.cs rename to src/Microsoft.AspNetCore.WebSockets.Server/ExtendedWebSocketAcceptContext.cs diff --git a/src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.xproj b/src/Microsoft.AspNetCore.WebSockets.Server/Microsoft.AspNetCore.WebSockets.Server.xproj similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Server/Microsoft.AspNet.WebSockets.Server.xproj rename to src/Microsoft.AspNetCore.WebSockets.Server/Microsoft.AspNetCore.WebSockets.Server.xproj diff --git a/src/Microsoft.AspNet.WebSockets.Server/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.WebSockets.Server/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Server/Properties/AssemblyInfo.cs rename to src/Microsoft.AspNetCore.WebSockets.Server/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs b/src/Microsoft.AspNetCore.WebSockets.Server/WebSocketMiddleware.cs similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddleware.cs rename to src/Microsoft.AspNetCore.WebSockets.Server/WebSocketMiddleware.cs diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs b/src/Microsoft.AspNetCore.WebSockets.Server/WebSocketMiddlewareExtensions.cs similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs rename to src/Microsoft.AspNetCore.WebSockets.Server/WebSocketMiddlewareExtensions.cs diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketOptions.cs b/src/Microsoft.AspNetCore.WebSockets.Server/WebSocketOptions.cs similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Server/WebSocketOptions.cs rename to src/Microsoft.AspNetCore.WebSockets.Server/WebSocketOptions.cs diff --git a/src/Microsoft.AspNet.WebSockets.Server/project.json b/src/Microsoft.AspNetCore.WebSockets.Server/project.json similarity index 100% rename from src/Microsoft.AspNet.WebSockets.Server/project.json rename to src/Microsoft.AspNetCore.WebSockets.Server/project.json diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNetCore.WebSockets.Client.Test/KestrelWebSocketHelpers.cs similarity index 100% rename from test/Microsoft.AspNet.WebSockets.Client.Test/KestrelWebSocketHelpers.cs rename to test/Microsoft.AspNetCore.WebSockets.Client.Test/KestrelWebSocketHelpers.cs diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.xproj b/test/Microsoft.AspNetCore.WebSockets.Client.Test/Microsoft.AspNetCore.WebSockets.Client.Test.xproj similarity index 100% rename from test/Microsoft.AspNet.WebSockets.Client.Test/Microsoft.AspNet.WebSockets.Client.Test.xproj rename to test/Microsoft.AspNetCore.WebSockets.Client.Test/Microsoft.AspNetCore.WebSockets.Client.Test.xproj diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/WebSocketClientTests.cs b/test/Microsoft.AspNetCore.WebSockets.Client.Test/WebSocketClientTests.cs similarity index 100% rename from test/Microsoft.AspNet.WebSockets.Client.Test/WebSocketClientTests.cs rename to test/Microsoft.AspNetCore.WebSockets.Client.Test/WebSocketClientTests.cs diff --git a/test/Microsoft.AspNet.WebSockets.Client.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json similarity index 100% rename from test/Microsoft.AspNet.WebSockets.Client.Test/project.json rename to test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/BufferStream.cs similarity index 100% rename from test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs rename to test/Microsoft.AspNetCore.WebSockets.Protocol.Test/BufferStream.cs diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexStream.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexStream.cs similarity index 100% rename from test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexStream.cs rename to test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexStream.cs diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexTests.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexTests.cs similarity index 100% rename from test/Microsoft.AspNet.WebSockets.Protocol.Test/DuplexTests.cs rename to test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexTests.cs diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.xproj b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj similarity index 100% rename from test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.AspNet.WebSockets.Protocol.Test.xproj rename to test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.Net.WebSockets.Test.csproj b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.Net.WebSockets.Test.csproj similarity index 100% rename from test/Microsoft.AspNet.WebSockets.Protocol.Test/Microsoft.Net.WebSockets.Test.csproj rename to test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.Net.WebSockets.Test.csproj diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Properties/AssemblyInfo.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Properties/AssemblyInfo.cs similarity index 100% rename from test/Microsoft.AspNet.WebSockets.Protocol.Test/Properties/AssemblyInfo.cs rename to test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Properties/AssemblyInfo.cs diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/Utf8ValidationTests.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Utf8ValidationTests.cs similarity index 100% rename from test/Microsoft.AspNet.WebSockets.Protocol.Test/Utf8ValidationTests.cs rename to test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Utf8ValidationTests.cs diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/UtilitiesTests.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/UtilitiesTests.cs similarity index 100% rename from test/Microsoft.AspNet.WebSockets.Protocol.Test/UtilitiesTests.cs rename to test/Microsoft.AspNetCore.WebSockets.Protocol.Test/UtilitiesTests.cs diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json similarity index 100% rename from test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json rename to test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json From e28aa5f568756d7755c5b6e803ec8f67daa1e3c8 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Fri, 22 Jan 2016 12:24:49 -0800 Subject: [PATCH 176/453] Rename AspNet 5 file contents. See https://github.com/aspnet/Announcements/issues/144 for more information. --- NuGetPackageVerifier.json | 6 +++--- WebSockets.sln | 12 ++++++------ .../Constants.cs | 2 +- .../WebSocketClient.cs | 4 ++-- .../project.json | 2 +- .../CommonWebSocket.cs | 2 +- .../Constants.cs | 2 +- .../FrameHeader.cs | 2 +- .../HandshakeHelpers.cs | 2 +- .../Utilities.cs | 2 +- .../ExtendedWebSocketAcceptContext.cs | 4 ++-- .../WebSocketMiddleware.cs | 10 +++++----- .../WebSocketMiddlewareExtensions.cs | 4 ++-- .../WebSocketOptions.cs | 2 +- .../project.json | 4 ++-- test/AutobahnTestClient/Program.cs | 2 +- test/AutobahnTestClient/Project.json | 2 +- test/AutobahnTestClient/ReadMe.txt | 4 ++-- test/AutobahnTestServer/Project.json | 4 ++-- test/AutobahnTestServer/Startup.cs | 6 +++--- test/AutobahnTestServer/hosting.json | 4 ++-- .../KestrelWebSocketHelpers.cs | 10 +++++----- .../WebSocketClientTests.cs | 4 ++-- .../project.json | 10 +++++----- .../BufferStream.cs | 2 +- .../DuplexStream.cs | 2 +- .../DuplexTests.cs | 2 +- .../Utf8ValidationTests.cs | 2 +- .../UtilitiesTests.cs | 2 +- .../project.json | 2 +- test/TestClient/Program.cs | 4 ++-- test/TestClient/project.json | 4 ++-- 32 files changed, 63 insertions(+), 63 deletions(-) diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json index fb6dff2589..f6d4502671 100644 --- a/NuGetPackageVerifier.json +++ b/NuGetPackageVerifier.json @@ -9,9 +9,9 @@ "StrictSemanticVersionValidationRule" ], "packages": { - "Microsoft.AspNet.WebSockets.Client": { }, - "Microsoft.AspNet.WebSockets.Protocol": { }, - "Microsoft.AspNet.WebSockets.Server": { } + "Microsoft.AspNetCore.WebSockets.Client": { }, + "Microsoft.AspNetCore.WebSockets.Protocol": { }, + "Microsoft.AspNetCore.WebSockets.Server": { } } }, "Default": { // Ru les to run for packages not listed in any other set. diff --git a/WebSockets.sln b/WebSockets.sln index dbe1d22aaf..a7b3697b81 100644 --- a/WebSockets.sln +++ b/WebSockets.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.22216.0 @@ -11,17 +11,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{C45106D0-7 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Protocol", "src\Microsoft.AspNet.WebSockets.Protocol\Microsoft.AspNet.WebSockets.Protocol.xproj", "{E0C10DEC-3339-4A47-85BC-3100C5D34AD4}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Protocol", "src\Microsoft.AspNetCore.WebSockets.Protocol\Microsoft.AspNetCore.WebSockets.Protocol.xproj", "{E0C10DEC-3339-4A47-85BC-3100C5D34AD4}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Protocol.Test", "test\Microsoft.AspNet.WebSockets.Protocol.Test\Microsoft.AspNet.WebSockets.Protocol.Test.xproj", "{62A07A24-4D06-4DDA-B6BF-02D0C9CB7D32}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Protocol.Test", "test\Microsoft.AspNetCore.WebSockets.Protocol.Test\Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj", "{62A07A24-4D06-4DDA-B6BF-02D0C9CB7D32}" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestClient", "test\TestClient\TestClient.xproj", "{8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Client", "src\Microsoft.AspNet.WebSockets.Client\Microsoft.AspNet.WebSockets.Client.xproj", "{4A1C4875-AE21-4A78-979A-F0E4DF5EB518}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Client", "src\Microsoft.AspNetCore.WebSockets.Client\Microsoft.AspNetCore.WebSockets.Client.xproj", "{4A1C4875-AE21-4A78-979A-F0E4DF5EB518}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Client.Test", "test\Microsoft.AspNet.WebSockets.Client.Test\Microsoft.AspNet.WebSockets.Client.Test.xproj", "{6604D154-817F-4BC5-BE95-FF7E851179D9}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Client.Test", "test\Microsoft.AspNetCore.WebSockets.Client.Test\Microsoft.AspNetCore.WebSockets.Client.Test.xproj", "{6604D154-817F-4BC5-BE95-FF7E851179D9}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebSockets.Server", "src\Microsoft.AspNet.WebSockets.Server\Microsoft.AspNet.WebSockets.Server.xproj", "{78A097D0-C0A4-4AED-93E2-84A65392FB52}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Server", "src\Microsoft.AspNetCore.WebSockets.Server\Microsoft.AspNetCore.WebSockets.Server.xproj", "{78A097D0-C0A4-4AED-93E2-84A65392FB52}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{86E1ADA2-631C-484F-906C-2D0BCF628E65}" ProjectSection(SolutionItems) = preProject diff --git a/src/Microsoft.AspNetCore.WebSockets.Client/Constants.cs b/src/Microsoft.AspNetCore.WebSockets.Client/Constants.cs index 7cc48a9baf..941c75c63b 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Client/Constants.cs +++ b/src/Microsoft.AspNetCore.WebSockets.Client/Constants.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNet.WebSockets.Client +namespace Microsoft.AspNetCore.WebSockets.Client { public static class Constants { diff --git a/src/Microsoft.AspNetCore.WebSockets.Client/WebSocketClient.cs b/src/Microsoft.AspNetCore.WebSockets.Client/WebSocketClient.cs index 3ba9c3963f..8e924734f1 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Client/WebSocketClient.cs +++ b/src/Microsoft.AspNetCore.WebSockets.Client/WebSocketClient.cs @@ -9,9 +9,9 @@ using System.Net; using System.Net.WebSockets; using System.Threading; using System.Threading.Tasks; -using Microsoft.AspNet.WebSockets.Protocol; +using Microsoft.AspNetCore.WebSockets.Protocol; -namespace Microsoft.AspNet.WebSockets.Client +namespace Microsoft.AspNetCore.WebSockets.Client { public class WebSocketClient { diff --git a/src/Microsoft.AspNetCore.WebSockets.Client/project.json b/src/Microsoft.AspNetCore.WebSockets.Client/project.json index 87056bc28c..71bae93c68 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Client/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Client/project.json @@ -10,7 +10,7 @@ "keyFile": "../../tools/Key.snk" }, "dependencies": { - "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*" + "Microsoft.AspNetCore.WebSockets.Protocol": "1.0.0-*" }, "frameworks": { "net451": { } diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/CommonWebSocket.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/CommonWebSocket.cs index f7e803ab08..56baf28d2f 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/CommonWebSocket.cs +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/CommonWebSocket.cs @@ -11,7 +11,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -namespace Microsoft.AspNet.WebSockets.Protocol +namespace Microsoft.AspNetCore.WebSockets.Protocol { // https://tools.ietf.org/html/rfc6455 public class CommonWebSocket : WebSocket diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/Constants.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/Constants.cs index 80a3bf8983..56e125afc2 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/Constants.cs +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/Constants.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNet.WebSockets.Protocol +namespace Microsoft.AspNetCore.WebSockets.Protocol { public static class Constants { diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/FrameHeader.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/FrameHeader.cs index 749bf13d68..50fe6060b4 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/FrameHeader.cs +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/FrameHeader.cs @@ -8,7 +8,7 @@ using System.Net.WebSockets; using System.Text; using System.Threading.Tasks; -namespace Microsoft.AspNet.WebSockets.Protocol +namespace Microsoft.AspNetCore.WebSockets.Protocol { public class FrameHeader { diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/HandshakeHelpers.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/HandshakeHelpers.cs index 478b61bfe5..8afe0a9ce5 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/HandshakeHelpers.cs +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/HandshakeHelpers.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Security.Cryptography; using System.Text; -namespace Microsoft.AspNet.WebSockets.Protocol +namespace Microsoft.AspNetCore.WebSockets.Protocol { public static class HandshakeHelpers { diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/Utilities.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/Utilities.cs index 385f4003a0..c8ec5768c2 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/Utilities.cs +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/Utilities.cs @@ -4,7 +4,7 @@ using System; using System.Net.WebSockets; -namespace Microsoft.AspNet.WebSockets.Protocol +namespace Microsoft.AspNetCore.WebSockets.Protocol { public static class Utilities { diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/ExtendedWebSocketAcceptContext.cs b/src/Microsoft.AspNetCore.WebSockets.Server/ExtendedWebSocketAcceptContext.cs index 6c6fa97f16..7d0ba9b945 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Server/ExtendedWebSocketAcceptContext.cs +++ b/src/Microsoft.AspNetCore.WebSockets.Server/ExtendedWebSocketAcceptContext.cs @@ -2,9 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Http.Features; +using Microsoft.AspNetCore.Http.Features; -namespace Microsoft.AspNet.WebSockets.Server +namespace Microsoft.AspNetCore.WebSockets.Server { public class ExtendedWebSocketAcceptContext : WebSocketAcceptContext { diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/WebSocketMiddleware.cs b/src/Microsoft.AspNetCore.WebSockets.Server/WebSocketMiddleware.cs index 8329d0789e..9bfccfd5c1 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Server/WebSocketMiddleware.cs +++ b/src/Microsoft.AspNetCore.WebSockets.Server/WebSocketMiddleware.cs @@ -6,13 +6,13 @@ using System.Collections.Generic; using System.IO; using System.Net.WebSockets; using System.Threading.Tasks; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Features; -using Microsoft.AspNet.WebSockets.Protocol; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.AspNetCore.WebSockets.Protocol; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.WebSockets.Server +namespace Microsoft.AspNetCore.WebSockets.Server { public class WebSocketMiddleware { diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/WebSocketMiddlewareExtensions.cs b/src/Microsoft.AspNetCore.WebSockets.Server/WebSocketMiddlewareExtensions.cs index 8e71aab70a..32295ab5af 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Server/WebSocketMiddlewareExtensions.cs +++ b/src/Microsoft.AspNetCore.WebSockets.Server/WebSocketMiddlewareExtensions.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.WebSockets.Server; +using Microsoft.AspNetCore.WebSockets.Server; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { public static class WebSocketMiddlewareExtensions { diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/WebSocketOptions.cs b/src/Microsoft.AspNetCore.WebSockets.Server/WebSocketOptions.cs index 69cfe2e177..d6603adf8a 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Server/WebSocketOptions.cs +++ b/src/Microsoft.AspNetCore.WebSockets.Server/WebSocketOptions.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { /// /// Configuration options for the WebSocketMiddleware diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/project.json b/src/Microsoft.AspNetCore.WebSockets.Server/project.json index 0c5563092e..df9dd72cdd 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Server/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Server/project.json @@ -10,8 +10,8 @@ "url": "git://github.com/aspnet/websockets" }, "dependencies": { - "Microsoft.AspNet.Http.Extensions": "1.0.0-*", - "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", + "Microsoft.AspNetCore.Http.Extensions": "1.0.0-*", + "Microsoft.AspNetCore.WebSockets.Protocol": "1.0.0-*", "Microsoft.Extensions.Options": "1.0.0-*" }, "frameworks": { diff --git a/test/AutobahnTestClient/Program.cs b/test/AutobahnTestClient/Program.cs index 67df22e3ff..d6251c8b6f 100644 --- a/test/AutobahnTestClient/Program.cs +++ b/test/AutobahnTestClient/Program.cs @@ -6,7 +6,7 @@ using System.Net.WebSockets; using System.Text; using System.Threading; using System.Threading.Tasks; -using Microsoft.AspNet.WebSockets.Client; +using Microsoft.AspNetCore.WebSockets.Client; namespace AutobahnTestClient { diff --git a/test/AutobahnTestClient/Project.json b/test/AutobahnTestClient/Project.json index a671b8f913..592bb2db4a 100644 --- a/test/AutobahnTestClient/Project.json +++ b/test/AutobahnTestClient/Project.json @@ -1,6 +1,6 @@ { "dependencies": { - "Microsoft.AspNet.WebSockets.Client": "1.0.0-*" + "Microsoft.AspNetCore.WebSockets.Client": "1.0.0-*" }, "commands": { "run" : "run" diff --git a/test/AutobahnTestClient/ReadMe.txt b/test/AutobahnTestClient/ReadMe.txt index c49984330f..6da6360ccc 100644 --- a/test/AutobahnTestClient/ReadMe.txt +++ b/test/AutobahnTestClient/ReadMe.txt @@ -1,5 +1,5 @@ -This test server is for use in testing client side implementations of the WebSocekt protocol. It is currently implemented to test -Microsoft.AspNet.WebSockets.Client.WebSocketClient and System.Net.WebSockets.ClientWebSocket. +This test server is for use in testing client side implementations of the WebSocekt protocol. It is currently implemented to test +Microsoft.AspNetCore.WebSockets.Client.WebSocketClient and System.Net.WebSockets.ClientWebSocket. See http://autobahn.ws/ to download and install the test framework. diff --git a/test/AutobahnTestServer/Project.json b/test/AutobahnTestServer/Project.json index ff0dac2eba..10188cf800 100644 --- a/test/AutobahnTestServer/Project.json +++ b/test/AutobahnTestServer/Project.json @@ -1,8 +1,8 @@ { "exclude": "wwwroot/**/*", "dependencies": { - "Microsoft.AspNet.WebSockets.Server": "1.0.0-*", - "Microsoft.AspNet.Server.Kestrel": "1.0.0-*" + "Microsoft.AspNetCore.WebSockets.Server": "1.0.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*" }, "compilationOptions": { "emitEntryPoint": true diff --git a/test/AutobahnTestServer/Startup.cs b/test/AutobahnTestServer/Startup.cs index 5af6589de0..023d05ffaa 100644 --- a/test/AutobahnTestServer/Startup.cs +++ b/test/AutobahnTestServer/Startup.cs @@ -5,9 +5,9 @@ using System; using System.Net.WebSockets; using System.Threading; using System.Threading.Tasks; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; namespace AutobahnTestServer { diff --git a/test/AutobahnTestServer/hosting.json b/test/AutobahnTestServer/hosting.json index f8ef14574d..6a93dbafa8 100644 --- a/test/AutobahnTestServer/hosting.json +++ b/test/AutobahnTestServer/hosting.json @@ -1,3 +1,3 @@ -{ - "server": "Microsoft.AspNet.Server.Kestrel" +{ + "server": "Microsoft.AspNetCore.Server.Kestrel" } diff --git a/test/Microsoft.AspNetCore.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNetCore.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index 9f2a9b321e..d496873e16 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -3,12 +3,12 @@ using System; using System.Threading.Tasks; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; -namespace Microsoft.AspNet.WebSockets.Client.Test +namespace Microsoft.AspNetCore.WebSockets.Client.Test { public class KestrelWebSocketHelpers { @@ -47,7 +47,7 @@ namespace Microsoft.AspNet.WebSockets.Client.Test var host = new WebHostBuilder() .UseConfiguration(config) - .UseServer("Microsoft.AspNet.Server.Kestrel") + .UseServer("Microsoft.AspNetCore.Server.Kestrel") .Configure(startup) .Build(); diff --git a/test/Microsoft.AspNetCore.WebSockets.Client.Test/WebSocketClientTests.cs b/test/Microsoft.AspNetCore.WebSockets.Client.Test/WebSocketClientTests.cs index 1d5ccf1f58..fe3e0d6852 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Client.Test/WebSocketClientTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Client.Test/WebSocketClientTests.cs @@ -6,10 +6,10 @@ using System.Net.WebSockets; using System.Text; using System.Threading; using System.Threading.Tasks; -using Microsoft.AspNet.Testing.xunit; +using Microsoft.AspNetCore.Testing.xunit; using Xunit; -namespace Microsoft.AspNet.WebSockets.Client.Test +namespace Microsoft.AspNetCore.WebSockets.Client.Test { public class WebSocketClientTests { diff --git a/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json index 9ffd597ef0..228d842348 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json @@ -1,10 +1,10 @@ { "dependencies": { - "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", - "Microsoft.AspNet.WebSockets.Client": "1.0.0-*", - "Microsoft.AspNet.WebSockets.Server": "1.0.0-*", - "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", - "Microsoft.AspNet.Testing": "1.0.0-*", + "Microsoft.AspNetCore.WebSockets.Protocol": "1.0.0-*", + "Microsoft.AspNetCore.WebSockets.Client": "1.0.0-*", + "Microsoft.AspNetCore.WebSockets.Server": "1.0.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", + "Microsoft.AspNetCore.Testing": "1.0.0-*", "xunit.runner.aspnet": "2.0.0-aspnet-*" }, "frameworks": { diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/BufferStream.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/BufferStream.cs index 9d49f8ec10..4a36510666 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/BufferStream.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/BufferStream.cs @@ -8,7 +8,7 @@ using System.IO; using System.Threading; using System.Threading.Tasks; -namespace Microsoft.AspNet.WebSockets.Protocol.Test +namespace Microsoft.AspNetCore.WebSockets.Protocol.Test { // This steam accepts writes from one side, buffers them internally, and returns the data via Reads // when requested on the other side. diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexStream.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexStream.cs index 09e87c660f..095029e5d8 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexStream.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexStream.cs @@ -5,7 +5,7 @@ using System.IO; using System.Threading; using System.Threading.Tasks; -namespace Microsoft.AspNet.WebSockets.Protocol.Test +namespace Microsoft.AspNetCore.WebSockets.Protocol.Test { // A duplex wrapper around a read and write stream. public class DuplexStream : Stream diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexTests.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexTests.cs index 2e5cc15d83..c0fe5dc66c 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexTests.cs @@ -8,7 +8,7 @@ using System.Threading; using System.Threading.Tasks; using Xunit; -namespace Microsoft.AspNet.WebSockets.Protocol.Test +namespace Microsoft.AspNetCore.WebSockets.Protocol.Test { public class DuplexTests { diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Utf8ValidationTests.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Utf8ValidationTests.cs index f42339a77f..10641f0dbd 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Utf8ValidationTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Utf8ValidationTests.cs @@ -5,7 +5,7 @@ using System; using System.Text; using Xunit; -namespace Microsoft.AspNet.WebSockets.Protocol.Test +namespace Microsoft.AspNetCore.WebSockets.Protocol.Test { public class Utf8ValidationTests { diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/UtilitiesTests.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/UtilitiesTests.cs index 9f221f197b..0d69ed89f7 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/UtilitiesTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/UtilitiesTests.cs @@ -5,7 +5,7 @@ using System; using System.Text; using Xunit; -namespace Microsoft.AspNet.WebSockets.Protocol.Test +namespace Microsoft.AspNetCore.WebSockets.Protocol.Test { public class UtilitiesTests { diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json index af40e33ade..263b03fb77 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json @@ -1,6 +1,6 @@ { "dependencies": { - "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", + "Microsoft.AspNetCore.WebSockets.Protocol": "1.0.0-*", "xunit.runner.aspnet": "2.0.0-aspnet-*" }, "frameworks": { diff --git a/test/TestClient/Program.cs b/test/TestClient/Program.cs index 37072d144d..7be260b81c 100644 --- a/test/TestClient/Program.cs +++ b/test/TestClient/Program.cs @@ -1,9 +1,9 @@ -using System; +using System; using System.Net.WebSockets; using System.Text; using System.Threading; using System.Threading.Tasks; -using Microsoft.AspNet.WebSockets.Client; +using Microsoft.AspNetCore.WebSockets.Client; namespace TestClient { diff --git a/test/TestClient/project.json b/test/TestClient/project.json index 2c1c4ae5e9..1b6b600c9d 100644 --- a/test/TestClient/project.json +++ b/test/TestClient/project.json @@ -3,8 +3,8 @@ "TestClient": "TestClient" }, "dependencies": { - "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", - "Microsoft.AspNet.WebSockets.Client": "1.0.0-*" + "Microsoft.AspNetCore.WebSockets.Protocol": "1.0.0-*", + "Microsoft.AspNetCore.WebSockets.Client": "1.0.0-*" }, "frameworks": { "dnx451": { } From 9beb46dff111741cffd8eb64db255a3f0446c424 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Fri, 22 Jan 2016 12:28:42 -0800 Subject: [PATCH 177/453] Update ASP.NET 5 versions for ASP.NET Core. See https://github.com/aspnet/Announcements/issues/144 for more information. --- .../project.json | 6 ++-- .../project.json | 4 +-- .../project.json | 6 ++-- test/AutobahnTestClient/Project.json | 20 ++++++------- test/AutobahnTestServer/Project.json | 8 ++--- .../project.json | 30 +++++++++---------- .../project.json | 24 +++++++-------- test/TestClient/project.json | 22 +++++++------- 8 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/Microsoft.AspNetCore.WebSockets.Client/project.json b/src/Microsoft.AspNetCore.WebSockets.Client/project.json index 71bae93c68..f060d59f35 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Client/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Client/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-*", + "version": "0.1.0-*", "description": "Client for communicating over web sockets.", "repository": { "type": "git", @@ -10,9 +10,9 @@ "keyFile": "../../tools/Key.snk" }, "dependencies": { - "Microsoft.AspNetCore.WebSockets.Protocol": "1.0.0-*" + "Microsoft.AspNetCore.WebSockets.Protocol": "0.1.0-*" }, "frameworks": { - "net451": { } + "net451": {} } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json index c268656661..8cb70926b9 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-*", + "version": "0.1.0-*", "description": "Managed web socket protocol parser.", "repository": { "type": "git", @@ -28,4 +28,4 @@ } } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/project.json b/src/Microsoft.AspNetCore.WebSockets.Server/project.json index df9dd72cdd..bd3c467577 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Server/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Server/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-*", + "version": "0.1.0-*", "compilationOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk" @@ -11,7 +11,7 @@ }, "dependencies": { "Microsoft.AspNetCore.Http.Extensions": "1.0.0-*", - "Microsoft.AspNetCore.WebSockets.Protocol": "1.0.0-*", + "Microsoft.AspNetCore.WebSockets.Protocol": "0.1.0-*", "Microsoft.Extensions.Options": "1.0.0-*" }, "frameworks": { @@ -22,4 +22,4 @@ } } } -} +} \ No newline at end of file diff --git a/test/AutobahnTestClient/Project.json b/test/AutobahnTestClient/Project.json index 592bb2db4a..4df967525e 100644 --- a/test/AutobahnTestClient/Project.json +++ b/test/AutobahnTestClient/Project.json @@ -1,11 +1,11 @@ { - "dependencies": { - "Microsoft.AspNetCore.WebSockets.Client": "1.0.0-*" - }, - "commands": { - "run" : "run" - }, - "frameworks" : { - "dnx451" : { } - } -} + "dependencies": { + "Microsoft.AspNetCore.WebSockets.Client": "0.1.0-*" + }, + "commands": { + "run": "run" + }, + "frameworks": { + "dnx451": {} + } +} \ No newline at end of file diff --git a/test/AutobahnTestServer/Project.json b/test/AutobahnTestServer/Project.json index 10188cf800..1ddb6860e7 100644 --- a/test/AutobahnTestServer/Project.json +++ b/test/AutobahnTestServer/Project.json @@ -1,7 +1,7 @@ { "exclude": "wwwroot/**/*", "dependencies": { - "Microsoft.AspNetCore.WebSockets.Server": "1.0.0-*", + "Microsoft.AspNetCore.WebSockets.Server": "0.1.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*" }, "compilationOptions": { @@ -11,7 +11,7 @@ "web": "AutobahnTestServer" }, "frameworks": { - "dnx451": { }, - "dnxcore50": { } + "dnx451": {}, + "dnxcore50": {} } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json index 228d842348..668a4fd631 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json @@ -1,16 +1,16 @@ { - "dependencies": { - "Microsoft.AspNetCore.WebSockets.Protocol": "1.0.0-*", - "Microsoft.AspNetCore.WebSockets.Client": "1.0.0-*", - "Microsoft.AspNetCore.WebSockets.Server": "1.0.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", - "Microsoft.AspNetCore.Testing": "1.0.0-*", - "xunit.runner.aspnet": "2.0.0-aspnet-*" - }, - "frameworks": { - "dnx451": { } - }, - "commands": { - "test": "xunit.runner.aspnet" - } -} + "dependencies": { + "Microsoft.AspNetCore.WebSockets.Protocol": "0.1.0-*", + "Microsoft.AspNetCore.WebSockets.Client": "0.1.0-*", + "Microsoft.AspNetCore.WebSockets.Server": "0.1.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", + "Microsoft.AspNetCore.Testing": "1.0.0-*", + "xunit.runner.aspnet": "2.0.0-aspnet-*" + }, + "frameworks": { + "dnx451": {} + }, + "commands": { + "test": "xunit.runner.aspnet" + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json index 263b03fb77..6048c89cf1 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json @@ -1,13 +1,13 @@ { - "dependencies": { - "Microsoft.AspNetCore.WebSockets.Protocol": "1.0.0-*", - "xunit.runner.aspnet": "2.0.0-aspnet-*" - }, - "frameworks": { - "dnx451": { }, - "dnxcore50": { } - }, - "commands": { - "test": "xunit.runner.aspnet" - } -} + "dependencies": { + "Microsoft.AspNetCore.WebSockets.Protocol": "0.1.0-*", + "xunit.runner.aspnet": "2.0.0-aspnet-*" + }, + "frameworks": { + "dnx451": {}, + "dnxcore50": {} + }, + "commands": { + "test": "xunit.runner.aspnet" + } +} \ No newline at end of file diff --git a/test/TestClient/project.json b/test/TestClient/project.json index 1b6b600c9d..7ac58fa16b 100644 --- a/test/TestClient/project.json +++ b/test/TestClient/project.json @@ -1,12 +1,12 @@ { - "commands": { - "TestClient": "TestClient" - }, - "dependencies": { - "Microsoft.AspNetCore.WebSockets.Protocol": "1.0.0-*", - "Microsoft.AspNetCore.WebSockets.Client": "1.0.0-*" - }, - "frameworks": { - "dnx451": { } - } -} + "commands": { + "TestClient": "TestClient" + }, + "dependencies": { + "Microsoft.AspNetCore.WebSockets.Protocol": "0.1.0-*", + "Microsoft.AspNetCore.WebSockets.Client": "0.1.0-*" + }, + "frameworks": { + "dnx451": {} + } +} \ No newline at end of file From 9c734ddbabd634a1a8dd263cf299f63df7f021f8 Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Wed, 3 Feb 2016 12:47:47 -0800 Subject: [PATCH 178/453] Reference Microsoft.NETCore.Platforms where necessary. --- test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json | 1 + test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json | 1 + 2 files changed, 2 insertions(+) diff --git a/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json index 668a4fd631..de12b42029 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json @@ -5,6 +5,7 @@ "Microsoft.AspNetCore.WebSockets.Server": "0.1.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.AspNetCore.Testing": "1.0.0-*", + "Microsoft.NETCore.Platforms": "1.0.1-*", "xunit.runner.aspnet": "2.0.0-aspnet-*" }, "frameworks": { diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json index 6048c89cf1..15de66709f 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json @@ -1,6 +1,7 @@ { "dependencies": { "Microsoft.AspNetCore.WebSockets.Protocol": "0.1.0-*", + "Microsoft.NETCore.Platforms": "1.0.1-*", "xunit.runner.aspnet": "2.0.0-aspnet-*" }, "frameworks": { From ce2f823c7d81adceda209ba32fd1a3eec7fb8b9a Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Wed, 20 Jan 2016 16:00:12 -0800 Subject: [PATCH 179/453] Build with dotnet (#70). --- .gitattributes | 2 + .gitignore | 2 + .travis.yml | 4 ++ NuGet.config | 2 +- appveyor.yml | 2 +- build.cmd | 68 +++++++++---------- build.sh | 42 ++++++------ makefile.shade | 7 -- test/AutobahnTestClient/Program.cs | 9 ++- .../{Project.json => project.json} | 6 +- .../{Project.json => project.json} | 9 ++- .../project.json | 9 +-- .../project.json | 19 +++++- 13 files changed, 99 insertions(+), 82 deletions(-) delete mode 100644 makefile.shade rename test/AutobahnTestClient/{Project.json => project.json} (70%) rename test/AutobahnTestServer/{Project.json => project.json} (63%) diff --git a/.gitattributes b/.gitattributes index bdaa5ba982..c2f0f84273 100644 --- a/.gitattributes +++ b/.gitattributes @@ -48,3 +48,5 @@ *.fsproj text=auto *.dbproj text=auto *.sln text=auto eol=crlf + +*.sh eol=lf \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2837d3092b..308fec5350 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,5 @@ nuget.exe *.sln.ide project.lock.json /.vs/ +.testPublish/ +.build/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 4965a261c5..529ee1b402 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,5 +22,9 @@ install: - cd $OLDPWD mono: - 4.0.5 +os: + - linux + - osx +osx_image: xcode7.1 script: - ./build.sh --quiet verify diff --git a/NuGet.config b/NuGet.config index 1707938c61..8de7d930c6 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 636a7618d3..72bddecb4b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,4 +4,4 @@ build_script: - build.cmd --quiet verify clone_depth: 1 test: off -deploy: off \ No newline at end of file +deploy: off diff --git a/build.cmd b/build.cmd index 553e3929a0..936a70fc02 100644 --- a/build.cmd +++ b/build.cmd @@ -1,40 +1,40 @@ -@echo off -cd %~dp0 - +@ECHO off SETLOCAL + +SET REPO_FOLDER=%~dp0 +CD "%REPO_FOLDER%" + +SET BUILD_FOLDER=.build +SET KOREBUILD_FOLDER=%BUILD_FOLDER%\KoreBuild-dotnet +SET KOREBUILD_VERSION= + +SET NUGET_PATH=%BUILD_FOLDER%\NuGet.exe SET NUGET_VERSION=latest SET CACHED_NUGET=%LocalAppData%\NuGet\nuget.%NUGET_VERSION%.exe -SET BUILDCMD_KOREBUILD_VERSION= -SET BUILDCMD_DNX_VERSION= -IF EXIST %CACHED_NUGET% goto copynuget -echo Downloading latest version of NuGet.exe... -IF NOT EXIST %LocalAppData%\NuGet md %LocalAppData%\NuGet -@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/%NUGET_VERSION%/nuget.exe' -OutFile '%CACHED_NUGET%'" - -:copynuget -IF EXIST .nuget\nuget.exe goto restore -md .nuget -copy %CACHED_NUGET% .nuget\nuget.exe > nul - -:restore -IF EXIST packages\Sake goto getdnx -IF "%BUILDCMD_KOREBUILD_VERSION%"=="" ( - .nuget\nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre -) ELSE ( - .nuget\nuget.exe install KoreBuild -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre -) -.nuget\NuGet.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages - -:getdnx -IF "%BUILDCMD_DNX_VERSION%"=="" ( - SET BUILDCMD_DNX_VERSION=latest -) -IF "%SKIP_DNX_INSTALL%"=="" ( - CALL packages\KoreBuild\build\dnvm install %BUILDCMD_DNX_VERSION% -runtime CoreCLR -arch x86 -alias default - CALL packages\KoreBuild\build\dnvm install default -runtime CLR -arch x86 -alias default -) ELSE ( - CALL packages\KoreBuild\build\dnvm use default -runtime CLR -arch x86 +IF NOT EXIST %BUILD_FOLDER% ( + md %BUILD_FOLDER% ) -packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* +IF NOT EXIST %NUGET_PATH% ( + IF NOT EXIST %CACHED_NUGET% ( + echo Downloading latest version of NuGet.exe... + IF NOT EXIST %LocalAppData%\NuGet ( + md %LocalAppData%\NuGet + ) + @powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/%NUGET_VERSION%/nuget.exe' -OutFile '%CACHED_NUGET%'" + ) + + copy %CACHED_NUGET% %NUGET_PATH% > nul +) + +IF NOT EXIST %KOREBUILD_FOLDER% ( + SET KOREBUILD_DOWNLOAD_ARGS= + IF NOT "%KOREBUILD_VERSION%"=="" ( + SET KOREBUILD_DOWNLOAD_ARGS=-version %KOREBUILD_VERSION% + ) + + %BUILD_FOLDER%\nuget.exe install KoreBuild-dotnet -ExcludeVersion -o %BUILD_FOLDER% -nocache -pre %KOREBUILD_DOWNLOAD_ARGS% +) + +"%KOREBUILD_FOLDER%\build\KoreBuild.cmd" %* \ No newline at end of file diff --git a/build.sh b/build.sh index da4e3fcd1c..c99124455c 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,10 @@ #!/usr/bin/env bash +buildFolder=.build +koreBuildFolder=$buildFolder/KoreBuild-dotnet + +nugetPath=$buildFolder/nuget.exe + if test `uname` = Darwin; then cachedir=~/Library/Caches/KBuild else @@ -11,33 +16,30 @@ else fi mkdir -p $cachedir nugetVersion=latest -cachePath=$cachedir/nuget.$nugetVersion.exe +cacheNuget=$cachedir/nuget.$nugetVersion.exe -url=https://dist.nuget.org/win-x86-commandline/$nugetVersion/nuget.exe +nugetUrl=https://dist.nuget.org/win-x86-commandline/$nugetVersion/nuget.exe -if test ! -f $cachePath; then - wget -O $cachePath $url 2>/dev/null || curl -o $cachePath --location $url /dev/null +if test ! -d $buildFolder; then + mkdir $buildFolder fi -if test ! -e .nuget; then - mkdir .nuget - cp $cachePath .nuget/nuget.exe +if test ! -f $nugetPath; then + if test ! -f $cacheNuget; then + wget -O $cacheNuget $nugetUrl 2>/dev/null || curl -o $cacheNuget --location $nugetUrl /dev/null + fi + + cp $cacheNuget $nugetPath fi -if test ! -d packages/Sake; then - mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre - mono .nuget/nuget.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages +if test ! -d $koreBuildFolder; then + mono $nugetPath install KoreBuild-dotnet -ExcludeVersion -o $buildFolder -nocache -pre + chmod +x $koreBuildFolder/build/KoreBuild.sh fi -if ! type dnvm > /dev/null 2>&1; then - source packages/KoreBuild/build/dnvm.sh +makeFile=makefile.shade +if [ ! -e $makeFile ]; then + makeFile=$koreBuildFolder/build/makefile.shade fi -if ! type dnx > /dev/null 2>&1 || [ -z "$SKIP_DNX_INSTALL" ]; then - dnvm install latest -runtime coreclr -alias default - dnvm install default -runtime mono -alias default -else - dnvm use default -runtime mono -fi - -mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" +./$koreBuildFolder/build/KoreBuild.sh -n $nugetPath -m $makeFile "$@" \ No newline at end of file diff --git a/makefile.shade b/makefile.shade deleted file mode 100644 index 562494d144..0000000000 --- a/makefile.shade +++ /dev/null @@ -1,7 +0,0 @@ - -var VERSION='0.1' -var FULL_VERSION='0.1' -var AUTHORS='Microsoft Open Technologies, Inc.' - -use-standard-lifecycle -k-standard-goals diff --git a/test/AutobahnTestClient/Program.cs b/test/AutobahnTestClient/Program.cs index d6251c8b6f..6a3ae749a7 100644 --- a/test/AutobahnTestClient/Program.cs +++ b/test/AutobahnTestClient/Program.cs @@ -12,11 +12,16 @@ namespace AutobahnTestClient { public class Program { - public async Task Main(string[] args) + public static void Main(string[] args) + { + new Program().Run(args).Wait(); + } + + private async Task Run(string[] args) { try { - string serverAddress = "ws://localhost:9001"; + string serverAddress = "ws://localhost:5000"; string agent = "ManagedWebSockets"; // "NativeWebSockets"; diff --git a/test/AutobahnTestClient/Project.json b/test/AutobahnTestClient/project.json similarity index 70% rename from test/AutobahnTestClient/Project.json rename to test/AutobahnTestClient/project.json index 4df967525e..2efb280920 100644 --- a/test/AutobahnTestClient/Project.json +++ b/test/AutobahnTestClient/project.json @@ -1,10 +1,10 @@ { + "compilationOptions": { + "emitEntryPoint": true + }, "dependencies": { "Microsoft.AspNetCore.WebSockets.Client": "0.1.0-*" }, - "commands": { - "run": "run" - }, "frameworks": { "dnx451": {} } diff --git a/test/AutobahnTestServer/Project.json b/test/AutobahnTestServer/project.json similarity index 63% rename from test/AutobahnTestServer/Project.json rename to test/AutobahnTestServer/project.json index 1ddb6860e7..d6f3ab082b 100644 --- a/test/AutobahnTestServer/Project.json +++ b/test/AutobahnTestServer/project.json @@ -2,16 +2,15 @@ "exclude": "wwwroot/**/*", "dependencies": { "Microsoft.AspNetCore.WebSockets.Server": "0.1.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*" + "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", + "Microsoft.NETCore.Platforms": "1.0.1-*" }, "compilationOptions": { "emitEntryPoint": true }, - "commands": { - "web": "AutobahnTestServer" - }, "frameworks": { "dnx451": {}, "dnxcore50": {} - } + }, + "content": [ "hosting.json" ] } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json index de12b42029..813176be56 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json @@ -1,17 +1,14 @@ { "dependencies": { - "Microsoft.AspNetCore.WebSockets.Protocol": "0.1.0-*", "Microsoft.AspNetCore.WebSockets.Client": "0.1.0-*", "Microsoft.AspNetCore.WebSockets.Server": "0.1.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.AspNetCore.Testing": "1.0.0-*", - "Microsoft.NETCore.Platforms": "1.0.1-*", - "xunit.runner.aspnet": "2.0.0-aspnet-*" + "xunit": "2.1.0", + "xunit.runner.console": "2.1.0" }, + "testRunner": "xunit", "frameworks": { "dnx451": {} - }, - "commands": { - "test": "xunit.runner.aspnet" } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json index 15de66709f..f189170f6f 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json @@ -2,11 +2,24 @@ "dependencies": { "Microsoft.AspNetCore.WebSockets.Protocol": "0.1.0-*", "Microsoft.NETCore.Platforms": "1.0.1-*", - "xunit.runner.aspnet": "2.0.0-aspnet-*" + "xunit": "2.1.0" }, + "testRunner": "xunit", "frameworks": { - "dnx451": {}, - "dnxcore50": {} + "dnx451": { + "frameworkAssemblies": { + "System.Runtime": "" + }, + "dependencies": { + "xunit.runner.console": "2.1.0" + } + }, + "dnxcore50": { + "dependencies": { + "xunit.runner.aspnet": "2.0.0-aspnet-*" + }, + "imports": "portable-net45+win8" + } }, "commands": { "test": "xunit.runner.aspnet" From cdf1d1f6c610e1c7bb9052f787b6b4219609ab7f Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Fri, 5 Feb 2016 17:23:13 -0800 Subject: [PATCH 180/453] Update project.json to remove redundant System.Runtime dependency. - This package is pulled in transitively. --- src/Microsoft.AspNetCore.WebSockets.Protocol/project.json | 1 - src/Microsoft.AspNetCore.WebSockets.Server/project.json | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json index 8cb70926b9..8168b11212 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json @@ -17,7 +17,6 @@ "System.IO": "4.1.0-*", "System.Linq": "4.0.1-*", "System.Net.WebSockets": "4.0.0-*", - "System.Runtime": "4.0.21-*", "System.Runtime.InteropServices": "4.0.21-*", "System.Runtime.Extensions": "4.1.0-*", "System.Security.Cryptography.Algorithms": "4.0.0-*", diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/project.json b/src/Microsoft.AspNetCore.WebSockets.Server/project.json index bd3c467577..f15bfed16e 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Server/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Server/project.json @@ -18,7 +18,6 @@ "net451": {}, "dotnet5.4": { "dependencies": { - "System.Runtime": "4.0.21-*" } } } From 99fbeb6ac37085453e8672983b77d488c3f592ee Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 8 Feb 2016 09:33:51 -0800 Subject: [PATCH 181/453] Reacting to CoreCLR package version changes --- src/Microsoft.AspNetCore.WebSockets.Protocol/project.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json index 8168b11212..101d91ae60 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json @@ -15,9 +15,9 @@ "dependencies": { "System.Diagnostics.Contracts": "4.0.1-*", "System.IO": "4.1.0-*", - "System.Linq": "4.0.1-*", + "System.Linq": "4.0.2-*", "System.Net.WebSockets": "4.0.0-*", - "System.Runtime.InteropServices": "4.0.21-*", + "System.Runtime.InteropServices": "4.1.0-*", "System.Runtime.Extensions": "4.1.0-*", "System.Security.Cryptography.Algorithms": "4.0.0-*", "System.Text.Encoding.Extensions": "4.0.11-*", From 5a8c5bf48d7943d687a0958629c8d3961c5d899d Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Tue, 9 Feb 2016 23:28:51 -0800 Subject: [PATCH 182/453] Enable tests to run using dotnet xunit runner --- test/AutobahnTestServer/project.json | 13 ++++++++++--- .../project.json | 15 ++++++--------- test/TestClient/project.json | 3 --- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/test/AutobahnTestServer/project.json b/test/AutobahnTestServer/project.json index d6f3ab082b..389fb0ae9d 100644 --- a/test/AutobahnTestServer/project.json +++ b/test/AutobahnTestServer/project.json @@ -9,8 +9,15 @@ "emitEntryPoint": true }, "frameworks": { - "dnx451": {}, - "dnxcore50": {} + "dnxcore50": { + "dependencies": { + "dotnet-test-xunit": "1.0.0-dev-*" + }, + "imports": "portable-net451+win8" + }, + "dnx451": {} }, - "content": [ "hosting.json" ] + "content": [ + "hosting.json" + ] } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json index f189170f6f..101547fcf7 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json @@ -6,6 +6,12 @@ }, "testRunner": "xunit", "frameworks": { + "dnxcore50": { + "dependencies": { + "dotnet-test-xunit": "1.0.0-dev-*" + }, + "imports": "portable-net451+win8" + }, "dnx451": { "frameworkAssemblies": { "System.Runtime": "" @@ -13,15 +19,6 @@ "dependencies": { "xunit.runner.console": "2.1.0" } - }, - "dnxcore50": { - "dependencies": { - "xunit.runner.aspnet": "2.0.0-aspnet-*" - }, - "imports": "portable-net45+win8" } - }, - "commands": { - "test": "xunit.runner.aspnet" } } \ No newline at end of file diff --git a/test/TestClient/project.json b/test/TestClient/project.json index 7ac58fa16b..d24a9e6b18 100644 --- a/test/TestClient/project.json +++ b/test/TestClient/project.json @@ -1,7 +1,4 @@ { - "commands": { - "TestClient": "TestClient" - }, "dependencies": { "Microsoft.AspNetCore.WebSockets.Protocol": "0.1.0-*", "Microsoft.AspNetCore.WebSockets.Client": "0.1.0-*" From 2abc6a23430551a259b2ccbd14c9531566579c05 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Thu, 18 Feb 2016 15:36:49 -0800 Subject: [PATCH 183/453] Update System.Linq 4.0.2-* => 4.1.0-*. --- src/Microsoft.AspNetCore.WebSockets.Protocol/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json index 101d91ae60..7da0483b3c 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json @@ -15,7 +15,7 @@ "dependencies": { "System.Diagnostics.Contracts": "4.0.1-*", "System.IO": "4.1.0-*", - "System.Linq": "4.0.2-*", + "System.Linq": "4.1.0-*", "System.Net.WebSockets": "4.0.0-*", "System.Runtime.InteropServices": "4.1.0-*", "System.Runtime.Extensions": "4.1.0-*", From 33d07b8f7ca7cfc2b17d430b1446dae1202f2e41 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Fri, 19 Feb 2016 12:29:48 -0800 Subject: [PATCH 184/453] Enabled xml doc generation --- NuGetPackageVerifier.json | 16 +++------------- .../project.json | 4 +++- .../project.json | 4 +++- .../project.json | 4 +++- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json index f6d4502671..f3fff6acbd 100644 --- a/NuGetPackageVerifier.json +++ b/NuGetPackageVerifier.json @@ -1,12 +1,7 @@ { "adx": { // Packages written by the ADX team and that ship on NuGet.org "rules": [ - "AssemblyHasDocumentFileRule", - "AssemblyHasVersionAttributesRule", - "AssemblyHasServicingAttributeRule", - "AssemblyHasNeutralResourcesLanguageAttributeRule", - "SatellitePackageRule", - "StrictSemanticVersionValidationRule" + "AdxVerificationCompositeRule" ], "packages": { "Microsoft.AspNetCore.WebSockets.Client": { }, @@ -14,14 +9,9 @@ "Microsoft.AspNetCore.WebSockets.Server": { } } }, - "Default": { // Ru les to run for packages not listed in any other set. + "Default": { // Rules to run for packages not listed in any other set. "rules": [ - "AssemblyHasDocumentFileRule", - "AssemblyHasVersionAttributesRule", - "AssemblyHasServicingAttributeRule", - "AssemblyHasNeutralResourcesLanguageAttributeRule", - "SatellitePackageRule", - "StrictSemanticVersionValidationRule" + "DefaultCompositeRule" ] } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets.Client/project.json b/src/Microsoft.AspNetCore.WebSockets.Client/project.json index f060d59f35..d18ae99dd3 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Client/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Client/project.json @@ -7,7 +7,9 @@ }, "compilationOptions": { "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk" + "keyFile": "../../tools/Key.snk", + "nowarn": [ "CS1591" ], + "xmlDoc": true }, "dependencies": { "Microsoft.AspNetCore.WebSockets.Protocol": "0.1.0-*" diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json index 7da0483b3c..5b2d663955 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json @@ -7,7 +7,9 @@ }, "compilationOptions": { "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk" + "keyFile": "../../tools/Key.snk", + "nowarn": [ "CS1591" ], + "xmlDoc": true }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/project.json b/src/Microsoft.AspNetCore.WebSockets.Server/project.json index f15bfed16e..19cf961dc0 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Server/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Server/project.json @@ -2,7 +2,9 @@ "version": "0.1.0-*", "compilationOptions": { "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk" + "keyFile": "../../tools/Key.snk", + "nowarn": [ "CS1591" ], + "xmlDoc": true }, "description": "ASP.NET 5 web socket middleware for use on top of opaque servers.", "repository": { From c5c3770f0d6c556ec0ecc8da11724e9accd0fbbf Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 19 Feb 2016 15:20:56 -0800 Subject: [PATCH 185/453] Updating test TFMs for custom test discovery --- .../Microsoft.AspNetCore.WebSockets.Client.Test/project.json | 5 +++-- .../project.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json index 813176be56..042acbfc62 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json @@ -9,6 +9,7 @@ }, "testRunner": "xunit", "frameworks": { - "dnx451": {} + "net451": {} } -} \ No newline at end of file +} + diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json index 101547fcf7..86a1be6d2a 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json @@ -12,7 +12,7 @@ }, "imports": "portable-net451+win8" }, - "dnx451": { + "net451": { "frameworkAssemblies": { "System.Runtime": "" }, @@ -21,4 +21,5 @@ } } } -} \ No newline at end of file +} + From 7ebbbce052b7104bec82cfec75326ed46a71e0d3 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Wed, 24 Feb 2016 13:13:31 -0800 Subject: [PATCH 186/453] Update `build.cmd` to match latest template - aspnet/Universe#347 - `%KOREBUILD_VERSION%` doesn't work without this fix --- build.cmd | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/build.cmd b/build.cmd index 936a70fc02..95b049cf63 100644 --- a/build.cmd +++ b/build.cmd @@ -28,13 +28,12 @@ IF NOT EXIST %NUGET_PATH% ( copy %CACHED_NUGET% %NUGET_PATH% > nul ) +SET KOREBUILD_DOWNLOAD_ARGS= +IF NOT "%KOREBUILD_VERSION%"=="" ( + SET KOREBUILD_DOWNLOAD_ARGS=-version %KOREBUILD_VERSION% +) IF NOT EXIST %KOREBUILD_FOLDER% ( - SET KOREBUILD_DOWNLOAD_ARGS= - IF NOT "%KOREBUILD_VERSION%"=="" ( - SET KOREBUILD_DOWNLOAD_ARGS=-version %KOREBUILD_VERSION% - ) - %BUILD_FOLDER%\nuget.exe install KoreBuild-dotnet -ExcludeVersion -o %BUILD_FOLDER% -nocache -pre %KOREBUILD_DOWNLOAD_ARGS% ) -"%KOREBUILD_FOLDER%\build\KoreBuild.cmd" %* \ No newline at end of file +"%KOREBUILD_FOLDER%\build\KoreBuild.cmd" %* From ef7663bee971c3b2de3c14777ada2133b091f188 Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Sat, 27 Feb 2016 12:51:14 -0800 Subject: [PATCH 187/453] Update the build scripts --- build.cmd | 41 ++----------------------------------- build.ps1 | 36 +++++++++++++++++++++++++++++++++ build.sh | 60 +++++++++++++++++++++++-------------------------------- 3 files changed, 63 insertions(+), 74 deletions(-) create mode 100644 build.ps1 diff --git a/build.cmd b/build.cmd index 95b049cf63..2fa024b15e 100644 --- a/build.cmd +++ b/build.cmd @@ -1,39 +1,2 @@ -@ECHO off -SETLOCAL - -SET REPO_FOLDER=%~dp0 -CD "%REPO_FOLDER%" - -SET BUILD_FOLDER=.build -SET KOREBUILD_FOLDER=%BUILD_FOLDER%\KoreBuild-dotnet -SET KOREBUILD_VERSION= - -SET NUGET_PATH=%BUILD_FOLDER%\NuGet.exe -SET NUGET_VERSION=latest -SET CACHED_NUGET=%LocalAppData%\NuGet\nuget.%NUGET_VERSION%.exe - -IF NOT EXIST %BUILD_FOLDER% ( - md %BUILD_FOLDER% -) - -IF NOT EXIST %NUGET_PATH% ( - IF NOT EXIST %CACHED_NUGET% ( - echo Downloading latest version of NuGet.exe... - IF NOT EXIST %LocalAppData%\NuGet ( - md %LocalAppData%\NuGet - ) - @powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/%NUGET_VERSION%/nuget.exe' -OutFile '%CACHED_NUGET%'" - ) - - copy %CACHED_NUGET% %NUGET_PATH% > nul -) - -SET KOREBUILD_DOWNLOAD_ARGS= -IF NOT "%KOREBUILD_VERSION%"=="" ( - SET KOREBUILD_DOWNLOAD_ARGS=-version %KOREBUILD_VERSION% -) -IF NOT EXIST %KOREBUILD_FOLDER% ( - %BUILD_FOLDER%\nuget.exe install KoreBuild-dotnet -ExcludeVersion -o %BUILD_FOLDER% -nocache -pre %KOREBUILD_DOWNLOAD_ARGS% -) - -"%KOREBUILD_FOLDER%\build\KoreBuild.cmd" %* +@ECHO OFF +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*" \ No newline at end of file diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000000..4fd24a30d5 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,36 @@ +cd $PSScriptRoot + +$repoFolder = $PSScriptRoot +$env:REPO_FOLDER = $repoFolder + +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +if ($env:KOREBUILD_ZIP) +{ + $koreBuildZip=$env:KOREBUILD_ZIP +} + +$buildFolder = ".build" +$buildFile="$buildFolder\KoreBuild.ps1" + +if (!(Test-Path $buildFolder)) { + Write-Host "Downloading KoreBuild from $koreBuildZip" + + $tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid() + New-Item -Path "$tempFolder" -Type directory | Out-Null + + $localZipFile="$tempFolder\korebuild.zip" + + Invoke-WebRequest $koreBuildZip -OutFile $localZipFile + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder) + + New-Item -Path "$buildFolder" -Type directory | Out-Null + copy-item "$tempFolder\**\build\*" $buildFolder -Recurse + + # Cleanup + if (Test-Path $tempFolder) { + Remove-Item -Recurse -Force $tempFolder + } +} + +&"$buildFile" $args \ No newline at end of file diff --git a/build.sh b/build.sh index c99124455c..79638d06b6 100755 --- a/build.sh +++ b/build.sh @@ -1,45 +1,35 @@ #!/usr/bin/env bash +repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd $repoFolder -buildFolder=.build -koreBuildFolder=$buildFolder/KoreBuild-dotnet - -nugetPath=$buildFolder/nuget.exe - -if test `uname` = Darwin; then - cachedir=~/Library/Caches/KBuild -else - if [ -z $XDG_DATA_HOME ]; then - cachedir=$HOME/.local/share - else - cachedir=$XDG_DATA_HOME; - fi +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +if [ ! -z $KOREBUILD_ZIP ]; then + koreBuildZip=$KOREBUILD_ZIP fi -mkdir -p $cachedir -nugetVersion=latest -cacheNuget=$cachedir/nuget.$nugetVersion.exe -nugetUrl=https://dist.nuget.org/win-x86-commandline/$nugetVersion/nuget.exe +buildFolder=".build" +buildFile="$buildFolder/KoreBuild.sh" if test ! -d $buildFolder; then + echo "Downloading KoreBuild from $koreBuildZip" + + tempFolder="/tmp/KoreBuild-$(uuidgen)" + mkdir $tempFolder + + localZipFile="$tempFolder/korebuild.zip" + + wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip /dev/null + unzip -q -d $tempFolder $localZipFile + mkdir $buildFolder -fi - -if test ! -f $nugetPath; then - if test ! -f $cacheNuget; then - wget -O $cacheNuget $nugetUrl 2>/dev/null || curl -o $cacheNuget --location $nugetUrl /dev/null + cp -r $tempFolder/**/build/** $buildFolder + + chmod +x $buildFile + + # Cleanup + if test ! -d $tempFolder; then + rm -rf $tempFolder fi - - cp $cacheNuget $nugetPath fi -if test ! -d $koreBuildFolder; then - mono $nugetPath install KoreBuild-dotnet -ExcludeVersion -o $buildFolder -nocache -pre - chmod +x $koreBuildFolder/build/KoreBuild.sh -fi - -makeFile=makefile.shade -if [ ! -e $makeFile ]; then - makeFile=$koreBuildFolder/build/makefile.shade -fi - -./$koreBuildFolder/build/KoreBuild.sh -n $nugetPath -m $makeFile "$@" \ No newline at end of file +$buildFile -r $repoFolder "$@" From b94fc1abf385775111bf10b6f302216192a6880a Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Sun, 28 Feb 2016 10:12:18 -0800 Subject: [PATCH 188/453] Return the error code from build.cmd --- build.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cmd b/build.cmd index 2fa024b15e..7d4894cb4a 100644 --- a/build.cmd +++ b/build.cmd @@ -1,2 +1,2 @@ @ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*" \ No newline at end of file +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" \ No newline at end of file From 1e06560676f424983c7cf44bf612903f566f17fc Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Tue, 1 Mar 2016 13:37:16 -0800 Subject: [PATCH 189/453] Transition to netstandard. - dotnet5.X => netstandard1.y (where y = x-1). - DNXCore50 => netstandardapp1.5. - Applied the same changes to ifdefs. --- .../project.json | 11 ++++++++--- .../project.json | 12 ++++++++---- test/AutobahnTestServer/project.json | 7 +++++-- .../BufferStream.cs | 4 ++-- .../DuplexStream.cs | 4 ++-- .../project.json | 10 ++++++---- 6 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json index 5b2d663955..1683ce7194 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json @@ -8,12 +8,14 @@ "compilationOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", - "nowarn": [ "CS1591" ], + "nowarn": [ + "CS1591" + ], "xmlDoc": true }, "frameworks": { "net451": {}, - "dotnet5.4": { + "netstandard1.3": { "dependencies": { "System.Diagnostics.Contracts": "4.0.1-*", "System.IO": "4.1.0-*", @@ -26,7 +28,10 @@ "System.Threading": "4.0.11-*", "System.Threading.Tasks": "4.0.11-*", "System.Threading.Timer": "4.0.1-*" - } + }, + "imports": [ + "dotnet5.4" + ] } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/project.json b/src/Microsoft.AspNetCore.WebSockets.Server/project.json index 19cf961dc0..0a870c23b6 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Server/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Server/project.json @@ -3,7 +3,9 @@ "compilationOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", - "nowarn": [ "CS1591" ], + "nowarn": [ + "CS1591" + ], "xmlDoc": true }, "description": "ASP.NET 5 web socket middleware for use on top of opaque servers.", @@ -18,9 +20,11 @@ }, "frameworks": { "net451": {}, - "dotnet5.4": { - "dependencies": { - } + "netstandard1.3": { + "dependencies": {}, + "imports": [ + "dotnet5.4" + ] } } } \ No newline at end of file diff --git a/test/AutobahnTestServer/project.json b/test/AutobahnTestServer/project.json index 389fb0ae9d..50b5275ea8 100644 --- a/test/AutobahnTestServer/project.json +++ b/test/AutobahnTestServer/project.json @@ -9,11 +9,14 @@ "emitEntryPoint": true }, "frameworks": { - "dnxcore50": { + "netstandardapp1.5": { "dependencies": { "dotnet-test-xunit": "1.0.0-dev-*" }, - "imports": "portable-net451+win8" + "imports": [ + "dnxcore50", + "portable-net451+win8" + ] }, "dnx451": {} }, diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/BufferStream.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/BufferStream.cs index 4a36510666..49d8955bb1 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/BufferStream.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/BufferStream.cs @@ -138,7 +138,7 @@ namespace Microsoft.AspNetCore.WebSockets.Protocol.Test } } -#if !DNXCORE50 +#if !NETSTANDARDAPP1_5 public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { // TODO: This option doesn't preserve the state object. @@ -226,7 +226,7 @@ namespace Microsoft.AspNetCore.WebSockets.Protocol.Test } } -#if !DNXCORE50 +#if !NETSTANDARDAPP1_5 public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { Write(buffer, offset, count); diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexStream.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexStream.cs index 095029e5d8..68fe1bca24 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexStream.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexStream.cs @@ -93,7 +93,7 @@ namespace Microsoft.AspNetCore.WebSockets.Protocol.Test return _readStream.Read(buffer, offset, count); } -#if !DNXCORE50 +#if !NETSTANDARDAPP1_5 public override int ReadByte() { return _readStream.ReadByte(); @@ -129,7 +129,7 @@ namespace Microsoft.AspNetCore.WebSockets.Protocol.Test _writeStream.Write(buffer, offset, count); } -#if !DNXCORE50 +#if !NETSTANDARDAPP1_5 public override void WriteByte(byte value) { _writeStream.WriteByte(value); diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json index 86a1be6d2a..76c0806699 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json @@ -6,11 +6,14 @@ }, "testRunner": "xunit", "frameworks": { - "dnxcore50": { + "netstandardapp1.5": { "dependencies": { "dotnet-test-xunit": "1.0.0-dev-*" }, - "imports": "portable-net451+win8" + "imports": [ + "dnxcore50", + "portable-net451+win8" + ] }, "net451": { "frameworkAssemblies": { @@ -21,5 +24,4 @@ } } } -} - +} \ No newline at end of file From 51997b2bfcb8ce4a86e9bef8f5fa4b6bbc6c3a9d Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Wed, 2 Mar 2016 21:40:10 -0800 Subject: [PATCH 190/453] Remove project name from output path - aspnet/Coherence-Signed#187 - remove `` settings but maintain other unique aspects e.g. `` - in a few cases, standardize on VS version `14.0` and not something more specific --- .../Microsoft.AspNetCore.WebSockets.Client.xproj | 2 +- .../Microsoft.AspNetCore.WebSockets.Protocol.xproj | 2 +- .../Microsoft.AspNetCore.WebSockets.Server.xproj | 2 +- test/AutobahnTestClient/AutobahnTestClient.xproj | 2 +- test/AutobahnTestServer/AutobahnTestServer.xproj | 2 +- .../Microsoft.AspNetCore.WebSockets.Client.Test.xproj | 2 +- .../Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj | 2 +- test/TestClient/TestClient.xproj | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.AspNetCore.WebSockets.Client/Microsoft.AspNetCore.WebSockets.Client.xproj b/src/Microsoft.AspNetCore.WebSockets.Client/Microsoft.AspNetCore.WebSockets.Client.xproj index 307cbf106e..2d11eee57c 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Client/Microsoft.AspNetCore.WebSockets.Client.xproj +++ b/src/Microsoft.AspNetCore.WebSockets.Client/Microsoft.AspNetCore.WebSockets.Client.xproj @@ -8,7 +8,7 @@ 4a1c4875-ae21-4a78-979a-f0e4df5eb518 ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/Microsoft.AspNetCore.WebSockets.Protocol.xproj b/src/Microsoft.AspNetCore.WebSockets.Protocol/Microsoft.AspNetCore.WebSockets.Protocol.xproj index a0179fbe4e..d2b2f77a01 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/Microsoft.AspNetCore.WebSockets.Protocol.xproj +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/Microsoft.AspNetCore.WebSockets.Protocol.xproj @@ -8,7 +8,7 @@ e0c10dec-3339-4a47-85bc-3100c5d34ad4 ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/Microsoft.AspNetCore.WebSockets.Server.xproj b/src/Microsoft.AspNetCore.WebSockets.Server/Microsoft.AspNetCore.WebSockets.Server.xproj index 2fdc3122ed..e6fdc5ade6 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Server/Microsoft.AspNetCore.WebSockets.Server.xproj +++ b/src/Microsoft.AspNetCore.WebSockets.Server/Microsoft.AspNetCore.WebSockets.Server.xproj @@ -8,7 +8,7 @@ 78a097d0-c0a4-4aed-93e2-84a65392fb52 ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/test/AutobahnTestClient/AutobahnTestClient.xproj b/test/AutobahnTestClient/AutobahnTestClient.xproj index 3c518c8c0c..386133d0f3 100644 --- a/test/AutobahnTestClient/AutobahnTestClient.xproj +++ b/test/AutobahnTestClient/AutobahnTestClient.xproj @@ -8,7 +8,7 @@ bc4d2bb1-05a8-4816-8bc1-3a664f09ee32 ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/test/AutobahnTestServer/AutobahnTestServer.xproj b/test/AutobahnTestServer/AutobahnTestServer.xproj index 9ae4693c51..8dcdc25349 100644 --- a/test/AutobahnTestServer/AutobahnTestServer.xproj +++ b/test/AutobahnTestServer/AutobahnTestServer.xproj @@ -8,7 +8,7 @@ c03c43fe-9201-48a6-b434-ad67ef627d67 ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/test/Microsoft.AspNetCore.WebSockets.Client.Test/Microsoft.AspNetCore.WebSockets.Client.Test.xproj b/test/Microsoft.AspNetCore.WebSockets.Client.Test/Microsoft.AspNetCore.WebSockets.Client.Test.xproj index 8111420e1d..3a5c5703c0 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Client.Test/Microsoft.AspNetCore.WebSockets.Client.Test.xproj +++ b/test/Microsoft.AspNetCore.WebSockets.Client.Test/Microsoft.AspNetCore.WebSockets.Client.Test.xproj @@ -8,7 +8,7 @@ 6604d154-817f-4bc5-be95-ff7e851179d9 ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj index 73851f8030..8a43569474 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj @@ -8,7 +8,7 @@ 62a07a24-4d06-4dda-b6bf-02d0c9cb7d32 ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/test/TestClient/TestClient.xproj b/test/TestClient/TestClient.xproj index a30c5b238d..d04078df6e 100644 --- a/test/TestClient/TestClient.xproj +++ b/test/TestClient/TestClient.xproj @@ -8,7 +8,7 @@ 8c8eac01-dc49-4c5e-b348-e4e46fe675f9 ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 From a561fecb91bc347d14cc38a8cbff40e092cad67f Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Thu, 3 Mar 2016 17:33:30 -0800 Subject: [PATCH 191/453] Added Company, Copyright and Product attributes to AssemblyInfo --- .../Properties/AssemblyInfo.cs | 5 ++++- .../Properties/AssemblyInfo.cs | 3 +++ .../Properties/AssemblyInfo.cs | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.WebSockets.Client/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.WebSockets.Client/Properties/AssemblyInfo.cs index b2437d9ad6..76feceeff0 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Client/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.WebSockets.Client/Properties/AssemblyInfo.cs @@ -5,4 +5,7 @@ using System.Reflection; using System.Resources; [assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] \ No newline at end of file +[assembly: NeutralResourcesLanguage("en-us")] +[assembly: AssemblyCompany("Microsoft Corporation.")] +[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] +[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/Properties/AssemblyInfo.cs index 1a71cec2c5..3a5a80986b 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/Properties/AssemblyInfo.cs @@ -37,3 +37,6 @@ using System.Runtime.InteropServices; [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: NeutralResourcesLanguage("en-us")] +[assembly: AssemblyCompany("Microsoft Corporation.")] +[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] +[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.WebSockets.Server/Properties/AssemblyInfo.cs index b2437d9ad6..76feceeff0 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Server/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.WebSockets.Server/Properties/AssemblyInfo.cs @@ -5,4 +5,7 @@ using System.Reflection; using System.Resources; [assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] \ No newline at end of file +[assembly: NeutralResourcesLanguage("en-us")] +[assembly: AssemblyCompany("Microsoft Corporation.")] +[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] +[assembly: AssemblyProduct("Microsoft ASP.NET Core")] From 8474003b1494854c90141fa7494f3f017d756689 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Thu, 3 Mar 2016 22:45:10 -0800 Subject: [PATCH 192/453] Removed duplicate attributes --- .../Properties/AssemblyInfo.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/Properties/AssemblyInfo.cs index 3a5a80986b..e33fcad3b6 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/Properties/AssemblyInfo.cs @@ -9,9 +9,6 @@ using System.Runtime.InteropServices; [assembly: AssemblyTitle("Microsoft.Net.WebSockets")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Microsoft.Net.WebSockets")] -[assembly: AssemblyCopyright("Copyright © 2014")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] From dd7c6750ac0c98bad0a7b892fb2f0ed2f5677675 Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Mon, 7 Mar 2016 20:55:03 -0800 Subject: [PATCH 193/453] Update the build scripts to the latest version --- build.ps1 | 33 ++++++++++++++++++++++++++++++++- build.sh | 15 +++++++++++++-- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/build.ps1 b/build.ps1 index 4fd24a30d5..8f2f99691a 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,3 +1,33 @@ +$ErrorActionPreference = "Stop" + +function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries) +{ + while($true) + { + try + { + Invoke-WebRequest $url -OutFile $downloadLocation + break + } + catch + { + $exceptionMessage = $_.Exception.Message + Write-Host "Failed to download '$url': $exceptionMessage" + if ($retries -gt 0) { + $retries-- + Write-Host "Waiting 10 seconds before retrying. Retries left: $retries" + Start-Sleep -Seconds 10 + + } + else + { + $exception = $_.Exception + throw $exception + } + } + } +} + cd $PSScriptRoot $repoFolder = $PSScriptRoot @@ -20,7 +50,8 @@ if (!(Test-Path $buildFolder)) { $localZipFile="$tempFolder\korebuild.zip" - Invoke-WebRequest $koreBuildZip -OutFile $localZipFile + DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6 + Add-Type -AssemblyName System.IO.Compression.FileSystem [System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder) diff --git a/build.sh b/build.sh index 79638d06b6..f4208100eb 100755 --- a/build.sh +++ b/build.sh @@ -18,7 +18,18 @@ if test ! -d $buildFolder; then localZipFile="$tempFolder/korebuild.zip" - wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip /dev/null + retries=6 + until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null) + do + echo "Failed to download '$koreBuildZip'" + if [ "$retries" -le 0 ]; then + exit 1 + fi + retries=$((retries - 1)) + echo "Waiting 10 seconds before retrying. Retries left: $retries" + sleep 10s + done + unzip -q -d $tempFolder $localZipFile mkdir $buildFolder @@ -32,4 +43,4 @@ if test ! -d $buildFolder; then fi fi -$buildFile -r $repoFolder "$@" +$buildFile -r $repoFolder "$@" \ No newline at end of file From 3f70b6a7cf252e4ec3e82b63258bf8b9732e7665 Mon Sep 17 00:00:00 2001 From: Chris R Date: Tue, 8 Mar 2016 12:13:12 -0800 Subject: [PATCH 194/453] Comment out unreachable test code. --- test/TestClient/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/TestClient/Program.cs b/test/TestClient/Program.cs index 7be260b81c..da50641682 100644 --- a/test/TestClient/Program.cs +++ b/test/TestClient/Program.cs @@ -45,7 +45,7 @@ namespace TestClient } while (!result.EndOfMessage); Console.WriteLine(Encoding.UTF8.GetString(data, 0, result.Count)); } - await socket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Closing", CancellationToken.None); + // await socket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Closing", CancellationToken.None); } } } From 65a9fd2ba92fa050bce723df906b2f415bbb0ac5 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 9 Mar 2016 16:35:05 -0800 Subject: [PATCH 195/453] Limit the branches that build on our public CI. [ci skip] --- .travis.yml | 6 ++++++ appveyor.yml | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/.travis.yml b/.travis.yml index 529ee1b402..d56f8886e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,5 +26,11 @@ os: - linux - osx osx_image: xcode7.1 +branches: + only: + - master + - release + - dev + - /^(.*\\/)?ci-.*$/ script: - ./build.sh --quiet verify diff --git a/appveyor.yml b/appveyor.yml index 72bddecb4b..f3128b0ec3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,11 @@ init: - git config --global core.autocrlf true +branches: + only: + - master + - release + - dev + - /^(.*\\/)?ci-.*$/ build_script: - build.cmd --quiet verify clone_depth: 1 From 2dba840f9435d67eb3143eb1972880cfaf32bba3 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 9 Mar 2016 17:44:49 -0800 Subject: [PATCH 196/453] Fix backslashes in yml config. [ci skip] --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d56f8886e2..a775dfa85c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,6 +31,6 @@ branches: - master - release - dev - - /^(.*\\/)?ci-.*$/ + - /^(.*\/)?ci-.*$/ script: - ./build.sh --quiet verify diff --git a/appveyor.yml b/appveyor.yml index f3128b0ec3..81cbe23e0c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,7 +5,7 @@ branches: - master - release - dev - - /^(.*\\/)?ci-.*$/ + - /^(.*\/)?ci-.*$/ build_script: - build.cmd --quiet verify clone_depth: 1 From 8e01db2c70e273b52e66be73d81ab082051d9651 Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Mon, 14 Mar 2016 21:50:34 -0700 Subject: [PATCH 197/453] ASP.NET 5 -> ASP.NET Core --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 981faf141a..5dea9440f3 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Travis: [![Travis](https://travis-ci.org/aspnet/WebSockets.svg?branch=dev)](ht Contains a managed implementation of the WebSocket protocol, along with client and server integration components. -This project is part of ASP.NET 5. You can find samples, documentation and getting started instructions for ASP.NET 5 at the [Home](https://github.com/aspnet/home) repo. +This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at the [Home](https://github.com/aspnet/home) repo. From 0f9e4eba024078d2b0b2f1efb70a594b9ee70d0c Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Fri, 18 Mar 2016 17:16:06 -0700 Subject: [PATCH 198/453] React to HttpAbstractions change: `WebSocketAcceptContext` in new namespace - see issue aspnet/HttpAbstractions#590 and pull aspnet/HttpAbstractions#589 --- .../ExtendedWebSocketAcceptContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/ExtendedWebSocketAcceptContext.cs b/src/Microsoft.AspNetCore.WebSockets.Server/ExtendedWebSocketAcceptContext.cs index 7d0ba9b945..eb6fd197c1 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Server/ExtendedWebSocketAcceptContext.cs +++ b/src/Microsoft.AspNetCore.WebSockets.Server/ExtendedWebSocketAcceptContext.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNetCore.Http.Features; +using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.WebSockets.Server { From 21a2acc927e036dee9cd1273f676ca66838fddb8 Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 22 Mar 2016 11:57:03 -0700 Subject: [PATCH 199/453] Reacting to Hosting changes --- test/AutobahnTestServer/Startup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/AutobahnTestServer/Startup.cs b/test/AutobahnTestServer/Startup.cs index 023d05ffaa..7340f0d3ff 100644 --- a/test/AutobahnTestServer/Startup.cs +++ b/test/AutobahnTestServer/Startup.cs @@ -73,7 +73,7 @@ namespace AutobahnTestServer public static void Main(string[] args) { var host = new WebHostBuilder() - .UseDefaultConfiguration(args) + .UseDefaultHostingConfiguration(args) .UseStartup() .Build(); From 4e78a2d02ec2ff7f8646d8d4c2a34fd188b36762 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Fri, 25 Mar 2016 09:28:20 -0700 Subject: [PATCH 200/453] Fixed build --- test/AutobahnTestServer/project.json | 7 ++++--- .../project.json | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/test/AutobahnTestServer/project.json b/test/AutobahnTestServer/project.json index 50b5275ea8..8f0856bc61 100644 --- a/test/AutobahnTestServer/project.json +++ b/test/AutobahnTestServer/project.json @@ -2,8 +2,7 @@ "exclude": "wwwroot/**/*", "dependencies": { "Microsoft.AspNetCore.WebSockets.Server": "0.1.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", - "Microsoft.NETCore.Platforms": "1.0.1-*" + "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*" }, "compilationOptions": { "emitEntryPoint": true @@ -11,7 +10,9 @@ "frameworks": { "netstandardapp1.5": { "dependencies": { - "dotnet-test-xunit": "1.0.0-dev-*" + "dotnet-test-xunit": "1.0.0-dev-*", + "NETStandard.Library": "1.5.0-*", + "System.Diagnostics.Process": "4.1.0-*" }, "imports": [ "dnxcore50", diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json index 76c0806699..5b120f6d85 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json @@ -1,14 +1,15 @@ { "dependencies": { "Microsoft.AspNetCore.WebSockets.Protocol": "0.1.0-*", - "Microsoft.NETCore.Platforms": "1.0.1-*", "xunit": "2.1.0" }, "testRunner": "xunit", "frameworks": { "netstandardapp1.5": { "dependencies": { - "dotnet-test-xunit": "1.0.0-dev-*" + "dotnet-test-xunit": "1.0.0-dev-*", + "NETStandard.Library": "1.5.0-*", + "System.Diagnostics.Process": "4.1.0-*" }, "imports": [ "dnxcore50", From a51ba19b16c2bfbd58ab2603fb9a5d49d1b62395 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 30 Mar 2016 16:02:47 -0700 Subject: [PATCH 201/453] Update samples --- test/AutobahnTestServer/Startup.cs | 1 + test/AutobahnTestServer/hosting.json | 3 --- .../KestrelWebSocketHelpers.cs | 3 ++- 3 files changed, 3 insertions(+), 4 deletions(-) delete mode 100644 test/AutobahnTestServer/hosting.json diff --git a/test/AutobahnTestServer/Startup.cs b/test/AutobahnTestServer/Startup.cs index 7340f0d3ff..a4c6b989fa 100644 --- a/test/AutobahnTestServer/Startup.cs +++ b/test/AutobahnTestServer/Startup.cs @@ -74,6 +74,7 @@ namespace AutobahnTestServer { var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) + .UseKestrel() .UseStartup() .Build(); diff --git a/test/AutobahnTestServer/hosting.json b/test/AutobahnTestServer/hosting.json deleted file mode 100644 index 6a93dbafa8..0000000000 --- a/test/AutobahnTestServer/hosting.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "server": "Microsoft.AspNetCore.Server.Kestrel" -} diff --git a/test/Microsoft.AspNetCore.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNetCore.WebSockets.Client.Test/KestrelWebSocketHelpers.cs index d496873e16..b6bc9250d8 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Client.Test/KestrelWebSocketHelpers.cs @@ -47,7 +47,7 @@ namespace Microsoft.AspNetCore.WebSockets.Client.Test var host = new WebHostBuilder() .UseConfiguration(config) - .UseServer("Microsoft.AspNetCore.Server.Kestrel") + .UseKestrel() .Configure(startup) .Build(); @@ -57,3 +57,4 @@ namespace Microsoft.AspNetCore.WebSockets.Client.Test } } } + From 52c84c99402bf0b707af290ce5c66613539fd850 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 6 Apr 2016 09:47:46 -0700 Subject: [PATCH 202/453] Updating to release. --- NuGet.config | 2 +- build.ps1 | 2 +- build.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/NuGet.config b/NuGet.config index 8de7d930c6..6c18699b6e 100644 --- a/NuGet.config +++ b/NuGet.config @@ -2,6 +2,6 @@ - + \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index 8f2f99691a..cf8bff13bb 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/release.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index f4208100eb..f88fe4052e 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/release.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From 8f5a75b26b8bad8133fce0b333b6d5f4bcc253ac Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 6 Apr 2016 18:18:57 -0700 Subject: [PATCH 203/453] Fix versions --- src/Microsoft.AspNetCore.WebSockets.Protocol/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json index 1683ce7194..bdda62d981 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json @@ -23,7 +23,7 @@ "System.Net.WebSockets": "4.0.0-*", "System.Runtime.InteropServices": "4.1.0-*", "System.Runtime.Extensions": "4.1.0-*", - "System.Security.Cryptography.Algorithms": "4.0.0-*", + "System.Security.Cryptography.Algorithms": "4.1.0-*", "System.Text.Encoding.Extensions": "4.0.11-*", "System.Threading": "4.0.11-*", "System.Threading.Tasks": "4.0.11-*", From 40091fcb22e666797f34481c4b93c9229f907291 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 6 Apr 2016 19:18:10 -0700 Subject: [PATCH 204/453] Fixing build break --- src/Microsoft.AspNetCore.WebSockets.Protocol/project.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json index bdda62d981..b3571039e2 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json @@ -18,9 +18,11 @@ "netstandard1.3": { "dependencies": { "System.Diagnostics.Contracts": "4.0.1-*", + "System.Globalization": "4.0.11-*", "System.IO": "4.1.0-*", "System.Linq": "4.1.0-*", "System.Net.WebSockets": "4.0.0-*", + "System.Resources.ResourceManager": "4.0.1-*", "System.Runtime.InteropServices": "4.1.0-*", "System.Runtime.Extensions": "4.1.0-*", "System.Security.Cryptography.Algorithms": "4.1.0-*", From e06a0f0898c6ded793b9cc80083a3625c45f5597 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 7 Apr 2016 15:51:05 -0700 Subject: [PATCH 205/453] Removing imports from src projects --- src/Microsoft.AspNetCore.WebSockets.Protocol/project.json | 5 +---- src/Microsoft.AspNetCore.WebSockets.Server/project.json | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json index b3571039e2..00c07d05b1 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json @@ -30,10 +30,7 @@ "System.Threading": "4.0.11-*", "System.Threading.Tasks": "4.0.11-*", "System.Threading.Timer": "4.0.1-*" - }, - "imports": [ - "dotnet5.4" - ] + } } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/project.json b/src/Microsoft.AspNetCore.WebSockets.Server/project.json index 0a870c23b6..d4bc37161a 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Server/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Server/project.json @@ -21,10 +21,7 @@ "frameworks": { "net451": {}, "netstandard1.3": { - "dependencies": {}, - "imports": [ - "dotnet5.4" - ] + "dependencies": {} } } } \ No newline at end of file From 86befd91ded497ca9e11aa3159b7f9c4073d7eed Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Fri, 15 Apr 2016 11:57:34 -0700 Subject: [PATCH 206/453] Migrate tests, tools and samples to portable --- test/AutobahnTestClient/project.json | 2 +- test/AutobahnTestServer/project.json | 9 ++++++--- .../BufferStream.cs | 4 ++-- .../DuplexStream.cs | 4 ++-- .../project.json | 7 +++++-- test/TestClient/project.json | 2 +- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/test/AutobahnTestClient/project.json b/test/AutobahnTestClient/project.json index 2efb280920..d464cd5c11 100644 --- a/test/AutobahnTestClient/project.json +++ b/test/AutobahnTestClient/project.json @@ -6,6 +6,6 @@ "Microsoft.AspNetCore.WebSockets.Client": "0.1.0-*" }, "frameworks": { - "dnx451": {} + "net451": {} } } \ No newline at end of file diff --git a/test/AutobahnTestServer/project.json b/test/AutobahnTestServer/project.json index 8f0856bc61..32f5531d86 100644 --- a/test/AutobahnTestServer/project.json +++ b/test/AutobahnTestServer/project.json @@ -8,10 +8,13 @@ "emitEntryPoint": true }, "frameworks": { - "netstandardapp1.5": { + "netcoreapp1.0": { "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0-*", + "type": "platform" + }, "dotnet-test-xunit": "1.0.0-dev-*", - "NETStandard.Library": "1.5.0-*", "System.Diagnostics.Process": "4.1.0-*" }, "imports": [ @@ -19,7 +22,7 @@ "portable-net451+win8" ] }, - "dnx451": {} + "net451": {} }, "content": [ "hosting.json" diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/BufferStream.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/BufferStream.cs index 49d8955bb1..2e900c2a5e 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/BufferStream.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/BufferStream.cs @@ -138,7 +138,7 @@ namespace Microsoft.AspNetCore.WebSockets.Protocol.Test } } -#if !NETSTANDARDAPP1_5 +#if !NETCOREAPP1_0 public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { // TODO: This option doesn't preserve the state object. @@ -226,7 +226,7 @@ namespace Microsoft.AspNetCore.WebSockets.Protocol.Test } } -#if !NETSTANDARDAPP1_5 +#if !NETCOREAPP1_0 public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { Write(buffer, offset, count); diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexStream.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexStream.cs index 68fe1bca24..0355fa44aa 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexStream.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexStream.cs @@ -93,7 +93,7 @@ namespace Microsoft.AspNetCore.WebSockets.Protocol.Test return _readStream.Read(buffer, offset, count); } -#if !NETSTANDARDAPP1_5 +#if !NETCOREAPP1_0 public override int ReadByte() { return _readStream.ReadByte(); @@ -129,7 +129,7 @@ namespace Microsoft.AspNetCore.WebSockets.Protocol.Test _writeStream.Write(buffer, offset, count); } -#if !NETSTANDARDAPP1_5 +#if !NETCOREAPP1_0 public override void WriteByte(byte value) { _writeStream.WriteByte(value); diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json index 5b120f6d85..e651871409 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json @@ -5,10 +5,13 @@ }, "testRunner": "xunit", "frameworks": { - "netstandardapp1.5": { + "netcoreapp1.0": { "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0-*", + "type": "platform" + }, "dotnet-test-xunit": "1.0.0-dev-*", - "NETStandard.Library": "1.5.0-*", "System.Diagnostics.Process": "4.1.0-*" }, "imports": [ diff --git a/test/TestClient/project.json b/test/TestClient/project.json index d24a9e6b18..2e35414780 100644 --- a/test/TestClient/project.json +++ b/test/TestClient/project.json @@ -4,6 +4,6 @@ "Microsoft.AspNetCore.WebSockets.Client": "0.1.0-*" }, "frameworks": { - "dnx451": {} + "net451": {} } } \ No newline at end of file From 4ee4c29b06b8d5d830b9186cf1f181732c3618d0 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Mon, 18 Apr 2016 17:09:11 -0700 Subject: [PATCH 207/453] Bring Microsoft.NETCore.Platforms dependency back --- test/AutobahnTestClient/project.json | 1 + test/AutobahnTestServer/project.json | 1 + test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json | 4 ++-- .../project.json | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/test/AutobahnTestClient/project.json b/test/AutobahnTestClient/project.json index d464cd5c11..d2c57323b1 100644 --- a/test/AutobahnTestClient/project.json +++ b/test/AutobahnTestClient/project.json @@ -3,6 +3,7 @@ "emitEntryPoint": true }, "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.WebSockets.Client": "0.1.0-*" }, "frameworks": { diff --git a/test/AutobahnTestServer/project.json b/test/AutobahnTestServer/project.json index 32f5531d86..1321df4158 100644 --- a/test/AutobahnTestServer/project.json +++ b/test/AutobahnTestServer/project.json @@ -1,6 +1,7 @@ { "exclude": "wwwroot/**/*", "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.WebSockets.Server": "0.1.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*" }, diff --git a/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json index 042acbfc62..a352ed1def 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json @@ -1,5 +1,6 @@ { "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.WebSockets.Client": "0.1.0-*", "Microsoft.AspNetCore.WebSockets.Server": "0.1.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", @@ -11,5 +12,4 @@ "frameworks": { "net451": {} } -} - +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json index e651871409..809da38bc4 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json @@ -1,5 +1,6 @@ { "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.WebSockets.Protocol": "0.1.0-*", "xunit": "2.1.0" }, From 4154b4c260af7f6547eabaf16ba3f354dd5133fb Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 19 Apr 2016 14:54:14 -0700 Subject: [PATCH 208/453] Use latest build of dotnet-test-xunit --- test/AutobahnTestServer/project.json | 2 +- test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/AutobahnTestServer/project.json b/test/AutobahnTestServer/project.json index 1321df4158..bffe72ff47 100644 --- a/test/AutobahnTestServer/project.json +++ b/test/AutobahnTestServer/project.json @@ -15,7 +15,7 @@ "version": "1.0.0-*", "type": "platform" }, - "dotnet-test-xunit": "1.0.0-dev-*", + "dotnet-test-xunit": "1.0.0-*", "System.Diagnostics.Process": "4.1.0-*" }, "imports": [ diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json index 809da38bc4..5ef4b2e69e 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json @@ -12,7 +12,7 @@ "version": "1.0.0-*", "type": "platform" }, - "dotnet-test-xunit": "1.0.0-dev-*", + "dotnet-test-xunit": "1.0.0-*", "System.Diagnostics.Process": "4.1.0-*" }, "imports": [ From 3615cfd28eea7fc4076de1853c88dbffdc2f25d3 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Wed, 27 Apr 2016 19:04:33 -0700 Subject: [PATCH 209/453] Remove reference to UseDefaultHostingConfiguration --- test/AutobahnTestServer/Startup.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/test/AutobahnTestServer/Startup.cs b/test/AutobahnTestServer/Startup.cs index a4c6b989fa..c3bb7e615c 100644 --- a/test/AutobahnTestServer/Startup.cs +++ b/test/AutobahnTestServer/Startup.cs @@ -73,7 +73,6 @@ namespace AutobahnTestServer public static void Main(string[] args) { var host = new WebHostBuilder() - .UseDefaultHostingConfiguration(args) .UseKestrel() .UseStartup() .Build(); From 95b6a0a9998ab7be1dfebc076f385aa2209b5dfa Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 2 May 2016 11:27:30 -0700 Subject: [PATCH 210/453] Fix build warnings --- .../project.json | 14 +++++++++----- .../project.json | 10 ++++++---- .../project.json | 10 ++++++---- test/AutobahnTestClient/project.json | 2 +- test/AutobahnTestServer/project.json | 10 ++++++---- .../project.json | 2 +- 6 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/Microsoft.AspNetCore.WebSockets.Client/project.json b/src/Microsoft.AspNetCore.WebSockets.Client/project.json index d18ae99dd3..366d975e4c 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Client/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Client/project.json @@ -1,14 +1,18 @@ { "version": "0.1.0-*", "description": "Client for communicating over web sockets.", - "repository": { - "type": "git", - "url": "git://github.com/aspnet/websockets" + "packOptions": { + "repository": { + "type": "git", + "url": "git://github.com/aspnet/websockets" + } }, - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", - "nowarn": [ "CS1591" ], + "nowarn": [ + "CS1591" + ], "xmlDoc": true }, "dependencies": { diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json index 00c07d05b1..1b903abe23 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json @@ -1,11 +1,13 @@ { "version": "0.1.0-*", "description": "Managed web socket protocol parser.", - "repository": { - "type": "git", - "url": "git://github.com/aspnet/websockets" + "packOptions": { + "repository": { + "type": "git", + "url": "git://github.com/aspnet/websockets" + } }, - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", "nowarn": [ diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/project.json b/src/Microsoft.AspNetCore.WebSockets.Server/project.json index d4bc37161a..ffef0488f2 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Server/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Server/project.json @@ -1,6 +1,6 @@ { "version": "0.1.0-*", - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", "nowarn": [ @@ -9,9 +9,11 @@ "xmlDoc": true }, "description": "ASP.NET 5 web socket middleware for use on top of opaque servers.", - "repository": { - "type": "git", - "url": "git://github.com/aspnet/websockets" + "packOptions": { + "repository": { + "type": "git", + "url": "git://github.com/aspnet/websockets" + } }, "dependencies": { "Microsoft.AspNetCore.Http.Extensions": "1.0.0-*", diff --git a/test/AutobahnTestClient/project.json b/test/AutobahnTestClient/project.json index d2c57323b1..bb1d1e8084 100644 --- a/test/AutobahnTestClient/project.json +++ b/test/AutobahnTestClient/project.json @@ -1,5 +1,5 @@ { - "compilationOptions": { + "buildOptions": { "emitEntryPoint": true }, "dependencies": { diff --git a/test/AutobahnTestServer/project.json b/test/AutobahnTestServer/project.json index bffe72ff47..0c58351c19 100644 --- a/test/AutobahnTestServer/project.json +++ b/test/AutobahnTestServer/project.json @@ -5,7 +5,7 @@ "Microsoft.AspNetCore.WebSockets.Server": "0.1.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*" }, - "compilationOptions": { + "buildOptions": { "emitEntryPoint": true }, "frameworks": { @@ -25,7 +25,9 @@ }, "net451": {} }, - "content": [ - "hosting.json" - ] + "publishOptions": { + "include": [ + "hosting.json" + ] + } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json index 5ef4b2e69e..a5c6ce28b1 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json @@ -1,5 +1,6 @@ { "dependencies": { + "dotnet-test-xunit": "1.0.0-*", "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.WebSockets.Protocol": "0.1.0-*", "xunit": "2.1.0" @@ -12,7 +13,6 @@ "version": "1.0.0-*", "type": "platform" }, - "dotnet-test-xunit": "1.0.0-*", "System.Diagnostics.Process": "4.1.0-*" }, "imports": [ From fc3ab48d61e9ee45107760af0b53a26359fae5eb Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 2 May 2016 18:12:30 -0700 Subject: [PATCH 211/453] Add dotnet-test-xunit dependency --- test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json index a352ed1def..85b3f1cbde 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json @@ -1,12 +1,12 @@ { "dependencies": { + "dotnet-test-xunit": "1.0.0-*", "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.WebSockets.Client": "0.1.0-*", "Microsoft.AspNetCore.WebSockets.Server": "0.1.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.AspNetCore.Testing": "1.0.0-*", - "xunit": "2.1.0", - "xunit.runner.console": "2.1.0" + "xunit": "2.1.0" }, "testRunner": "xunit", "frameworks": { From 37931a9fa56d558ab08130783a776fd9fc7a42ee Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 3 May 2016 18:54:36 -0700 Subject: [PATCH 212/453] Update AutobahnTestServer to use IISIntegration --- test/AutobahnTestServer/Startup.cs | 1 + test/AutobahnTestServer/project.json | 13 +++++++++++-- test/AutobahnTestServer/web.config | 9 +++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 test/AutobahnTestServer/web.config diff --git a/test/AutobahnTestServer/Startup.cs b/test/AutobahnTestServer/Startup.cs index c3bb7e615c..7330152214 100644 --- a/test/AutobahnTestServer/Startup.cs +++ b/test/AutobahnTestServer/Startup.cs @@ -74,6 +74,7 @@ namespace AutobahnTestServer { var host = new WebHostBuilder() .UseKestrel() + .UseIISIntegration() .UseStartup() .Build(); diff --git a/test/AutobahnTestServer/project.json b/test/AutobahnTestServer/project.json index 0c58351c19..ed5dca222f 100644 --- a/test/AutobahnTestServer/project.json +++ b/test/AutobahnTestServer/project.json @@ -1,8 +1,8 @@ { - "exclude": "wwwroot/**/*", "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.WebSockets.Server": "0.1.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*" }, "buildOptions": { @@ -27,7 +27,16 @@ }, "publishOptions": { "include": [ - "hosting.json" + "web.config" ] + }, + "tools": { + "Microsoft.AspNetCore.Server.IISIntegration.Tools": { + "version": "1.0.0-*", + "imports": "portable-net45+wp80+win8+wpa81+dnxcore50" + } + }, + "scripts": { + "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" } } \ No newline at end of file diff --git a/test/AutobahnTestServer/web.config b/test/AutobahnTestServer/web.config new file mode 100644 index 0000000000..41b492941a --- /dev/null +++ b/test/AutobahnTestServer/web.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file From 5ddbe386309e7b258b912e5ae44ba940558bdccd Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 17 May 2016 14:45:03 -0700 Subject: [PATCH 213/453] React to updated CoreCLR packages https://github.com/aspnet/Coherence/issues/97 --- src/Microsoft.AspNetCore.WebSockets.Protocol/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json index 1b903abe23..ca32295042 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json @@ -27,7 +27,7 @@ "System.Resources.ResourceManager": "4.0.1-*", "System.Runtime.InteropServices": "4.1.0-*", "System.Runtime.Extensions": "4.1.0-*", - "System.Security.Cryptography.Algorithms": "4.1.0-*", + "System.Security.Cryptography.Algorithms": "4.2.0-*", "System.Text.Encoding.Extensions": "4.0.11-*", "System.Threading": "4.0.11-*", "System.Threading.Tasks": "4.0.11-*", From f20a8acb617aa9c106e48a95600328690591274b Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 18 May 2016 09:42:58 -0700 Subject: [PATCH 214/453] Revert "React to updated CoreCLR packages" This reverts commit 5ddbe386309e7b258b912e5ae44ba940558bdccd. --- src/Microsoft.AspNetCore.WebSockets.Protocol/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json index ca32295042..1b903abe23 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json @@ -27,7 +27,7 @@ "System.Resources.ResourceManager": "4.0.1-*", "System.Runtime.InteropServices": "4.1.0-*", "System.Runtime.Extensions": "4.1.0-*", - "System.Security.Cryptography.Algorithms": "4.2.0-*", + "System.Security.Cryptography.Algorithms": "4.1.0-*", "System.Text.Encoding.Extensions": "4.0.11-*", "System.Threading": "4.0.11-*", "System.Threading.Tasks": "4.0.11-*", From 3a1c463e0217d49a36759d054cd262629a33a1f6 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 26 May 2016 18:19:13 -0700 Subject: [PATCH 215/453] React to updated CoreCLR packages https://github.com/aspnet/Coherence/issues/97 --- src/Microsoft.AspNetCore.WebSockets.Protocol/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json index 1b903abe23..ca32295042 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json @@ -27,7 +27,7 @@ "System.Resources.ResourceManager": "4.0.1-*", "System.Runtime.InteropServices": "4.1.0-*", "System.Runtime.Extensions": "4.1.0-*", - "System.Security.Cryptography.Algorithms": "4.1.0-*", + "System.Security.Cryptography.Algorithms": "4.2.0-*", "System.Text.Encoding.Extensions": "4.0.11-*", "System.Threading": "4.0.11-*", "System.Threading.Tasks": "4.0.11-*", From 20a5d80fca38791135b55bdaaf140f128ff5c814 Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Fri, 27 May 2016 11:38:55 -0700 Subject: [PATCH 216/453] Fix OSX build on Travis. --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index a775dfa85c..be2e4ad775 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,5 +32,7 @@ branches: - release - dev - /^(.*\/)?ci-.*$/ +before_install: + - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; brew link --force openssl; fi script: - ./build.sh --quiet verify From 263d76421554042e5029d2e3b14b7fea473349ee Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 2 Jun 2016 10:50:45 -0700 Subject: [PATCH 217/453] Fix assembly metadata to fix package verifier warnings --- .../Properties/AssemblyInfo.cs | 28 ++----------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/Properties/AssemblyInfo.cs index e33fcad3b6..916862c41d 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/Properties/AssemblyInfo.cs @@ -1,37 +1,15 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. [assembly: AssemblyTitle("Microsoft.Net.WebSockets")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] -// The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("9a9e41ae-1494-4d87-a66f-a4019ff68ce5")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: NeutralResourcesLanguage("en-us")] [assembly: AssemblyCompany("Microsoft Corporation.")] From abe0f9ed9077d9e1f22414f5faf1735ae7e22702 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Mon, 13 Jun 2016 15:30:01 -0700 Subject: [PATCH 218/453] Remove direct Microsoft.NETCore.Platforms dependency. - Microsoft.NETCore.App now pulls this package in. aspnet/Coherence-Signed#344 --- test/AutobahnTestClient/project.json | 1 - test/AutobahnTestServer/project.json | 1 - test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json | 1 - test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json | 1 - 4 files changed, 4 deletions(-) diff --git a/test/AutobahnTestClient/project.json b/test/AutobahnTestClient/project.json index bb1d1e8084..048f699897 100644 --- a/test/AutobahnTestClient/project.json +++ b/test/AutobahnTestClient/project.json @@ -3,7 +3,6 @@ "emitEntryPoint": true }, "dependencies": { - "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.WebSockets.Client": "0.1.0-*" }, "frameworks": { diff --git a/test/AutobahnTestServer/project.json b/test/AutobahnTestServer/project.json index ed5dca222f..e7ade41076 100644 --- a/test/AutobahnTestServer/project.json +++ b/test/AutobahnTestServer/project.json @@ -1,6 +1,5 @@ { "dependencies": { - "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.WebSockets.Server": "0.1.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*" diff --git a/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json index 85b3f1cbde..a86e179525 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json @@ -1,7 +1,6 @@ { "dependencies": { "dotnet-test-xunit": "1.0.0-*", - "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.WebSockets.Client": "0.1.0-*", "Microsoft.AspNetCore.WebSockets.Server": "0.1.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json index a5c6ce28b1..b2402862ef 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json @@ -1,7 +1,6 @@ { "dependencies": { "dotnet-test-xunit": "1.0.0-*", - "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.WebSockets.Protocol": "0.1.0-*", "xunit": "2.1.0" }, From fc2f0e480ea9e1451e1dd57824b187a5c840ae17 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 14 Jun 2016 16:23:09 -0700 Subject: [PATCH 219/453] Updating to release. --- NuGet.config | 2 +- build.ps1 | 2 +- build.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/NuGet.config b/NuGet.config index 8de7d930c6..6c18699b6e 100644 --- a/NuGet.config +++ b/NuGet.config @@ -2,6 +2,6 @@ - + \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index 8f2f99691a..cf8bff13bb 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/release.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index f4208100eb..f88fe4052e 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/release.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From 38ba07487a1a2820b32b4a14453821a8d4a6041e Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 16 Jun 2016 10:18:52 -0700 Subject: [PATCH 220/453] Updating to dev versions --- src/Microsoft.AspNetCore.WebSockets.Client/project.json | 4 ++-- src/Microsoft.AspNetCore.WebSockets.Protocol/project.json | 2 +- src/Microsoft.AspNetCore.WebSockets.Server/project.json | 8 ++++---- test/AutobahnTestClient/project.json | 2 +- test/AutobahnTestServer/project.json | 6 +++--- .../project.json | 8 ++++---- .../project.json | 2 +- test/TestClient/project.json | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Microsoft.AspNetCore.WebSockets.Client/project.json b/src/Microsoft.AspNetCore.WebSockets.Client/project.json index 366d975e4c..e39b3dafae 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Client/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Client/project.json @@ -1,5 +1,5 @@ { - "version": "0.1.0-*", + "version": "0.2.0-*", "description": "Client for communicating over web sockets.", "packOptions": { "repository": { @@ -16,7 +16,7 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.WebSockets.Protocol": "0.1.0-*" + "Microsoft.AspNetCore.WebSockets.Protocol": "0.2.0-*" }, "frameworks": { "net451": {} diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json index ca32295042..8acb4508e4 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json @@ -1,5 +1,5 @@ { - "version": "0.1.0-*", + "version": "0.2.0-*", "description": "Managed web socket protocol parser.", "packOptions": { "repository": { diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/project.json b/src/Microsoft.AspNetCore.WebSockets.Server/project.json index ffef0488f2..33a2d2a0c5 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Server/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Server/project.json @@ -1,5 +1,5 @@ { - "version": "0.1.0-*", + "version": "0.2.0-*", "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", @@ -16,9 +16,9 @@ } }, "dependencies": { - "Microsoft.AspNetCore.Http.Extensions": "1.0.0-*", - "Microsoft.AspNetCore.WebSockets.Protocol": "0.1.0-*", - "Microsoft.Extensions.Options": "1.0.0-*" + "Microsoft.AspNetCore.Http.Extensions": "1.1.0-*", + "Microsoft.AspNetCore.WebSockets.Protocol": "0.2.0-*", + "Microsoft.Extensions.Options": "1.1.0-*" }, "frameworks": { "net451": {}, diff --git a/test/AutobahnTestClient/project.json b/test/AutobahnTestClient/project.json index 048f699897..b900bced6b 100644 --- a/test/AutobahnTestClient/project.json +++ b/test/AutobahnTestClient/project.json @@ -3,7 +3,7 @@ "emitEntryPoint": true }, "dependencies": { - "Microsoft.AspNetCore.WebSockets.Client": "0.1.0-*" + "Microsoft.AspNetCore.WebSockets.Client": "0.2.0-*" }, "frameworks": { "net451": {} diff --git a/test/AutobahnTestServer/project.json b/test/AutobahnTestServer/project.json index e7ade41076..d88d3a0553 100644 --- a/test/AutobahnTestServer/project.json +++ b/test/AutobahnTestServer/project.json @@ -1,8 +1,8 @@ { "dependencies": { - "Microsoft.AspNetCore.WebSockets.Server": "0.1.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*" + "Microsoft.AspNetCore.WebSockets.Server": "0.2.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*" }, "buildOptions": { "emitEntryPoint": true diff --git a/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json index a86e179525..c489f1766d 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json @@ -1,10 +1,10 @@ { "dependencies": { "dotnet-test-xunit": "1.0.0-*", - "Microsoft.AspNetCore.WebSockets.Client": "0.1.0-*", - "Microsoft.AspNetCore.WebSockets.Server": "0.1.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", - "Microsoft.AspNetCore.Testing": "1.0.0-*", + "Microsoft.AspNetCore.WebSockets.Client": "0.2.0-*", + "Microsoft.AspNetCore.WebSockets.Server": "0.2.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", + "Microsoft.AspNetCore.Testing": "1.1.0-*", "xunit": "2.1.0" }, "testRunner": "xunit", diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json index b2402862ef..d005ec7630 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json @@ -1,7 +1,7 @@ { "dependencies": { "dotnet-test-xunit": "1.0.0-*", - "Microsoft.AspNetCore.WebSockets.Protocol": "0.1.0-*", + "Microsoft.AspNetCore.WebSockets.Protocol": "0.2.0-*", "xunit": "2.1.0" }, "testRunner": "xunit", diff --git a/test/TestClient/project.json b/test/TestClient/project.json index 2e35414780..cf854beb28 100644 --- a/test/TestClient/project.json +++ b/test/TestClient/project.json @@ -1,7 +1,7 @@ { "dependencies": { - "Microsoft.AspNetCore.WebSockets.Protocol": "0.1.0-*", - "Microsoft.AspNetCore.WebSockets.Client": "0.1.0-*" + "Microsoft.AspNetCore.WebSockets.Protocol": "0.2.0-*", + "Microsoft.AspNetCore.WebSockets.Client": "0.2.0-*" }, "frameworks": { "net451": {} From da50b8e026efd56d35ebdd51fc621fb223c37707 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Tue, 5 Jul 2016 21:05:15 -0700 Subject: [PATCH 221/453] Updating to RTM builds of xunit and Moq (#94) --- test/AutobahnTestServer/project.json | 9 ++------ .../project.json | 4 ++-- .../project.json | 22 +++++-------------- 3 files changed, 9 insertions(+), 26 deletions(-) diff --git a/test/AutobahnTestServer/project.json b/test/AutobahnTestServer/project.json index d88d3a0553..997723dc70 100644 --- a/test/AutobahnTestServer/project.json +++ b/test/AutobahnTestServer/project.json @@ -14,13 +14,8 @@ "version": "1.0.0-*", "type": "platform" }, - "dotnet-test-xunit": "1.0.0-*", - "System.Diagnostics.Process": "4.1.0-*" - }, - "imports": [ - "dnxcore50", - "portable-net451+win8" - ] + "dotnet-test-xunit": "2.2.0-*" + } }, "net451": {} }, diff --git a/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json index c489f1766d..9a5cc63182 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json @@ -1,11 +1,11 @@ { "dependencies": { - "dotnet-test-xunit": "1.0.0-*", + "dotnet-test-xunit": "2.2.0-*", "Microsoft.AspNetCore.WebSockets.Client": "0.2.0-*", "Microsoft.AspNetCore.WebSockets.Server": "0.2.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", "Microsoft.AspNetCore.Testing": "1.1.0-*", - "xunit": "2.1.0" + "xunit": "2.2.0-*" }, "testRunner": "xunit", "frameworks": { diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json index d005ec7630..ff14cc11fb 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json @@ -1,8 +1,8 @@ { "dependencies": { - "dotnet-test-xunit": "1.0.0-*", + "dotnet-test-xunit": "2.2.0-*", "Microsoft.AspNetCore.WebSockets.Protocol": "0.2.0-*", - "xunit": "2.1.0" + "xunit": "2.2.0-*" }, "testRunner": "xunit", "frameworks": { @@ -11,21 +11,9 @@ "Microsoft.NETCore.App": { "version": "1.0.0-*", "type": "platform" - }, - "System.Diagnostics.Process": "4.1.0-*" - }, - "imports": [ - "dnxcore50", - "portable-net451+win8" - ] - }, - "net451": { - "frameworkAssemblies": { - "System.Runtime": "" - }, - "dependencies": { - "xunit.runner.console": "2.1.0" + } } - } + }, + "net451": {} } } \ No newline at end of file From 80437e878ad1a97c80e103b3e68289f2a780ba5e Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Thu, 7 Jul 2016 14:16:10 -0700 Subject: [PATCH 222/453] One build to rule them all - well, at least VS and command-line builds will share output - part of aspnet/Coherence-Signed#277 --- .../Microsoft.AspNetCore.WebSockets.Client.xproj | 4 ++-- .../Microsoft.AspNetCore.WebSockets.Protocol.xproj | 4 ++-- .../Microsoft.AspNetCore.WebSockets.Server.xproj | 4 ++-- test/AutobahnTestClient/AutobahnTestClient.xproj | 4 ++-- test/AutobahnTestServer/AutobahnTestServer.xproj | 4 ++-- .../Microsoft.AspNetCore.WebSockets.Client.Test.xproj | 4 ++-- .../Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj | 4 ++-- test/TestClient/TestClient.xproj | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Microsoft.AspNetCore.WebSockets.Client/Microsoft.AspNetCore.WebSockets.Client.xproj b/src/Microsoft.AspNetCore.WebSockets.Client/Microsoft.AspNetCore.WebSockets.Client.xproj index 2d11eee57c..ad1997b9e5 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Client/Microsoft.AspNetCore.WebSockets.Client.xproj +++ b/src/Microsoft.AspNetCore.WebSockets.Client/Microsoft.AspNetCore.WebSockets.Client.xproj @@ -7,8 +7,8 @@ 4a1c4875-ae21-4a78-979a-f0e4df5eb518 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/Microsoft.AspNetCore.WebSockets.Protocol.xproj b/src/Microsoft.AspNetCore.WebSockets.Protocol/Microsoft.AspNetCore.WebSockets.Protocol.xproj index d2b2f77a01..5b35ce65e5 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/Microsoft.AspNetCore.WebSockets.Protocol.xproj +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/Microsoft.AspNetCore.WebSockets.Protocol.xproj @@ -7,8 +7,8 @@ e0c10dec-3339-4a47-85bc-3100c5d34ad4 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/Microsoft.AspNetCore.WebSockets.Server.xproj b/src/Microsoft.AspNetCore.WebSockets.Server/Microsoft.AspNetCore.WebSockets.Server.xproj index e6fdc5ade6..cace316cad 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Server/Microsoft.AspNetCore.WebSockets.Server.xproj +++ b/src/Microsoft.AspNetCore.WebSockets.Server/Microsoft.AspNetCore.WebSockets.Server.xproj @@ -7,8 +7,8 @@ 78a097d0-c0a4-4aed-93e2-84a65392fb52 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/test/AutobahnTestClient/AutobahnTestClient.xproj b/test/AutobahnTestClient/AutobahnTestClient.xproj index 386133d0f3..ef9c52ad9d 100644 --- a/test/AutobahnTestClient/AutobahnTestClient.xproj +++ b/test/AutobahnTestClient/AutobahnTestClient.xproj @@ -7,8 +7,8 @@ bc4d2bb1-05a8-4816-8bc1-3a664f09ee32 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/test/AutobahnTestServer/AutobahnTestServer.xproj b/test/AutobahnTestServer/AutobahnTestServer.xproj index 8dcdc25349..fa9134b6ad 100644 --- a/test/AutobahnTestServer/AutobahnTestServer.xproj +++ b/test/AutobahnTestServer/AutobahnTestServer.xproj @@ -7,8 +7,8 @@ c03c43fe-9201-48a6-b434-ad67ef627d67 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/test/Microsoft.AspNetCore.WebSockets.Client.Test/Microsoft.AspNetCore.WebSockets.Client.Test.xproj b/test/Microsoft.AspNetCore.WebSockets.Client.Test/Microsoft.AspNetCore.WebSockets.Client.Test.xproj index 3a5c5703c0..e8c407ffd3 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Client.Test/Microsoft.AspNetCore.WebSockets.Client.Test.xproj +++ b/test/Microsoft.AspNetCore.WebSockets.Client.Test/Microsoft.AspNetCore.WebSockets.Client.Test.xproj @@ -7,8 +7,8 @@ 6604d154-817f-4bc5-be95-ff7e851179d9 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj index 8a43569474..1025dc3503 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj @@ -7,8 +7,8 @@ 62a07a24-4d06-4dda-b6bf-02d0c9cb7d32 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/test/TestClient/TestClient.xproj b/test/TestClient/TestClient.xproj index d04078df6e..ed24e19aa4 100644 --- a/test/TestClient/TestClient.xproj +++ b/test/TestClient/TestClient.xproj @@ -7,8 +7,8 @@ 8c8eac01-dc49-4c5e-b348-e4e46fe675f9 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 From 91e94b13536e3b07451aed78ac56ba327e074597 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Fri, 15 Jul 2016 11:54:24 -0700 Subject: [PATCH 223/453] automate the autobahn test suite (#101) However, we only run that automation if the Autobahn test suite runner (wstest) is installed. After this is in and we can verify it on the CI we'll look at making it mandatory for building the repo. Also includes test applications and scripts for running Autobahn suites against arbitrary ASP.NET 4.6, ASP.NET Core and HttpListener applications. --- .gitignore | 3 +- .travis.yml | 5 +- README.md | 6 + WebSockets.sln | 69 ++++---- appveyor.yml | 3 + makefile.shade | 15 ++ .../AutobahnTestAppAspNet4.csproj | 129 +++++++++++++++ .../AutobahnTestAppAspNet4/EchoSocket.ashx | 1 + .../AutobahnTestAppAspNet4/EchoSocket.ashx.cs | 46 ++++++ .../Properties/AssemblyInfo.cs | 35 +++++ .../AutobahnTestAppAspNet4/Web.Debug.config | 30 ++++ .../AutobahnTestAppAspNet4/Web.Release.config | 31 ++++ samples/AutobahnTestAppAspNet4/Web.config | 21 +++ .../AutobahnTestAppAspNet4/packages.config | 5 + .../AutobahnTestAppAspNet4/wstest-spec.json | 14 ++ .../AutobahnTestAppHttpListener/App.config | 6 + .../AutobahnTestAppHttpListener.csproj | 60 +++++++ .../AutobahnTestAppHttpListener/Program.cs | 106 +++++++++++++ .../Properties/AssemblyInfo.cs | 36 +++++ {test => samples}/TestClient/App.config | 0 {test => samples}/TestClient/Program.cs | 0 .../TestClient/Properties/AssemblyInfo.cs | 0 {test => samples}/TestClient/TestClient.xproj | 0 {test => samples}/TestClient/project.json | 0 {test => samples}/TestServer/App.config | 0 {test => samples}/TestServer/Program.cs | 0 .../TestServer/Properties/AssemblyInfo.cs | 0 .../TestServer/TestServer.csproj | 0 .../AutobahnTestApp.xproj} | 16 +- test/AutobahnTestApp/Program.cs | 39 +++++ .../Properties/launchSettings.json | 42 +++++ test/AutobahnTestApp/README.md | 14 ++ test/AutobahnTestApp/Startup.cs | 54 +++++++ .../TestResources/testCert.pfx | Bin 0 -> 2483 bytes .../TestResources/testCert.txt | 3 + test/AutobahnTestApp/project.json | 55 +++++++ .../scripts/RunAutobahnTests.ps1 | 30 ++++ .../scripts/autobahn.spec.json | 14 ++ .../web.config | 11 +- test/AutobahnTestClient/Program.cs | 107 ------------- test/AutobahnTestClient/ReadMe.txt | 23 --- test/AutobahnTestClient/project.json | 11 -- test/AutobahnTestServer/ReadMe.txt | 25 --- test/AutobahnTestServer/Startup.cs | 84 ---------- test/AutobahnTestServer/project.json | 36 ----- ...ft.AspNetCore.WebSockets.Client.Test.xproj | 3 + ....AspNetCore.WebSockets.Protocol.Test.xproj | 3 + .../Autobahn/AutobahnCaseResult.cs | 30 ++++ .../Autobahn/AutobahnExpectations.cs | 88 +++++++++++ .../Autobahn/AutobahnResult.cs | 24 +++ .../Autobahn/AutobahnServerResult.cs | 39 +++++ .../Autobahn/AutobahnSpec.cs | 61 ++++++++ .../Autobahn/AutobahnTester.cs | 148 ++++++++++++++++++ .../Autobahn/Executable.cs | 55 +++++++ .../Autobahn/Expectation.cs | 11 ++ .../Autobahn/ServerSpec.cs | 23 +++ .../Autobahn/Wstest.cs | 22 +++ .../AutobahnTests.cs | 104 ++++++++++++ .../Helpers.cs | 29 ++++ ...t.AspNetCore.WebSockets.Server.Test.xproj} | 9 +- .../Properties/AssemblyInfo.cs | 19 +++ .../SkipIfWsTestNotPresentAttribute.cs | 13 ++ .../project.json | 23 +++ 63 files changed, 1563 insertions(+), 326 deletions(-) create mode 100644 makefile.shade create mode 100644 samples/AutobahnTestAppAspNet4/AutobahnTestAppAspNet4.csproj create mode 100644 samples/AutobahnTestAppAspNet4/EchoSocket.ashx create mode 100644 samples/AutobahnTestAppAspNet4/EchoSocket.ashx.cs create mode 100644 samples/AutobahnTestAppAspNet4/Properties/AssemblyInfo.cs create mode 100644 samples/AutobahnTestAppAspNet4/Web.Debug.config create mode 100644 samples/AutobahnTestAppAspNet4/Web.Release.config create mode 100644 samples/AutobahnTestAppAspNet4/Web.config create mode 100644 samples/AutobahnTestAppAspNet4/packages.config create mode 100644 samples/AutobahnTestAppAspNet4/wstest-spec.json create mode 100644 samples/AutobahnTestAppHttpListener/App.config create mode 100644 samples/AutobahnTestAppHttpListener/AutobahnTestAppHttpListener.csproj create mode 100644 samples/AutobahnTestAppHttpListener/Program.cs create mode 100644 samples/AutobahnTestAppHttpListener/Properties/AssemblyInfo.cs rename {test => samples}/TestClient/App.config (100%) rename {test => samples}/TestClient/Program.cs (100%) rename {test => samples}/TestClient/Properties/AssemblyInfo.cs (100%) rename {test => samples}/TestClient/TestClient.xproj (100%) rename {test => samples}/TestClient/project.json (100%) rename {test => samples}/TestServer/App.config (100%) rename {test => samples}/TestServer/Program.cs (100%) rename {test => samples}/TestServer/Properties/AssemblyInfo.cs (100%) rename {test => samples}/TestServer/TestServer.csproj (100%) rename test/{AutobahnTestServer/AutobahnTestServer.xproj => AutobahnTestApp/AutobahnTestApp.xproj} (58%) create mode 100644 test/AutobahnTestApp/Program.cs create mode 100644 test/AutobahnTestApp/Properties/launchSettings.json create mode 100644 test/AutobahnTestApp/README.md create mode 100644 test/AutobahnTestApp/Startup.cs create mode 100644 test/AutobahnTestApp/TestResources/testCert.pfx create mode 100644 test/AutobahnTestApp/TestResources/testCert.txt create mode 100644 test/AutobahnTestApp/project.json create mode 100644 test/AutobahnTestApp/scripts/RunAutobahnTests.ps1 create mode 100644 test/AutobahnTestApp/scripts/autobahn.spec.json rename test/{AutobahnTestServer => AutobahnTestApp}/web.config (57%) delete mode 100644 test/AutobahnTestClient/Program.cs delete mode 100644 test/AutobahnTestClient/ReadMe.txt delete mode 100644 test/AutobahnTestClient/project.json delete mode 100644 test/AutobahnTestServer/ReadMe.txt delete mode 100644 test/AutobahnTestServer/Startup.cs delete mode 100644 test/AutobahnTestServer/project.json create mode 100644 test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnCaseResult.cs create mode 100644 test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnExpectations.cs create mode 100644 test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnResult.cs create mode 100644 test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnServerResult.cs create mode 100644 test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnSpec.cs create mode 100644 test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnTester.cs create mode 100644 test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/Executable.cs create mode 100644 test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/Expectation.cs create mode 100644 test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/ServerSpec.cs create mode 100644 test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/Wstest.cs create mode 100644 test/Microsoft.AspNetCore.WebSockets.Server.Test/AutobahnTests.cs create mode 100644 test/Microsoft.AspNetCore.WebSockets.Server.Test/Helpers.cs rename test/{AutobahnTestClient/AutobahnTestClient.xproj => Microsoft.AspNetCore.WebSockets.Server.Test/Microsoft.AspNetCore.WebSockets.Server.Test.xproj} (66%) create mode 100644 test/Microsoft.AspNetCore.WebSockets.Server.Test/Properties/AssemblyInfo.cs create mode 100644 test/Microsoft.AspNetCore.WebSockets.Server.Test/SkipIfWsTestNotPresentAttribute.cs create mode 100644 test/Microsoft.AspNetCore.WebSockets.Server.Test/project.json diff --git a/.gitignore b/.gitignore index 308fec5350..d510684e27 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,5 @@ nuget.exe project.lock.json /.vs/ .testPublish/ -.build/ \ No newline at end of file +.build/ +autobahnreports/ diff --git a/.travis.yml b/.travis.yml index be2e4ad775..a2b7cd463b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,8 +20,11 @@ install: - make install - export LD_LIBRARY_PATH="$HOME/libuvinstall/lib" - cd $OLDPWD + - sudo pip install autobahntestsuite "six>=1.9.0" mono: - 4.0.5 +python: + - "2.7" os: - linux - osx @@ -33,6 +36,6 @@ branches: - dev - /^(.*\/)?ci-.*$/ before_install: - - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; brew link --force openssl; fi + - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl python; brew link --force openssl; fi script: - ./build.sh --quiet verify diff --git a/README.md b/README.md index 5dea9440f3..db96812f49 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,10 @@ Contains a managed implementation of the WebSocket protocol, along with client a This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at the [Home](https://github.com/aspnet/home) repo. +## System Requirements +This repo has a few special system requirements/prerequisites. + +1. Windows IIS Express tests require IIS Express 10 and Windows 8 for WebSockets support +2. HttpListener/ASP.NET 4.6 samples require at least Windows 8 +3. Autobahn Test Suite requires special installation see the README.md in test/AutobahnTestApp diff --git a/WebSockets.sln b/WebSockets.sln index a7b3697b81..a79504e978 100644 --- a/WebSockets.sln +++ b/WebSockets.sln @@ -1,10 +1,7 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.22216.0 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestServer", "test\TestServer\TestServer.csproj", "{4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2C7947A5-9FBD-4267-97C1-2D726D7B3BAF}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{C45106D0-76C8-4776-A140-F7DD83CA2958}" @@ -15,8 +12,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSoc EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Protocol.Test", "test\Microsoft.AspNetCore.WebSockets.Protocol.Test\Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj", "{62A07A24-4D06-4DDA-B6BF-02D0C9CB7D32}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestClient", "test\TestClient\TestClient.xproj", "{8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}" -EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Client", "src\Microsoft.AspNetCore.WebSockets.Client\Microsoft.AspNetCore.WebSockets.Client.xproj", "{4A1C4875-AE21-4A78-979A-F0E4DF5EB518}" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Client.Test", "test\Microsoft.AspNetCore.WebSockets.Client.Test\Microsoft.AspNetCore.WebSockets.Client.Test.xproj", "{6604D154-817F-4BC5-BE95-FF7E851179D9}" @@ -28,9 +23,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution global.json = global.json EndProjectSection EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AutobahnTestServer", "test\AutobahnTestServer\AutobahnTestServer.xproj", "{C03C43FE-9201-48A6-B434-AD67EF627D67}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestClient", "samples\TestClient\TestClient.xproj", "{8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AutobahnTestClient", "test\AutobahnTestClient\AutobahnTestClient.xproj", "{BC4D2BB1-05A8-4816-8BC1-3A664F09EE32}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestServer", "samples\TestServer\TestServer.csproj", "{4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Server.Test", "test\Microsoft.AspNetCore.WebSockets.Server.Test\Microsoft.AspNetCore.WebSockets.Server.Test.xproj", "{E82D9F64-8AFA-4DCB-A842-2283FDA73BE8}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AutobahnTestApp", "test\AutobahnTestApp\AutobahnTestApp.xproj", "{9755F612-A155-4BDD-9E20-37ADE0B4B3BA}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutobahnTestAppAspNet4", "samples\AutobahnTestAppAspNet4\AutobahnTestAppAspNet4.csproj", "{72E3AB32-682F-42AF-B7C7-0B777244FF11}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutobahnTestAppHttpListener", "samples\AutobahnTestAppHttpListener\AutobahnTestAppHttpListener.csproj", "{B7246F23-6A4B-492F-AB61-292AA1A9E9D5}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -38,10 +41,6 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Release|Any CPU.Build.0 = Release|Any CPU {E0C10DEC-3339-4A47-85BC-3100C5D34AD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E0C10DEC-3339-4A47-85BC-3100C5D34AD4}.Debug|Any CPU.Build.0 = Debug|Any CPU {E0C10DEC-3339-4A47-85BC-3100C5D34AD4}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -50,10 +49,6 @@ Global {62A07A24-4D06-4DDA-B6BF-02D0C9CB7D32}.Debug|Any CPU.Build.0 = Debug|Any CPU {62A07A24-4D06-4DDA-B6BF-02D0C9CB7D32}.Release|Any CPU.ActiveCfg = Release|Any CPU {62A07A24-4D06-4DDA-B6BF-02D0C9CB7D32}.Release|Any CPU.Build.0 = Release|Any CPU - {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Release|Any CPU.Build.0 = Release|Any CPU {4A1C4875-AE21-4A78-979A-F0E4DF5EB518}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4A1C4875-AE21-4A78-979A-F0E4DF5EB518}.Debug|Any CPU.Build.0 = Debug|Any CPU {4A1C4875-AE21-4A78-979A-F0E4DF5EB518}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -66,27 +61,45 @@ Global {78A097D0-C0A4-4AED-93E2-84A65392FB52}.Debug|Any CPU.Build.0 = Debug|Any CPU {78A097D0-C0A4-4AED-93E2-84A65392FB52}.Release|Any CPU.ActiveCfg = Release|Any CPU {78A097D0-C0A4-4AED-93E2-84A65392FB52}.Release|Any CPU.Build.0 = Release|Any CPU - {C03C43FE-9201-48A6-B434-AD67EF627D67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C03C43FE-9201-48A6-B434-AD67EF627D67}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C03C43FE-9201-48A6-B434-AD67EF627D67}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C03C43FE-9201-48A6-B434-AD67EF627D67}.Release|Any CPU.Build.0 = Release|Any CPU - {BC4D2BB1-05A8-4816-8BC1-3A664F09EE32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BC4D2BB1-05A8-4816-8BC1-3A664F09EE32}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BC4D2BB1-05A8-4816-8BC1-3A664F09EE32}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BC4D2BB1-05A8-4816-8BC1-3A664F09EE32}.Release|Any CPU.Build.0 = Release|Any CPU + {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Release|Any CPU.Build.0 = Release|Any CPU + {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Release|Any CPU.Build.0 = Release|Any CPU + {E82D9F64-8AFA-4DCB-A842-2283FDA73BE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E82D9F64-8AFA-4DCB-A842-2283FDA73BE8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E82D9F64-8AFA-4DCB-A842-2283FDA73BE8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E82D9F64-8AFA-4DCB-A842-2283FDA73BE8}.Release|Any CPU.Build.0 = Release|Any CPU + {9755F612-A155-4BDD-9E20-37ADE0B4B3BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9755F612-A155-4BDD-9E20-37ADE0B4B3BA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9755F612-A155-4BDD-9E20-37ADE0B4B3BA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9755F612-A155-4BDD-9E20-37ADE0B4B3BA}.Release|Any CPU.Build.0 = Release|Any CPU + {72E3AB32-682F-42AF-B7C7-0B777244FF11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {72E3AB32-682F-42AF-B7C7-0B777244FF11}.Debug|Any CPU.Build.0 = Debug|Any CPU + {72E3AB32-682F-42AF-B7C7-0B777244FF11}.Release|Any CPU.ActiveCfg = Release|Any CPU + {72E3AB32-682F-42AF-B7C7-0B777244FF11}.Release|Any CPU.Build.0 = Release|Any CPU + {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} {E0C10DEC-3339-4A47-85BC-3100C5D34AD4} = {2C7947A5-9FBD-4267-97C1-2D726D7B3BAF} {62A07A24-4D06-4DDA-B6BF-02D0C9CB7D32} = {C45106D0-76C8-4776-A140-F7DD83CA2958} - {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} {4A1C4875-AE21-4A78-979A-F0E4DF5EB518} = {2C7947A5-9FBD-4267-97C1-2D726D7B3BAF} {6604D154-817F-4BC5-BE95-FF7E851179D9} = {C45106D0-76C8-4776-A140-F7DD83CA2958} {78A097D0-C0A4-4AED-93E2-84A65392FB52} = {2C7947A5-9FBD-4267-97C1-2D726D7B3BAF} - {C03C43FE-9201-48A6-B434-AD67EF627D67} = {C45106D0-76C8-4776-A140-F7DD83CA2958} - {BC4D2BB1-05A8-4816-8BC1-3A664F09EE32} = {C45106D0-76C8-4776-A140-F7DD83CA2958} + {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} + {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} + {E82D9F64-8AFA-4DCB-A842-2283FDA73BE8} = {C45106D0-76C8-4776-A140-F7DD83CA2958} + {9755F612-A155-4BDD-9E20-37ADE0B4B3BA} = {C45106D0-76C8-4776-A140-F7DD83CA2958} + {72E3AB32-682F-42AF-B7C7-0B777244FF11} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} + {B7246F23-6A4B-492F-AB61-292AA1A9E9D5} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} EndGlobalSection EndGlobal diff --git a/appveyor.yml b/appveyor.yml index 81cbe23e0c..5086ce1532 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,6 +8,9 @@ branches: - /^(.*\/)?ci-.*$/ build_script: - build.cmd --quiet verify +install: + - set PATH=C:\Python27\scripts;%PATH% + - pip install autobahntestsuite clone_depth: 1 test: off deploy: off diff --git a/makefile.shade b/makefile.shade new file mode 100644 index 0000000000..ecfd6668cc --- /dev/null +++ b/makefile.shade @@ -0,0 +1,15 @@ +use namespace="System.IO" + +var VERSION='0.1' +var FULL_VERSION='0.1' +var AUTHORS='Microsoft' + +use-standard-lifecycle +k-standard-goals + +var AUTOBAHN_REPORTS_DIR='${Path.Combine(Directory.GetCurrentDirectory(), "artifacts", "autobahnreports")}' + +#set-autobahn-report-dir target='initialize' + @{ + E("AUTOBAHN_SUITES_REPORT_DIR", AUTOBAHN_REPORTS_DIR); + } diff --git a/samples/AutobahnTestAppAspNet4/AutobahnTestAppAspNet4.csproj b/samples/AutobahnTestAppAspNet4/AutobahnTestAppAspNet4.csproj new file mode 100644 index 0000000000..e778fb466b --- /dev/null +++ b/samples/AutobahnTestAppAspNet4/AutobahnTestAppAspNet4.csproj @@ -0,0 +1,129 @@ + + + + + + + Debug + AnyCPU + + + 2.0 + {72E3AB32-682F-42AF-B7C7-0B777244FF11} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + AutobahnTestAppAspNet4 + AutobahnTestAppAspNet4 + v4.6.1 + true + + + + + + + + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + ..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll + True + + + + + + + + + + + + + + + + + + + + + + + + + Web.config + + + Web.config + + + + + + + + EchoSocket.ashx + + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + True + True + 29392 + / + http://localhost:29392 + True + http://localhost:29392/EchoSocket.ashx + False + False + + + False + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/samples/AutobahnTestAppAspNet4/EchoSocket.ashx b/samples/AutobahnTestAppAspNet4/EchoSocket.ashx new file mode 100644 index 0000000000..7d018e48ed --- /dev/null +++ b/samples/AutobahnTestAppAspNet4/EchoSocket.ashx @@ -0,0 +1 @@ +<%@ WebHandler Language="C#" CodeBehind="EchoSocket.ashx.cs" Class="AutobahnTestAppAspNet4.EchoSocket" %> diff --git a/samples/AutobahnTestAppAspNet4/EchoSocket.ashx.cs b/samples/AutobahnTestAppAspNet4/EchoSocket.ashx.cs new file mode 100644 index 0000000000..0b001f8715 --- /dev/null +++ b/samples/AutobahnTestAppAspNet4/EchoSocket.ashx.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.WebSockets; +using System.Threading; +using System.Threading.Tasks; +using System.Web; + +namespace AutobahnTestAppAspNet4 +{ + /// + /// Summary description for EchoSocket + /// + public class EchoSocket : IHttpHandler + { + public bool IsReusable => false; + + public void ProcessRequest(HttpContext context) + { + if (context.IsWebSocketRequest) + { + context.AcceptWebSocketRequest(async socketContext => + { + await Echo(socketContext.WebSocket); + }); + } + else + { + context.Response.Write("Ready to accept WebSocket request at: " + context.Request.Url.ToString().Replace("https://", "wss://").Replace("http://", "ws://")); + context.Response.Flush(); + } + } + + private async Task Echo(WebSocket webSocket) + { + var buffer = new byte[1024 * 4]; + var result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); + while (!result.CloseStatus.HasValue) + { + await webSocket.SendAsync(new ArraySegment(buffer, 0, result.Count), result.MessageType, result.EndOfMessage, CancellationToken.None); + result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); + } + await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + } + } +} \ No newline at end of file diff --git a/samples/AutobahnTestAppAspNet4/Properties/AssemblyInfo.cs b/samples/AutobahnTestAppAspNet4/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..22e5a4f43d --- /dev/null +++ b/samples/AutobahnTestAppAspNet4/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("AutobahnTestAppAspNet4")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("AutobahnTestAppAspNet4")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("72e3ab32-682f-42af-b7c7-0b777244ff11")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/samples/AutobahnTestAppAspNet4/Web.Debug.config b/samples/AutobahnTestAppAspNet4/Web.Debug.config new file mode 100644 index 0000000000..2e302f9f95 --- /dev/null +++ b/samples/AutobahnTestAppAspNet4/Web.Debug.config @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/samples/AutobahnTestAppAspNet4/Web.Release.config b/samples/AutobahnTestAppAspNet4/Web.Release.config new file mode 100644 index 0000000000..c35844462b --- /dev/null +++ b/samples/AutobahnTestAppAspNet4/Web.Release.config @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/samples/AutobahnTestAppAspNet4/Web.config b/samples/AutobahnTestAppAspNet4/Web.config new file mode 100644 index 0000000000..9500f90d67 --- /dev/null +++ b/samples/AutobahnTestAppAspNet4/Web.config @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/AutobahnTestAppAspNet4/packages.config b/samples/AutobahnTestAppAspNet4/packages.config new file mode 100644 index 0000000000..5f629e51b2 --- /dev/null +++ b/samples/AutobahnTestAppAspNet4/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/samples/AutobahnTestAppAspNet4/wstest-spec.json b/samples/AutobahnTestAppAspNet4/wstest-spec.json new file mode 100644 index 0000000000..d11521b04b --- /dev/null +++ b/samples/AutobahnTestAppAspNet4/wstest-spec.json @@ -0,0 +1,14 @@ +{ + "options": { "failByDrop": false }, + "outdir": "./bin/wstest-report", + "servers": [ + { + "agent": "ASP.NET 4", + "url": "ws://localhost:29392/EchoSocket.ashx", + "options": { "version": 18 } + } + ], + "cases": ["*"], + "exclude-cases": ["12.*", "13.*"], + "exclude-agent-cases": {} +} \ No newline at end of file diff --git a/samples/AutobahnTestAppHttpListener/App.config b/samples/AutobahnTestAppHttpListener/App.config new file mode 100644 index 0000000000..731f6de6c2 --- /dev/null +++ b/samples/AutobahnTestAppHttpListener/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/samples/AutobahnTestAppHttpListener/AutobahnTestAppHttpListener.csproj b/samples/AutobahnTestAppHttpListener/AutobahnTestAppHttpListener.csproj new file mode 100644 index 0000000000..943e30e4c3 --- /dev/null +++ b/samples/AutobahnTestAppHttpListener/AutobahnTestAppHttpListener.csproj @@ -0,0 +1,60 @@ + + + + + Debug + AnyCPU + {B7246F23-6A4B-492F-AB61-292AA1A9E9D5} + Exe + Properties + AutobahnTestAppHttpListener + AutobahnTestAppHttpListener + v4.6.1 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/AutobahnTestAppHttpListener/Program.cs b/samples/AutobahnTestAppHttpListener/Program.cs new file mode 100644 index 0000000000..3c965d1be6 --- /dev/null +++ b/samples/AutobahnTestAppHttpListener/Program.cs @@ -0,0 +1,106 @@ +using System; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.WebSockets; +using System.Threading; +using System.Threading.Tasks; + +namespace AutobahnTestAppHttpListener +{ + class Program + { + // This app only works on Windows 8+ + static int Main(string[] args) + { + using (var listener = StartListener()) + { + if (listener == null) + { + return 1; + } + + var httpUrl = listener.Prefixes.Single(); + var wsUrl = httpUrl.Replace("http://", "ws://"); + + var stopTokenSource = new CancellationTokenSource(); + var task = Run(listener, wsUrl, stopTokenSource.Token); + + Console.CancelKeyPress += (sender, a) => + { + a.Cancel = true; + stopTokenSource.Cancel(); + }; + + Console.WriteLine($"HTTP: {httpUrl}"); + Console.WriteLine($"WS : {wsUrl}"); + Console.WriteLine("Press Ctrl-C to stop..."); + + task.Wait(); + } + return 0; + } + + private static async Task Run(HttpListener listener, string wsUrl, CancellationToken stopToken) + { + while (!stopToken.IsCancellationRequested) + { + try + { + var context = await listener.GetContextAsync(); + + if (context.Request.IsWebSocketRequest) + { + var socket = await context.AcceptWebSocketAsync(null); + await Echo(socket.WebSocket); + } + else + { + using (var writer = new StreamWriter(context.Response.OutputStream)) + { + await writer.WriteLineAsync($"Ready to accept WebSocket request at: {wsUrl}"); + } + } + } + catch (Exception ex) + { + Console.WriteLine($"Request failed: {ex}"); + } + } + } + + private static async Task Echo(WebSocket webSocket) + { + var buffer = new byte[1024 * 4]; + var result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); + while (!result.CloseStatus.HasValue) + { + await webSocket.SendAsync(new ArraySegment(buffer, 0, result.Count), result.MessageType, result.EndOfMessage, CancellationToken.None); + result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); + } + await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + } + + static HttpListener StartListener() + { + var port = 49152; // IANA recommends starting at port 49152 for dynamic ports + while (port < 65535) + { + HttpListener listener = new HttpListener(); + listener.Prefixes.Add($"http://localhost:{port}/"); + try + { + listener.Start(); + return listener; + } + catch + { + port++; + } + } + + Console.Error.WriteLine("Failed to find a free port!"); + return null; + } + } +} diff --git a/samples/AutobahnTestAppHttpListener/Properties/AssemblyInfo.cs b/samples/AutobahnTestAppHttpListener/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..f442cae407 --- /dev/null +++ b/samples/AutobahnTestAppHttpListener/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("AutobahnTestAppHttpListener")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("AutobahnTestAppHttpListener")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("b7246f23-6a4b-492f-ab61-292aa1a9e9d5")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/test/TestClient/App.config b/samples/TestClient/App.config similarity index 100% rename from test/TestClient/App.config rename to samples/TestClient/App.config diff --git a/test/TestClient/Program.cs b/samples/TestClient/Program.cs similarity index 100% rename from test/TestClient/Program.cs rename to samples/TestClient/Program.cs diff --git a/test/TestClient/Properties/AssemblyInfo.cs b/samples/TestClient/Properties/AssemblyInfo.cs similarity index 100% rename from test/TestClient/Properties/AssemblyInfo.cs rename to samples/TestClient/Properties/AssemblyInfo.cs diff --git a/test/TestClient/TestClient.xproj b/samples/TestClient/TestClient.xproj similarity index 100% rename from test/TestClient/TestClient.xproj rename to samples/TestClient/TestClient.xproj diff --git a/test/TestClient/project.json b/samples/TestClient/project.json similarity index 100% rename from test/TestClient/project.json rename to samples/TestClient/project.json diff --git a/test/TestServer/App.config b/samples/TestServer/App.config similarity index 100% rename from test/TestServer/App.config rename to samples/TestServer/App.config diff --git a/test/TestServer/Program.cs b/samples/TestServer/Program.cs similarity index 100% rename from test/TestServer/Program.cs rename to samples/TestServer/Program.cs diff --git a/test/TestServer/Properties/AssemblyInfo.cs b/samples/TestServer/Properties/AssemblyInfo.cs similarity index 100% rename from test/TestServer/Properties/AssemblyInfo.cs rename to samples/TestServer/Properties/AssemblyInfo.cs diff --git a/test/TestServer/TestServer.csproj b/samples/TestServer/TestServer.csproj similarity index 100% rename from test/TestServer/TestServer.csproj rename to samples/TestServer/TestServer.csproj diff --git a/test/AutobahnTestServer/AutobahnTestServer.xproj b/test/AutobahnTestApp/AutobahnTestApp.xproj similarity index 58% rename from test/AutobahnTestServer/AutobahnTestServer.xproj rename to test/AutobahnTestApp/AutobahnTestApp.xproj index fa9134b6ad..1e23714cd5 100644 --- a/test/AutobahnTestServer/AutobahnTestServer.xproj +++ b/test/AutobahnTestApp/AutobahnTestApp.xproj @@ -4,14 +4,22 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + + - c03c43fe-9201-48a6-b434-ad67ef627d67 + 9755f612-a155-4bdd-9e20-37ade0b4b3ba + AutobahnTestApp .\obj .\bin\ + v4.6.1 + 2.0 - - \ No newline at end of file + + + + + + diff --git a/test/AutobahnTestApp/Program.cs b/test/AutobahnTestApp/Program.cs new file mode 100644 index 0000000000..04098c88ab --- /dev/null +++ b/test/AutobahnTestApp/Program.cs @@ -0,0 +1,39 @@ +using System; +using System.IO; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; + +namespace AutobahnTestApp +{ + public class Program + { + public static void Main(string[] args) + { + var config = new ConfigurationBuilder() + .AddCommandLine(args) + .Build(); + + var builder = new WebHostBuilder() + .UseConfiguration(config) + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup(); + + if (string.Equals(builder.GetSetting("server"), "Microsoft.AspNetCore.Server.WebListener", System.StringComparison.Ordinal)) + { + builder.UseWebListener(); + } + else + { + builder.UseKestrel(options => + { + var certPath = Path.Combine(AppContext.BaseDirectory, "TestResources", "testCert.pfx"); + options.UseHttps(certPath, "testPassword"); + }); + } + + var host = builder.Build(); + host.Run(); + } + } +} diff --git a/test/AutobahnTestApp/Properties/launchSettings.json b/test/AutobahnTestApp/Properties/launchSettings.json new file mode 100644 index 0000000000..c96436ad2a --- /dev/null +++ b/test/AutobahnTestApp/Properties/launchSettings.json @@ -0,0 +1,42 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:6155/", + "sslPort": 44371 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "ManagedSockets" + } + }, + "AutobahnTestApp": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "ManagedSockets" + } + }, + "AutobahnTestApp (SSL)": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "https://localhost:5443", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "ManagedSockets" + } + }, + "WebListener": { + "commandName": "Project", + "commandLineArgs": "--server Microsoft.AspNetCore.Server.WebListener", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "ManagedSockets" + } + } + } +} \ No newline at end of file diff --git a/test/AutobahnTestApp/README.md b/test/AutobahnTestApp/README.md new file mode 100644 index 0000000000..ece563a39b --- /dev/null +++ b/test/AutobahnTestApp/README.md @@ -0,0 +1,14 @@ +# Autobahn Testing + +This application is used to provide the server for the [Autobahn Test Suite](http://autobahn.ws/testsuite) 'fuzzingclient' mode to test. It is a simple echo server that echos each frame recieved back to the client. + +In order to run these tests you must install CPython 2.7, Pip, and the test suite modules. You must also have +the `wstest` executable provided by the Autobahn Suite on the `PATH`. See http://autobahn.ws/testsuite/installation.html#installation for more info + +Once Autobahn is installed, launch this application in the desired configuration (in IIS Express, or using Kestrel directly) from Visual Studio and get the WebSocket URL from the HTTP response. Use that URL in place of `ws://server:1234` and invoke the `scripts\RunAutobahnTests.ps1` script in this project like so: + +``` +> .\scripts\RunAutobahnTests.ps1 -ServerUrl ws://server:1234 +``` + +By default, all cases are run and the report is written to the `autobahnreports` sub-directory of the directory in which you run the script. You can change either by using the `-Cases` and `-OutputDir` switches, use `.\script\RunAutobahnTests.ps1 -?` for help. \ No newline at end of file diff --git a/test/AutobahnTestApp/Startup.cs b/test/AutobahnTestApp/Startup.cs new file mode 100644 index 0000000000..67562d9ce0 --- /dev/null +++ b/test/AutobahnTestApp/Startup.cs @@ -0,0 +1,54 @@ +using System; +using System.Net.WebSockets; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; + +namespace AutobahnTestApp +{ + public class Startup + { + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + { + if (!env.IsEnvironment("NativeSockets")) + { + app.UseWebSockets(new WebSocketOptions + { + ReplaceFeature = true + }); + } + + app.Use(async (context, next) => + { + if (context.WebSockets.IsWebSocketRequest) + { + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + await Echo(webSocket); + } + else + { + var wsScheme = context.Request.IsHttps ? "wss" : "ws"; + var wsUrl = $"{wsScheme}://{context.Request.Host.Host}:{context.Request.Host.Port}{context.Request.Path}"; + await context.Response.WriteAsync($"Ready to accept a WebSocket request at: {wsUrl}"); + } + }); + + } + + private async Task Echo(WebSocket webSocket) + { + var buffer = new byte[1024 * 4]; + var result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); + while (!result.CloseStatus.HasValue) + { + await webSocket.SendAsync(new ArraySegment(buffer, 0, result.Count), result.MessageType, result.EndOfMessage, CancellationToken.None); + result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); + } + await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + } + } +} diff --git a/test/AutobahnTestApp/TestResources/testCert.pfx b/test/AutobahnTestApp/TestResources/testCert.pfx new file mode 100644 index 0000000000000000000000000000000000000000..7118908c2d730670c16e9f8b2c532a262c951989 GIT binary patch literal 2483 zcmaKuc|27A8pqF>IWr86E&Q@(n=B)p$ug!;QVB6xij*z;uPLG!yCz#DQB)+9G$9m9 zQU)=DWXU?*EZIwG!+0d++P@yZ4Xhoagg?p6B~|Ue7tN=Ny=UD?x#1n1MTq z#c9MHh+D#gd|(a(cN}8i91v^=GcdgW3SmA$49p~gM-dys3jVWdg8+!iVL)pz1LDE5 zSb=|GAn(@R=(Ux!MfS9@}sFu-xDd zIt2+mqSq$glwy_6UNs<2?(qERU!gJ;5j}Pp&6trxG=wi)=@k(w2+fJVnc+qvXVzy(>Om4;L|^)R`t*3nTpAmEmTl(#i!RV#a0t#u6>Q9mY`-Nmcs7$XjXT7 zUmCD`O~_j7!%R#I?cG-7C^hcH)@l?WC1vyw$FFu_(r)jhOq6p}W8sG7NO{YTy8tG4 zrb$tTkag*G?(7lfoGx$4YWui>{{@}-FB2ub=}RX{1zx?j)s-##J9|G7E1@-;7Nuln z9MQoX7FJ76+D#XXT@ZZmLZCufIdf3@OigG6m8I7!GT=7VD|>?6e!z9=eT}*E_tSn6 zl+clHCZ-kcIR#gen#LjMJW8>0QtViaQB#FhqsCb0YPYr3;jRITl@V9Aph24D?r2d` zetCyyCg<*O-u+M& zW^ptmT|}p$VAOZpmbQ1{5fK-6ytEvre#Po}6c2URn`viQAF2+e?Z~PK2&pd>7=7)I zTCYm)@3PFRu_6a6Kb)IpCzQ%e3l%O#SDA+$Pq{Dk{HCqi7z>qd{nVpebffL7h{c4( zmhXn~G+C27S3(IfC)q2KON=YwqHXEo%zc40DgWLzF{%RIdr@RcLu90qMSHf!Y}JaqP<={8_Rfe;ddR5= zKEo;^Yip&^m((#{czE{kUga3-@`*;&EwO}Jt>QdURP2P>ob^j-A!qld-0S_pm)kjs zkNo48oZnMt){W~o8g^f;4#?lRLr-T@f}wH1o~-Iq=NEVtTVEZ`vrW~!>2yh%;Bc~H zHl&OK>n@d`*e19*9#v>zZpU?I);f7}IPIfSSk#N|ujE492Itg)l!)TJ19@FE^x|p= zH16NC7OfK&|6_!AnWfTIf^YPOa&`|nbk3VR0vql6&s@y1V3QOU%(`Re+kJgrz?r9!{^wOQ4W-eng23gc}f(LxIs zH_Ls~5izbjcRQH#WH6s6hR;zn>j_R8aJ$A)6xNneu8UI-vWV8Z@HZu&WwvG5q{1ZS zdZeVf{Pv5-u281~y;aJe*x%Uv0@biMZ$vPbKj}O`(SOWQc~kJX` zXR&d4DtAe@2RH$^ z0os5*;0eIUeJi3Uh`A%44x(XzjClG8BO~-r_A}odiRuHo2-86#`mhrgN5p~<$RLY? zq(kynfFA5{v#p+EA1 z5aoe1763EQHorRm`C&ktKn(OQ1n)$Q{GZz&jRb`eDEMpl<0O#+)DMV(T7nsIzCG{QuM->B9g7Lrl2SE&gW`M!~(un|y0fIn=b^6_$ z9{zEzgYI~39xn0ZP*9qBL%fg7rg$ttt&TOmvfNNO<6FT0ZavM$Y4CYLQGIcIYv9Y& zBGPUh&QTfW;V2!)oIra@s&d968y-y}Y|ww(R$GzWS*V&)k@W0>Slem{|HdTCjm;_5 zwY*A8W3nUbemE^_f0ng$tbd<`sr?TO-_&VCw+F#7P@LkIl$1PzTBoPY1b88EIO>UO zP-NK7+g2yD3U6g3i|iA6+su>54sf_Sk0F=)1|9odnCM4u2Rs z=&Y?-V&VquSN%3FJ2~ZGweP~iLs|w=l@9yu$tj@}Dp?e-2JUsqOoswdXb=E%&0te_ zA2M+{5Hf-dqD7=yw*r@A*xkn(1IS~nfP}k}e?4Bt|9g(eph4hFX_|S6nj1&Sz9z^= zRw~<&-9d@FzTn6S*RVE{Wj5lgLJr9HLB8S9CgOm*>XA8*y4`JE;^s$=bqD#U4;e5C&x&ggKIAVL zrQ)Yd8|{>7Z(6*B&7&4&9(*vDOfHMuR-Dk1IZia*XM^EZUD^{?cWG>J>KrtElc*{K zaVl(7SN2cH4I6Q$bZOpJ8e5LKaG7p;?tJ~#+9QrTYU@f#5`Vo7cEX!szCT}iX-K^2 w#3o+=C+lQz2J+SOEzVX(eJ)e7=eicC{rr9U2VGDcdH?_b literal 0 HcmV?d00001 diff --git a/test/AutobahnTestApp/TestResources/testCert.txt b/test/AutobahnTestApp/TestResources/testCert.txt new file mode 100644 index 0000000000..8771b78318 --- /dev/null +++ b/test/AutobahnTestApp/TestResources/testCert.txt @@ -0,0 +1,3 @@ +The password for this is 'testPassword' + +DO NOT EVER TRUST THIS CERT. The private key for it is publicly released. \ No newline at end of file diff --git a/test/AutobahnTestApp/project.json b/test/AutobahnTestApp/project.json new file mode 100644 index 0000000000..fc3aab9d44 --- /dev/null +++ b/test/AutobahnTestApp/project.json @@ -0,0 +1,55 @@ +{ + "dependencies": { + "Microsoft.AspNetCore.WebSockets.Server": { "target": "project" }, + "Microsoft.NETCore.App": { + "version": "1.0.0", + "type": "platform" + }, + + "Microsoft.AspNetCore.Diagnostics": "1.1.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", + "Microsoft.AspNetCore.Server.WebListener": "0.2.0-*", + "Microsoft.AspNetCore.Server.Kestrel.Https": "1.1.0-*", + "Microsoft.Extensions.Configuration.CommandLine": "1.1.0-*", + "Microsoft.Extensions.Logging.Console": "1.1.0-*" + }, + + "tools": { + "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" + }, + + "frameworks": { + "netcoreapp1.0": { + "imports": [ + "dotnet5.6", + "portable-net45+win8" + ] + } + }, + + "buildOptions": { + "emitEntryPoint": true, + "copyToOutput": [ + "TestResources/testCert.pfx" + ] + }, + + "runtimeOptions": { + "configProperties": { + "System.GC.Server": true + } + }, + + "publishOptions": { + "include": [ + "wwwroot", + "web.config", + "TestResources/testCert.pfx" + ] + }, + + "scripts": { + "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] + } +} diff --git a/test/AutobahnTestApp/scripts/RunAutobahnTests.ps1 b/test/AutobahnTestApp/scripts/RunAutobahnTests.ps1 new file mode 100644 index 0000000000..52f35e492f --- /dev/null +++ b/test/AutobahnTestApp/scripts/RunAutobahnTests.ps1 @@ -0,0 +1,30 @@ +# +# RunAutobahnTests.ps1 +# +param([Parameter(Mandatory=$true)][string]$ServerUrl, [string[]]$Cases = @("*"), [string]$OutputDir) + +if(!(Get-Command wstest -ErrorAction SilentlyContinue)) { + throw "Missing required command 'wstest'. See README.md in Microsoft.AspNetCore.WebSockets.Server.Test project for information on installing Autobahn Test Suite." +} + +if(!$OutputDir) { + $OutputDir = Convert-Path "." + $OutputDir = Join-Path $OutputDir "autobahnreports" +} + +$Spec = Convert-Path (Join-Path $PSScriptRoot "autobahn.spec.json") + +$CasesArray = [string]::Join(",", @($Cases | ForEach-Object { "`"$_`"" })) + +$SpecJson = [IO.File]::ReadAllText($Spec).Replace("OUTPUTDIR", $OutputDir.Replace("\", "\\")).Replace("WEBSOCKETURL", $ServerUrl).Replace("`"CASES`"", $CasesArray) + +$TempFile = [IO.Path]::GetTempFileName() + +try { + [IO.File]::WriteAllText($TempFile, $SpecJson) + & wstest -m fuzzingclient -s $TempFile +} finally { + if(Test-Path $TempFile) { + rm $TempFile + } +} \ No newline at end of file diff --git a/test/AutobahnTestApp/scripts/autobahn.spec.json b/test/AutobahnTestApp/scripts/autobahn.spec.json new file mode 100644 index 0000000000..aa6d841167 --- /dev/null +++ b/test/AutobahnTestApp/scripts/autobahn.spec.json @@ -0,0 +1,14 @@ +{ + "options": { "failByDrop": false }, + "outdir": "OUTPUTDIR", + "servers": [ + { + "agent": "Server", + "url": "WEBSOCKETURL", + "options": { "version": 18 } + } + ], + "cases": ["CASES"], + "exclude-cases": ["12.*", "13.*"], + "exclude-agent-cases": {} +} diff --git a/test/AutobahnTestServer/web.config b/test/AutobahnTestApp/web.config similarity index 57% rename from test/AutobahnTestServer/web.config rename to test/AutobahnTestApp/web.config index 41b492941a..dc0514fca5 100644 --- a/test/AutobahnTestServer/web.config +++ b/test/AutobahnTestApp/web.config @@ -1,9 +1,14 @@ - + + + + - + - \ No newline at end of file + diff --git a/test/AutobahnTestClient/Program.cs b/test/AutobahnTestClient/Program.cs deleted file mode 100644 index 6a3ae749a7..0000000000 --- a/test/AutobahnTestClient/Program.cs +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Net.WebSockets; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.AspNetCore.WebSockets.Client; - -namespace AutobahnTestClient -{ - public class Program - { - public static void Main(string[] args) - { - new Program().Run(args).Wait(); - } - - private async Task Run(string[] args) - { - try - { - string serverAddress = "ws://localhost:5000"; - string agent = - "ManagedWebSockets"; - // "NativeWebSockets"; - - Console.WriteLine("Getting case count."); - var caseCount = await GetCaseCountAsync(serverAddress, agent); - Console.WriteLine(caseCount + " case(s)."); - - for (int i = 1; i <= caseCount; i++) - { - await RunCaseAsync(serverAddress, i, agent); - } - - await UpdateReportsAsync(serverAddress, agent); - } - catch (Exception ex) - { - Console.WriteLine(ex); - } - - Console.WriteLine("Done"); - Console.ReadLine(); - } - - private async Task ConnectAsync(string address, string agent) - { - if (string.Equals(agent, "NativeWebSockets")) - { - var client = new ClientWebSocket(); - await client.ConnectAsync(new Uri(address), CancellationToken.None); - return client; - } - else - { - // TODO: BUG: Require ws or wss schemes - var client = new WebSocketClient(); - return await client.ConnectAsync(new Uri(address), CancellationToken.None); - } - } - - private async Task GetCaseCountAsync(string serverAddress, string agent) - { - var webSocket = await ConnectAsync(serverAddress + "/getCaseCount", agent); - byte[] buffer = new byte[1024 * 4]; - var result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); - await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty, CancellationToken.None); - var caseCountText = Encoding.UTF8.GetString(buffer, 0, result.Count); - return int.Parse(caseCountText); - } - - private async Task RunCaseAsync(string serverAddress, int caseId, string agent) - { - try - { - Console.WriteLine("Running case " + caseId); - var webSocket = await ConnectAsync(serverAddress + "/runCase?case=" + caseId + "&agent=" + agent, agent); - await Echo(webSocket); - } - catch (Exception ex) - { - Console.WriteLine(ex); - } - } - - private async Task Echo(WebSocket webSocket) - { - byte[] buffer = new byte[1024 * 4]; - var result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); - while (!result.CloseStatus.HasValue) - { - await webSocket.SendAsync(new ArraySegment(buffer, 0, result.Count), result.MessageType, result.EndOfMessage, CancellationToken.None); - result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); - } - await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); - } - - private async Task UpdateReportsAsync(string serverAddress, string agent) - { - var webSocket = await ConnectAsync(serverAddress + "/updateReports?agent=" + agent, agent); - await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty, CancellationToken.None); - } - } -} diff --git a/test/AutobahnTestClient/ReadMe.txt b/test/AutobahnTestClient/ReadMe.txt deleted file mode 100644 index 6da6360ccc..0000000000 --- a/test/AutobahnTestClient/ReadMe.txt +++ /dev/null @@ -1,23 +0,0 @@ -This test server is for use in testing client side implementations of the WebSocekt protocol. It is currently implemented to test -Microsoft.AspNetCore.WebSockets.Client.WebSocketClient and System.Net.WebSockets.ClientWebSocket. - -See http://autobahn.ws/ to download and install the test framework. - -Usage: -Run the test server: -"C:\Program Files\Python\2.7.6\Scripts\wstest" -d -m fuzzingserver -s fuzzingserver.json -Where fuzzingserver.json contains the following: - -{ - "url": "ws://127.0.0.1:9001", - - "options": {"failByDrop": false}, - "outdir": "./reports/clients", - "webport": 8080, - - "cases": ["*"], - "exclude-cases": [], - "exclude-agent-cases": {} -} - -Then run the client of your choice, taking care to update the serverAddress and agent fields in the client code. \ No newline at end of file diff --git a/test/AutobahnTestClient/project.json b/test/AutobahnTestClient/project.json deleted file mode 100644 index b900bced6b..0000000000 --- a/test/AutobahnTestClient/project.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "buildOptions": { - "emitEntryPoint": true - }, - "dependencies": { - "Microsoft.AspNetCore.WebSockets.Client": "0.2.0-*" - }, - "frameworks": { - "net451": {} - } -} \ No newline at end of file diff --git a/test/AutobahnTestServer/ReadMe.txt b/test/AutobahnTestServer/ReadMe.txt deleted file mode 100644 index 0c0bb6837d..0000000000 --- a/test/AutobahnTestServer/ReadMe.txt +++ /dev/null @@ -1,25 +0,0 @@ -This test server is for use in testing server side implementations of the WebSocekt protocol. It should work with Helios, WebListener (native), -and the managed implementation of WebSockets in this project (running on WebListener, Kestrel, etc.). The tests only require that the server implement -a basic WebSocket accept and then echo any content received. - -See http://autobahn.ws/ to download and install the test framework. - -Usage: -Configure and start the server of your choice. -Run the test client: -"C:\Program Files\Python\2.7.6\Scripts\wstest.exe" -d -m fuzzingclient -s fuzzingclient.json -Where fussingclient.json contains: -{ - "options": {"failByDrop": false}, - "outdir": "./reports/servers", - - "servers": [ - {"agent": "NameOfImplementationBeingTested", - "url": "ws://localhost:12345", - "options": {"version": 18}} - ], - - "cases": ["*"], - "exclude-cases": [], - "exclude-agent-cases": {} -} \ No newline at end of file diff --git a/test/AutobahnTestServer/Startup.cs b/test/AutobahnTestServer/Startup.cs deleted file mode 100644 index 7330152214..0000000000 --- a/test/AutobahnTestServer/Startup.cs +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Net.WebSockets; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; - -namespace AutobahnTestServer -{ - public class Startup - { - public void Configure(IApplicationBuilder app) - { - app.Map("/Managed", managedWebSocketsApp => - { - // Comment this out to test native server implementations - managedWebSocketsApp.UseWebSockets(new WebSocketOptions - { - ReplaceFeature = true - }); - - managedWebSocketsApp.Use(async (context, next) => - { - if (context.WebSockets.IsWebSocketRequest) - { - Console.WriteLine("Echo: " + context.Request.Path); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - await Echo(webSocket); - return; - } - await next(); - }); - }); - - app.Map("/Native", nativeWebSocketsApp => - { - nativeWebSocketsApp.Use(async (context, next) => - { - if (context.WebSockets.IsWebSocketRequest) - { - Console.WriteLine("Echo: " + context.Request.Path); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - await Echo(webSocket); - return; - } - await next(); - }); - }); - - app.Run(context => - { - Console.WriteLine("Hello World"); - return context.Response.WriteAsync("Hello World"); - }); - } - - private async Task Echo(WebSocket webSocket) - { - byte[] buffer = new byte[1024 * 4]; - var result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); - while (!result.CloseStatus.HasValue) - { - await webSocket.SendAsync(new ArraySegment(buffer, 0, result.Count), result.MessageType, result.EndOfMessage, CancellationToken.None); - result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); - } - await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); - } - - public static void Main(string[] args) - { - var host = new WebHostBuilder() - .UseKestrel() - .UseIISIntegration() - .UseStartup() - .Build(); - - host.Run(); - } - } -} diff --git a/test/AutobahnTestServer/project.json b/test/AutobahnTestServer/project.json deleted file mode 100644 index 997723dc70..0000000000 --- a/test/AutobahnTestServer/project.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "dependencies": { - "Microsoft.AspNetCore.WebSockets.Server": "0.2.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*" - }, - "buildOptions": { - "emitEntryPoint": true - }, - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.0.0-*", - "type": "platform" - }, - "dotnet-test-xunit": "2.2.0-*" - } - }, - "net451": {} - }, - "publishOptions": { - "include": [ - "web.config" - ] - }, - "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": { - "version": "1.0.0-*", - "imports": "portable-net45+wp80+win8+wpa81+dnxcore50" - } - }, - "scripts": { - "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Client.Test/Microsoft.AspNetCore.WebSockets.Client.Test.xproj b/test/Microsoft.AspNetCore.WebSockets.Client.Test/Microsoft.AspNetCore.WebSockets.Client.Test.xproj index e8c407ffd3..e54463273b 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Client.Test/Microsoft.AspNetCore.WebSockets.Client.Test.xproj +++ b/test/Microsoft.AspNetCore.WebSockets.Client.Test/Microsoft.AspNetCore.WebSockets.Client.Test.xproj @@ -13,5 +13,8 @@ 2.0 + + + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj index 1025dc3503..80b9e72b45 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj @@ -13,5 +13,8 @@ 2.0 + + + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnCaseResult.cs b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnCaseResult.cs new file mode 100644 index 0000000000..017d178880 --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnCaseResult.cs @@ -0,0 +1,30 @@ +using System; +using System.Linq; +using Newtonsoft.Json.Linq; + +namespace Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn +{ + public class AutobahnCaseResult + { + public string Name { get; } + public string ActualBehavior { get; } + + public AutobahnCaseResult(string name, string actualBehavior) + { + Name = name; + ActualBehavior = actualBehavior; + } + + public static AutobahnCaseResult FromJson(JProperty prop) + { + var caseObj = (JObject)prop.Value; + var actualBehavior = (string)caseObj["behavior"]; + return new AutobahnCaseResult(prop.Name, actualBehavior); + } + + public bool BehaviorIs(params string[] behaviors) + { + return behaviors.Any(b => string.Equals(b, ActualBehavior, StringComparison.Ordinal)); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnExpectations.cs b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnExpectations.cs new file mode 100644 index 0000000000..dfcf9a4c25 --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnExpectations.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Microsoft.AspNetCore.Server.Testing; + +namespace Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn +{ + public class AutobahnExpectations + { + private Dictionary _expectations = new Dictionary(); + public bool Ssl { get; } + public ServerType Server { get; } + public string Environment { get; } + + public AutobahnExpectations(ServerType server, bool ssl, string environment) + { + Server = server; + Ssl = ssl; + Environment = environment; + } + + public AutobahnExpectations Fail(params string[] caseSpecs) => Expect(Expectation.Fail, caseSpecs); + public AutobahnExpectations NonStrict(params string[] caseSpecs) => Expect(Expectation.NonStrict, caseSpecs); + public AutobahnExpectations OkOrNonStrict(params string[] caseSpecs) => Expect(Expectation.OkOrNonStrict, caseSpecs); + public AutobahnExpectations OkOrFail(params string[] caseSpecs) => Expect(Expectation.OkOrFail, caseSpecs); + + public AutobahnExpectations Expect(Expectation expectation, params string[] caseSpecs) + { + foreach (var caseSpec in caseSpecs) + { + _expectations[caseSpec] = expectation; + } + return this; + } + + internal void Verify(AutobahnServerResult serverResult, StringBuilder failures) + { + foreach (var caseResult in serverResult.Cases) + { + // If this is an informational test result, we can't compare it to anything + if (!string.Equals(caseResult.ActualBehavior, "INFORMATIONAL", StringComparison.Ordinal)) + { + Expectation expectation; + if (!_expectations.TryGetValue(caseResult.Name, out expectation)) + { + expectation = Expectation.Ok; + } + + switch (expectation) + { + case Expectation.Fail: + if (!caseResult.BehaviorIs("FAILED")) + { + failures.AppendLine($"Case {serverResult.Name}:{caseResult.Name}. Expected 'FAILED', but got '{caseResult.ActualBehavior}'"); + } + break; + case Expectation.NonStrict: + if (!caseResult.BehaviorIs("NON-STRICT")) + { + failures.AppendLine($"Case {serverResult.Name}:{caseResult.Name}. Expected 'NON-STRICT', but got '{caseResult.ActualBehavior}'"); + } + break; + case Expectation.Ok: + if (!caseResult.BehaviorIs("OK")) + { + failures.AppendLine($"Case {serverResult.Name}:{caseResult.Name}. Expected 'OK', but got '{caseResult.ActualBehavior}'"); + } + break; + case Expectation.OkOrNonStrict: + if (!caseResult.BehaviorIs("NON-STRICT") && !caseResult.BehaviorIs("OK")) + { + failures.AppendLine($"Case {serverResult.Name}:{caseResult.Name}. Expected 'NON-STRICT' or 'OK', but got '{caseResult.ActualBehavior}'"); + } + break; + case Expectation.OkOrFail: + if (!caseResult.BehaviorIs("FAILED") && !caseResult.BehaviorIs("OK")) + { + failures.AppendLine($"Case {serverResult.Name}:{caseResult.Name}. Expected 'FAILED' or 'OK', but got '{caseResult.ActualBehavior}'"); + } + break; + default: + break; + } + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnResult.cs b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnResult.cs new file mode 100644 index 0000000000..c23164a13c --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnResult.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.AspNetCore.Server.Testing; +using Newtonsoft.Json.Linq; + +namespace Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn +{ + public class AutobahnResult + { + public IEnumerable Servers { get; } + + public AutobahnResult(IEnumerable servers) + { + Servers = servers; + } + + public static AutobahnResult FromReportJson(JObject indexJson) + { + // Load the report + return new AutobahnResult(indexJson.Properties().Select(AutobahnServerResult.FromJson)); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnServerResult.cs b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnServerResult.cs new file mode 100644 index 0000000000..4986bbdfc6 --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnServerResult.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.AspNetCore.Server.Testing; +using Newtonsoft.Json.Linq; + +namespace Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn +{ + public class AutobahnServerResult + { + public ServerType Server { get; } + public bool Ssl { get; } + public string Environment { get; } + public string Name { get; } + public IEnumerable Cases { get; } + + public AutobahnServerResult(string name, IEnumerable cases) + { + Name = name; + + var splat = name.Split('|'); + if (splat.Length < 3) + { + throw new FormatException("Results incorrectly formatted"); + } + + Server = (ServerType)Enum.Parse(typeof(ServerType), splat[0]); + Ssl = string.Equals(splat[1], "SSL", StringComparison.Ordinal); + Environment = splat[2]; + Cases = cases; + } + + public static AutobahnServerResult FromJson(JProperty prop) + { + var valueObj = ((JObject)prop.Value); + return new AutobahnServerResult(prop.Name, valueObj.Properties().Select(AutobahnCaseResult.FromJson)); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnSpec.cs b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnSpec.cs new file mode 100644 index 0000000000..0c97999136 --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnSpec.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn +{ + public class AutobahnSpec + { + public string OutputDirectory { get; } + public IList Servers { get; } = new List(); + public IList Cases { get; } = new List(); + public IList ExcludedCases { get; } = new List(); + + public AutobahnSpec(string outputDirectory) + { + OutputDirectory = outputDirectory; + } + + public AutobahnSpec WithServer(string name, string url) + { + Servers.Add(new ServerSpec(name, url)); + return this; + } + + public AutobahnSpec IncludeCase(params string[] caseSpecs) + { + foreach (var caseSpec in caseSpecs) + { + Cases.Add(caseSpec); + } + return this; + } + + public AutobahnSpec ExcludeCase(params string[] caseSpecs) + { + foreach (var caseSpec in caseSpecs) + { + ExcludedCases.Add(caseSpec); + } + return this; + } + + public void WriteJson(string file) + { + File.WriteAllText(file, GetJson().ToString(Formatting.Indented)); + } + + public JObject GetJson() => new JObject( + new JProperty("options", new JObject( + new JProperty("failByDrop", false))), + new JProperty("outdir", OutputDirectory), + new JProperty("servers", new JArray(Servers.Select(s => s.GetJson()).ToArray())), + new JProperty("cases", new JArray(Cases.ToArray())), + new JProperty("exclude-cases", new JArray(ExcludedCases.ToArray())), + new JProperty("exclude-agent-cases", new JObject())); + } +} diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnTester.cs new file mode 100644 index 0000000000..ed74e67b5a --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnTester.cs @@ -0,0 +1,148 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Server.Testing; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json.Linq; +using Xunit; + +namespace Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn +{ + public class AutobahnTester : IDisposable + { + private int _nextPort; + private readonly List _deployers = new List(); + private readonly List _expectations = new List(); + private readonly ILoggerFactory _loggerFactory; + private readonly ILogger _logger; + + public AutobahnSpec Spec { get; } + + public AutobahnTester(ILoggerFactory loggerFactory, AutobahnSpec baseSpec) : this(7000, loggerFactory, baseSpec) { } + + public AutobahnTester(int startPort, ILoggerFactory loggerFactory, AutobahnSpec baseSpec) + { + _nextPort = startPort; + _loggerFactory = loggerFactory; + _logger = _loggerFactory.CreateLogger("AutobahnTester"); + + Spec = baseSpec; + } + + public async Task Run() + { + var specFile = Path.GetTempFileName(); + try + { + Spec.WriteJson(specFile); + + // Run the test (write something to the console so people know this will take a while...) + _logger.LogInformation("Now launching Autobahn Test Suite. This will take a while."); + var exitCode = await Wstest.Default.ExecAsync("-m fuzzingclient -s " + specFile); + if (exitCode != 0) + { + throw new Exception("wstest failed"); + } + } + finally + { + if (File.Exists(specFile)) + { + File.Delete(specFile); + } + } + + // Parse the output. + var outputFile = Path.Combine(Directory.GetCurrentDirectory(), Spec.OutputDirectory, "index.json"); + using (var reader = new StreamReader(File.OpenRead(outputFile))) + { + return AutobahnResult.FromReportJson(JObject.Parse(await reader.ReadToEndAsync())); + } + } + + public void Verify(AutobahnResult result) + { + var failures = new StringBuilder(); + foreach (var serverResult in result.Servers) + { + var serverExpectation = _expectations.FirstOrDefault(e => e.Server == serverResult.Server && e.Ssl == serverResult.Ssl); + if (serverExpectation == null) + { + failures.AppendLine($"Expected no results for server: {serverResult.Name} but found results!"); + } + else + { + serverExpectation.Verify(serverResult, failures); + } + } + + Assert.True(failures.Length == 0, "Autobahn results did not meet expectations:" + Environment.NewLine + failures.ToString()); + } + + public async Task DeployTestAndAddToSpec(ServerType server, bool ssl, string environment, Action expectationConfig = null) + { + var port = Interlocked.Increment(ref _nextPort); + var baseUrl = ssl ? $"https://localhost:{port}" : $"http://localhost:{port}"; + var sslNamePart = ssl ? "SSL" : "NoSSL"; + var name = $"{server}|{sslNamePart}|{environment}"; + var logger = _loggerFactory.CreateLogger($"AutobahnTestApp:{server}:{sslNamePart}:{environment}"); + + var appPath = Helpers.GetApplicationPath("AutobahnTestApp"); + var parameters = new DeploymentParameters(appPath, server, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64) + { + ApplicationBaseUriHint = baseUrl, + ApplicationType = ApplicationType.Portable, + TargetFramework = "netcoreapp1.0", + EnvironmentName = environment + }; + + var deployer = ApplicationDeployerFactory.Create(parameters, logger); + var result = deployer.Deploy(); + +#if NET451 + System.Net.ServicePointManager.ServerCertificateValidationCallback = (_, __, ___, ____) => true; + var client = new HttpClient(); +#else + var handler = new HttpClientHandler(); + if (ssl) + { + // Don't take this out of the "if(ssl)". If we set it on some platforms, it crashes + // So we avoid running SSL tests on those platforms (for now). + // See https://github.com/dotnet/corefx/issues/9728 + handler.ServerCertificateCustomValidationCallback = (_, __, ___, ____) => true; + } + var client = new HttpClient(handler); +#endif + + // Make sure the server works + var resp = await RetryHelper.RetryRequest(() => + { + return client.GetAsync(result.ApplicationBaseUri); + }, logger, result.HostShutdownToken, retryCount: 5); + resp.EnsureSuccessStatusCode(); + + // Add to the current spec + var wsUrl = result.ApplicationBaseUri.Replace("https://", "wss://").Replace("http://", "ws://"); + Spec.WithServer(name, wsUrl); + + _deployers.Add(deployer); + + var expectations = new AutobahnExpectations(server, ssl, environment); + expectationConfig?.Invoke(expectations); + _expectations.Add(expectations); + } + + public void Dispose() + { + foreach (var deployer in _deployers) + { + deployer.Dispose(); + } + } + } +} diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/Executable.cs b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/Executable.cs new file mode 100644 index 0000000000..eb9a46a889 --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/Executable.cs @@ -0,0 +1,55 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn +{ + public class Executable + { + private static readonly string _exeSuffix = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : string.Empty; + + private readonly string _path; + + protected Executable(string path) + { + _path = path; + } + + public static string Locate(string name) + { + foreach (var dir in Environment.GetEnvironmentVariable("PATH").Split(Path.PathSeparator)) + { + var candidate = Path.Combine(dir, name + _exeSuffix); + if (File.Exists(candidate)) + { + return candidate; + } + } + return null; + } + + public Task ExecAsync(string args) + { + var process = new Process() + { + StartInfo = new ProcessStartInfo() + { + FileName = _path, + Arguments = args, + UseShellExecute = false, + }, + EnableRaisingEvents = true + }; + var tcs = new TaskCompletionSource(); + + process.Exited += (_, __) => tcs.TrySetResult(process.ExitCode); + + process.Start(); + + return tcs.Task; + } + } +} diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/Expectation.cs b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/Expectation.cs new file mode 100644 index 0000000000..a3a8040f9d --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/Expectation.cs @@ -0,0 +1,11 @@ +namespace Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn +{ + public enum Expectation + { + Fail, + NonStrict, + OkOrFail, + Ok, + OkOrNonStrict + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/ServerSpec.cs b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/ServerSpec.cs new file mode 100644 index 0000000000..265d1f7971 --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/ServerSpec.cs @@ -0,0 +1,23 @@ +using System; +using Newtonsoft.Json.Linq; + +namespace Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn +{ + public class ServerSpec + { + public string Name { get; } + public string Url { get; } + + public ServerSpec(string name, string url) + { + Name = name; + Url = url; + } + + public JObject GetJson() => new JObject( + new JProperty("agent", Name), + new JProperty("url", Url), + new JProperty("options", new JObject( + new JProperty("version", 18)))); + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/Wstest.cs b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/Wstest.cs new file mode 100644 index 0000000000..07d09d34f5 --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/Wstest.cs @@ -0,0 +1,22 @@ +using System; + +namespace Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn +{ + /// + /// Wrapper around the Autobahn Test Suite's "wstest" app. + /// + public class Wstest : Executable + { + private static Lazy _instance = new Lazy(Create); + + public static Wstest Default => _instance.Value; + + public Wstest(string path) : base(path) { } + + private static Wstest Create() + { + var location = Locate("wstest"); + return location == null ? null : new Wstest(location); + } + } +} diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.Server.Test/AutobahnTests.cs new file mode 100644 index 0000000000..c2c685af21 --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.Server.Test/AutobahnTests.cs @@ -0,0 +1,104 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Server.Testing; +using Microsoft.AspNetCore.Testing.xunit; +using Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.PlatformAbstractions; + +namespace Microsoft.AspNetCore.WebSockets.Server.Test +{ + public class AutobahnTests + { + // Skip if wstest is not installed for now, see https://github.com/aspnet/WebSockets/issues/95 + // We will enable Wstest on every build once we've gotten the necessary infrastructure sorted out :). + [ConditionalFact] + [SkipIfWsTestNotPresent] + public async Task AutobahnTestSuite() + { + var reportDir = Environment.GetEnvironmentVariable("AUTOBAHN_SUITES_REPORT_DIR"); + var outDir = !string.IsNullOrEmpty(reportDir) ? + reportDir : + Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "autobahnreports"); + + if (Directory.Exists(outDir)) + { + Directory.Delete(outDir, recursive: true); + } + + outDir = outDir.Replace("\\", "\\\\"); + + // 9.* is Limits/Performance which is VERY SLOW; 12.*/13.* are compression which we don't implement + var spec = new AutobahnSpec(outDir) + .IncludeCase("*") + .ExcludeCase("9.*", "12.*", "13.*"); + + var loggerFactory = new LoggerFactory(); // No logging! It's very loud... + + AutobahnResult result; + using (var tester = new AutobahnTester(loggerFactory, spec)) + { + await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: false, environment: "ManagedSockets", expectationConfig: expect => expect + .NonStrict("6.4.3", "6.4.4")); // https://github.com/aspnet/WebSockets/issues/99 + + // Windows-only IIS tests, and Kestrel SSL tests (due to: https://github.com/aspnet/WebSockets/issues/102) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: true, environment: "ManagedSockets", expectationConfig: expect => expect + .NonStrict("6.4.3", "6.4.4")); // https://github.com/aspnet/WebSockets/issues/99 + + if (IsIISExpress10Installed()) + { + // IIS Express tests are a bit flaky, some tests fail occasionally or get non-strict passes + // https://github.com/aspnet/WebSockets/issues/100 + await tester.DeployTestAndAddToSpec(ServerType.IISExpress, ssl: false, environment: "ManagedSockets", expectationConfig: expect => expect + .OkOrFail(Enumerable.Range(1, 20).Select(i => $"5.{i}").ToArray()) // 5.* occasionally fail on IIS express + .OkOrNonStrict("3.2", "3.3", "3.4", "4.1.3", "4.1.4", "4.1.5", "4.2.3", "4.2.4", "4.2.5", "5.15")); // These occasionally get non-strict results + } + + if (IsWindows8OrHigher()) + { + await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "ManagedSockets", expectationConfig: expect => expect + .Fail("6.1.2", "6.1.3") // https://github.com/aspnet/WebSockets/issues/97 + .NonStrict("6.4.3", "6.4.4")); // https://github.com/aspnet/WebSockets/issues/99 + } + } + + // REQUIRES a build of WebListener that supports native WebSockets, which we don't have right now + //await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "NativeSockets"); + + result = await tester.Run(); + tester.Verify(result); + } + } + + private bool IsWindows8OrHigher() + { + const string WindowsName = "Microsoft Windows "; + const int VersionOffset = 18; + + if (RuntimeInformation.OSDescription.StartsWith(WindowsName)) + { + var versionStr = RuntimeInformation.OSDescription.Substring(VersionOffset); + Version version; + if (Version.TryParse(versionStr, out version)) + { + return version.Major > 6 || (version.Major == 6 && version.Minor >= 2); + } + } + + return false; + } + + private bool IsIISExpress10Installed() + { + var pf = Environment.GetEnvironmentVariable("PROGRAMFILES"); + var iisExpressExe = Path.Combine(pf, "IIS Express", "iisexpress.exe"); + return File.Exists(iisExpressExe) && FileVersionInfo.GetVersionInfo(iisExpressExe).FileMajorPart >= 10; + } + } +} diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Helpers.cs b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Helpers.cs new file mode 100644 index 0000000000..a22eb25bf3 --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Helpers.cs @@ -0,0 +1,29 @@ +using System; +using System.IO; +using Microsoft.Extensions.PlatformAbstractions; + +namespace Microsoft.AspNetCore.WebSockets.Server.Test +{ + public class Helpers + { + public static string GetApplicationPath(string projectName) + { + var applicationBasePath = PlatformServices.Default.Application.ApplicationBasePath; + + var directoryInfo = new DirectoryInfo(applicationBasePath); + do + { + var solutionFileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, "WebSockets.sln")); + if (solutionFileInfo.Exists) + { + return Path.GetFullPath(Path.Combine(directoryInfo.FullName, "test", projectName)); + } + + directoryInfo = directoryInfo.Parent; + } + while (directoryInfo.Parent != null); + + throw new Exception($"Solution root could not be found using {applicationBasePath}"); + } + } +} diff --git a/test/AutobahnTestClient/AutobahnTestClient.xproj b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Microsoft.AspNetCore.WebSockets.Server.Test.xproj similarity index 66% rename from test/AutobahnTestClient/AutobahnTestClient.xproj rename to test/Microsoft.AspNetCore.WebSockets.Server.Test/Microsoft.AspNetCore.WebSockets.Server.Test.xproj index ef9c52ad9d..11f55fd48c 100644 --- a/test/AutobahnTestClient/AutobahnTestClient.xproj +++ b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Microsoft.AspNetCore.WebSockets.Server.Test.xproj @@ -4,14 +4,17 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + - bc4d2bb1-05a8-4816-8bc1-3a664f09ee32 + e82d9f64-8afa-4dcb-a842-2283fda73be8 .\obj .\bin\ 2.0 - + + + + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Properties/AssemblyInfo.cs b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..6e03af7061 --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.Server.Test/Properties/AssemblyInfo.cs @@ -0,0 +1,19 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Microsoft.AspNetCore.WebSockets.Server.Test")] +[assembly: AssemblyTrademark("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e82d9f64-8afa-4dcb-a842-2283fda73be8")] diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/SkipIfWsTestNotPresentAttribute.cs b/test/Microsoft.AspNetCore.WebSockets.Server.Test/SkipIfWsTestNotPresentAttribute.cs new file mode 100644 index 0000000000..b37fd95868 --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.Server.Test/SkipIfWsTestNotPresentAttribute.cs @@ -0,0 +1,13 @@ +using System; +using Microsoft.AspNetCore.Testing.xunit; +using Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn; + +namespace Microsoft.AspNetCore.WebSockets.Server.Test +{ + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] + public class SkipIfWsTestNotPresentAttribute : Attribute, ITestCondition + { + public bool IsMet => Wstest.Default != null; + public string SkipReason => "Autobahn Test Suite is not installed on the host machine."; + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Server.Test/project.json new file mode 100644 index 0000000000..9054cd9eb8 --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.Server.Test/project.json @@ -0,0 +1,23 @@ +{ + "dependencies": { + "dotnet-test-xunit": "2.2.0-*", + "Microsoft.AspNetCore.Server.Testing": "0.2.0-*", + "Microsoft.AspNetCore.Testing": "1.1.0-*", + "Microsoft.Extensions.Logging": "1.1.0-*", + "Microsoft.Extensions.Logging.Console": "1.1.0-*", + "Microsoft.Extensions.PlatformAbstractions": "1.1.0-*", + "System.Diagnostics.FileVersionInfo": "4.0.0", + "xunit": "2.2.0-*" + }, + "testRunner": "xunit", + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0-*", + "type": "platform" + } + } + } + } +} From 854ffadc6a06a5ef4292c05ded0b25247f236e2f Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Mon, 18 Jul 2016 09:41:13 -0700 Subject: [PATCH 224/453] fix project reference --- test/AutobahnTestApp/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/AutobahnTestApp/project.json b/test/AutobahnTestApp/project.json index fc3aab9d44..db9aab27e7 100644 --- a/test/AutobahnTestApp/project.json +++ b/test/AutobahnTestApp/project.json @@ -1,6 +1,6 @@ { "dependencies": { - "Microsoft.AspNetCore.WebSockets.Server": { "target": "project" }, + "Microsoft.AspNetCore.WebSockets.Server": "0.2.0-*", "Microsoft.NETCore.App": { "version": "1.0.0", "type": "platform" From 935d15a15e8a64862fc796bc9ea9ddb48a77e964 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Wed, 27 Jul 2016 10:54:05 -0700 Subject: [PATCH 225/453] don't run Autobahn tests on Win7/Server2008 (#104) --- .../AutobahnTests.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.Server.Test/AutobahnTests.cs index c2c685af21..8e6d3ab191 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Server.Test/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Server.Test/AutobahnTests.cs @@ -51,17 +51,17 @@ namespace Microsoft.AspNetCore.WebSockets.Server.Test await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: true, environment: "ManagedSockets", expectationConfig: expect => expect .NonStrict("6.4.3", "6.4.4")); // https://github.com/aspnet/WebSockets/issues/99 - if (IsIISExpress10Installed()) - { - // IIS Express tests are a bit flaky, some tests fail occasionally or get non-strict passes - // https://github.com/aspnet/WebSockets/issues/100 - await tester.DeployTestAndAddToSpec(ServerType.IISExpress, ssl: false, environment: "ManagedSockets", expectationConfig: expect => expect - .OkOrFail(Enumerable.Range(1, 20).Select(i => $"5.{i}").ToArray()) // 5.* occasionally fail on IIS express - .OkOrNonStrict("3.2", "3.3", "3.4", "4.1.3", "4.1.4", "4.1.5", "4.2.3", "4.2.4", "4.2.5", "5.15")); // These occasionally get non-strict results - } - if (IsWindows8OrHigher()) { + if (IsIISExpress10Installed()) + { + // IIS Express tests are a bit flaky, some tests fail occasionally or get non-strict passes + // https://github.com/aspnet/WebSockets/issues/100 + await tester.DeployTestAndAddToSpec(ServerType.IISExpress, ssl: false, environment: "ManagedSockets", expectationConfig: expect => expect + .OkOrFail(Enumerable.Range(1, 20).Select(i => $"5.{i}").ToArray()) // 5.* occasionally fail on IIS express + .OkOrNonStrict("3.2", "3.3", "3.4", "4.1.3", "4.1.4", "4.1.5", "4.2.3", "4.2.4", "4.2.5", "5.15")); // These occasionally get non-strict results + } + await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "ManagedSockets", expectationConfig: expect => expect .Fail("6.1.2", "6.1.3") // https://github.com/aspnet/WebSockets/issues/97 .NonStrict("6.4.3", "6.4.4")); // https://github.com/aspnet/WebSockets/issues/99 From 8b25152a67c64d03e86ed2b2347650c78b441529 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Tue, 2 Aug 2016 13:07:33 -0700 Subject: [PATCH 226/453] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a2b7cd463b..3b4056f4a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,6 +36,6 @@ branches: - dev - /^(.*\/)?ci-.*$/ before_install: - - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl python; brew link --force openssl; fi + - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl python; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi script: - ./build.sh --quiet verify From 45f0fe178f452edd7283faae4cbd4ff76cdae432 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Wed, 3 Aug 2016 11:07:01 -0700 Subject: [PATCH 227/453] import WebSockets code from CoreFX (#105) * import WebSockets code from CoreFX * sync pr feedback from dotnet/corefx#10510 --- WebSockets.sln | 33 +- scripts/UpdateCoreFxCode.ps1 | 44 + .../WebSocketClient.cs | 8 +- .../CommonWebSocket.cs | 643 +------- .../CompatHelpers.cs | 49 + .../FrameHeader.cs | 252 ---- .../SR.cs | 24 + .../Utilities.cs | 170 --- .../ext/README.md | 5 + .../Net/WebSockets/WebSocketValidate.cs | 132 ++ .../System/Net/WebSockets/ManagedWebSocket.cs | 1312 +++++++++++++++++ .../project.json | 8 +- .../scripts/RunAutobahnTests.ps1 | 35 +- .../WebSocketClientTests.cs | 34 +- .../BufferStream.cs | 4 +- .../DuplexStream.cs | 4 +- .../DuplexTests.cs | 66 - ....AspNetCore.WebSockets.Protocol.Test.xproj | 8 +- .../Microsoft.Net.WebSockets.Test.csproj | 69 - .../Properties/AssemblyInfo.cs | 27 +- .../SendReceiveTests.cs | 77 + .../Utf8ValidationTests.cs | 75 - .../UtilitiesTests.cs | 22 - .../WebSocketPair.cs | 28 + .../project.json | 7 +- .../Autobahn/AutobahnCaseResult.cs | 0 .../Autobahn/AutobahnExpectations.cs | 0 .../Autobahn/AutobahnResult.cs | 0 .../Autobahn/AutobahnServerResult.cs | 0 .../Autobahn/AutobahnSpec.cs | 0 .../Autobahn/AutobahnTester.cs | 0 .../Autobahn/Executable.cs | 0 .../Autobahn/Expectation.cs | 0 .../Autobahn/ServerSpec.cs | 0 .../Autobahn/Wstest.cs | 0 .../AutobahnTests.cs | 17 +- .../Helpers.cs | 0 ...e.WebSockets.Server.ConformanceTest.xproj} | 7 +- .../Properties/AssemblyInfo.cs | 0 .../SkipIfWsTestNotPresentAttribute.cs | 0 .../project.json | 0 41 files changed, 1771 insertions(+), 1389 deletions(-) create mode 100644 scripts/UpdateCoreFxCode.ps1 create mode 100644 src/Microsoft.AspNetCore.WebSockets.Protocol/CompatHelpers.cs delete mode 100644 src/Microsoft.AspNetCore.WebSockets.Protocol/FrameHeader.cs create mode 100644 src/Microsoft.AspNetCore.WebSockets.Protocol/SR.cs delete mode 100644 src/Microsoft.AspNetCore.WebSockets.Protocol/Utilities.cs create mode 100644 src/Microsoft.AspNetCore.WebSockets.Protocol/ext/README.md create mode 100644 src/Microsoft.AspNetCore.WebSockets.Protocol/ext/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs create mode 100644 src/Microsoft.AspNetCore.WebSockets.Protocol/ext/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ManagedWebSocket.cs delete mode 100644 test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexTests.cs delete mode 100644 test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.Net.WebSockets.Test.csproj create mode 100644 test/Microsoft.AspNetCore.WebSockets.Protocol.Test/SendReceiveTests.cs delete mode 100644 test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Utf8ValidationTests.cs delete mode 100644 test/Microsoft.AspNetCore.WebSockets.Protocol.Test/UtilitiesTests.cs create mode 100644 test/Microsoft.AspNetCore.WebSockets.Protocol.Test/WebSocketPair.cs rename test/{Microsoft.AspNetCore.WebSockets.Server.Test => Microsoft.AspNetCore.WebSockets.Server.ConformanceTest}/Autobahn/AutobahnCaseResult.cs (100%) rename test/{Microsoft.AspNetCore.WebSockets.Server.Test => Microsoft.AspNetCore.WebSockets.Server.ConformanceTest}/Autobahn/AutobahnExpectations.cs (100%) rename test/{Microsoft.AspNetCore.WebSockets.Server.Test => Microsoft.AspNetCore.WebSockets.Server.ConformanceTest}/Autobahn/AutobahnResult.cs (100%) rename test/{Microsoft.AspNetCore.WebSockets.Server.Test => Microsoft.AspNetCore.WebSockets.Server.ConformanceTest}/Autobahn/AutobahnServerResult.cs (100%) rename test/{Microsoft.AspNetCore.WebSockets.Server.Test => Microsoft.AspNetCore.WebSockets.Server.ConformanceTest}/Autobahn/AutobahnSpec.cs (100%) rename test/{Microsoft.AspNetCore.WebSockets.Server.Test => Microsoft.AspNetCore.WebSockets.Server.ConformanceTest}/Autobahn/AutobahnTester.cs (100%) rename test/{Microsoft.AspNetCore.WebSockets.Server.Test => Microsoft.AspNetCore.WebSockets.Server.ConformanceTest}/Autobahn/Executable.cs (100%) rename test/{Microsoft.AspNetCore.WebSockets.Server.Test => Microsoft.AspNetCore.WebSockets.Server.ConformanceTest}/Autobahn/Expectation.cs (100%) rename test/{Microsoft.AspNetCore.WebSockets.Server.Test => Microsoft.AspNetCore.WebSockets.Server.ConformanceTest}/Autobahn/ServerSpec.cs (100%) rename test/{Microsoft.AspNetCore.WebSockets.Server.Test => Microsoft.AspNetCore.WebSockets.Server.ConformanceTest}/Autobahn/Wstest.cs (100%) rename test/{Microsoft.AspNetCore.WebSockets.Server.Test => Microsoft.AspNetCore.WebSockets.Server.ConformanceTest}/AutobahnTests.cs (85%) rename test/{Microsoft.AspNetCore.WebSockets.Server.Test => Microsoft.AspNetCore.WebSockets.Server.ConformanceTest}/Helpers.cs (100%) rename test/{Microsoft.AspNetCore.WebSockets.Server.Test/Microsoft.AspNetCore.WebSockets.Server.Test.xproj => Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest.xproj} (73%) rename test/{Microsoft.AspNetCore.WebSockets.Server.Test => Microsoft.AspNetCore.WebSockets.Server.ConformanceTest}/Properties/AssemblyInfo.cs (100%) rename test/{Microsoft.AspNetCore.WebSockets.Server.Test => Microsoft.AspNetCore.WebSockets.Server.ConformanceTest}/SkipIfWsTestNotPresentAttribute.cs (100%) rename test/{Microsoft.AspNetCore.WebSockets.Server.Test => Microsoft.AspNetCore.WebSockets.Server.ConformanceTest}/project.json (100%) diff --git a/WebSockets.sln b/WebSockets.sln index a79504e978..8c2c5904a1 100644 --- a/WebSockets.sln +++ b/WebSockets.sln @@ -10,8 +10,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{9E55 EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Protocol", "src\Microsoft.AspNetCore.WebSockets.Protocol\Microsoft.AspNetCore.WebSockets.Protocol.xproj", "{E0C10DEC-3339-4A47-85BC-3100C5D34AD4}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Protocol.Test", "test\Microsoft.AspNetCore.WebSockets.Protocol.Test\Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj", "{62A07A24-4D06-4DDA-B6BF-02D0C9CB7D32}" -EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Client", "src\Microsoft.AspNetCore.WebSockets.Client\Microsoft.AspNetCore.WebSockets.Client.xproj", "{4A1C4875-AE21-4A78-979A-F0E4DF5EB518}" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Client.Test", "test\Microsoft.AspNetCore.WebSockets.Client.Test\Microsoft.AspNetCore.WebSockets.Client.Test.xproj", "{6604D154-817F-4BC5-BE95-FF7E851179D9}" @@ -27,14 +25,21 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestClient", "samples\TestC EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestServer", "samples\TestServer\TestServer.csproj", "{4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Server.Test", "test\Microsoft.AspNetCore.WebSockets.Server.Test\Microsoft.AspNetCore.WebSockets.Server.Test.xproj", "{E82D9F64-8AFA-4DCB-A842-2283FDA73BE8}" -EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AutobahnTestApp", "test\AutobahnTestApp\AutobahnTestApp.xproj", "{9755F612-A155-4BDD-9E20-37ADE0B4B3BA}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutobahnTestAppAspNet4", "samples\AutobahnTestAppAspNet4\AutobahnTestAppAspNet4.csproj", "{72E3AB32-682F-42AF-B7C7-0B777244FF11}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutobahnTestAppHttpListener", "samples\AutobahnTestAppHttpListener\AutobahnTestAppHttpListener.csproj", "{B7246F23-6A4B-492F-AB61-292AA1A9E9D5}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{19595D64-E42E-46FD-AB2E-BDC870724EE7}" + ProjectSection(SolutionItems) = preProject + scripts\UpdateCoreFxCode.ps1 = scripts\UpdateCoreFxCode.ps1 + EndProjectSection +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Server.ConformanceTest", "test\Microsoft.AspNetCore.WebSockets.Server.ConformanceTest\Microsoft.AspNetCore.WebSockets.Server.ConformanceTest.xproj", "{A722BB6C-9114-4F25-9BB0-2191D4405F3A}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Protocol.Test", "test\Microsoft.AspNetCore.WebSockets.Protocol.Test\Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj", "{AAF2DFCF-845E-4410-BBF0-0683AD60DD6A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -45,10 +50,6 @@ Global {E0C10DEC-3339-4A47-85BC-3100C5D34AD4}.Debug|Any CPU.Build.0 = Debug|Any CPU {E0C10DEC-3339-4A47-85BC-3100C5D34AD4}.Release|Any CPU.ActiveCfg = Release|Any CPU {E0C10DEC-3339-4A47-85BC-3100C5D34AD4}.Release|Any CPU.Build.0 = Release|Any CPU - {62A07A24-4D06-4DDA-B6BF-02D0C9CB7D32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {62A07A24-4D06-4DDA-B6BF-02D0C9CB7D32}.Debug|Any CPU.Build.0 = Debug|Any CPU - {62A07A24-4D06-4DDA-B6BF-02D0C9CB7D32}.Release|Any CPU.ActiveCfg = Release|Any CPU - {62A07A24-4D06-4DDA-B6BF-02D0C9CB7D32}.Release|Any CPU.Build.0 = Release|Any CPU {4A1C4875-AE21-4A78-979A-F0E4DF5EB518}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4A1C4875-AE21-4A78-979A-F0E4DF5EB518}.Debug|Any CPU.Build.0 = Debug|Any CPU {4A1C4875-AE21-4A78-979A-F0E4DF5EB518}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -69,10 +70,6 @@ Global {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Debug|Any CPU.Build.0 = Debug|Any CPU {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Release|Any CPU.ActiveCfg = Release|Any CPU {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Release|Any CPU.Build.0 = Release|Any CPU - {E82D9F64-8AFA-4DCB-A842-2283FDA73BE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E82D9F64-8AFA-4DCB-A842-2283FDA73BE8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E82D9F64-8AFA-4DCB-A842-2283FDA73BE8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E82D9F64-8AFA-4DCB-A842-2283FDA73BE8}.Release|Any CPU.Build.0 = Release|Any CPU {9755F612-A155-4BDD-9E20-37ADE0B4B3BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9755F612-A155-4BDD-9E20-37ADE0B4B3BA}.Debug|Any CPU.Build.0 = Debug|Any CPU {9755F612-A155-4BDD-9E20-37ADE0B4B3BA}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -85,21 +82,29 @@ Global {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Debug|Any CPU.Build.0 = Debug|Any CPU {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Release|Any CPU.ActiveCfg = Release|Any CPU {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Release|Any CPU.Build.0 = Release|Any CPU + {A722BB6C-9114-4F25-9BB0-2191D4405F3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A722BB6C-9114-4F25-9BB0-2191D4405F3A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A722BB6C-9114-4F25-9BB0-2191D4405F3A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A722BB6C-9114-4F25-9BB0-2191D4405F3A}.Release|Any CPU.Build.0 = Release|Any CPU + {AAF2DFCF-845E-4410-BBF0-0683AD60DD6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AAF2DFCF-845E-4410-BBF0-0683AD60DD6A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AAF2DFCF-845E-4410-BBF0-0683AD60DD6A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AAF2DFCF-845E-4410-BBF0-0683AD60DD6A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {E0C10DEC-3339-4A47-85BC-3100C5D34AD4} = {2C7947A5-9FBD-4267-97C1-2D726D7B3BAF} - {62A07A24-4D06-4DDA-B6BF-02D0C9CB7D32} = {C45106D0-76C8-4776-A140-F7DD83CA2958} {4A1C4875-AE21-4A78-979A-F0E4DF5EB518} = {2C7947A5-9FBD-4267-97C1-2D726D7B3BAF} {6604D154-817F-4BC5-BE95-FF7E851179D9} = {C45106D0-76C8-4776-A140-F7DD83CA2958} {78A097D0-C0A4-4AED-93E2-84A65392FB52} = {2C7947A5-9FBD-4267-97C1-2D726D7B3BAF} {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} - {E82D9F64-8AFA-4DCB-A842-2283FDA73BE8} = {C45106D0-76C8-4776-A140-F7DD83CA2958} {9755F612-A155-4BDD-9E20-37ADE0B4B3BA} = {C45106D0-76C8-4776-A140-F7DD83CA2958} {72E3AB32-682F-42AF-B7C7-0B777244FF11} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} {B7246F23-6A4B-492F-AB61-292AA1A9E9D5} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} + {A722BB6C-9114-4F25-9BB0-2191D4405F3A} = {C45106D0-76C8-4776-A140-F7DD83CA2958} + {AAF2DFCF-845E-4410-BBF0-0683AD60DD6A} = {C45106D0-76C8-4776-A140-F7DD83CA2958} EndGlobalSection EndGlobal diff --git a/scripts/UpdateCoreFxCode.ps1 b/scripts/UpdateCoreFxCode.ps1 new file mode 100644 index 0000000000..bc1d772500 --- /dev/null +++ b/scripts/UpdateCoreFxCode.ps1 @@ -0,0 +1,44 @@ +param([string]$CoreFxRepoRoot) + +$RepoRoot = Split-Path -Parent $PSScriptRoot + +$FilesToCopy = @( + "src\System.Net.WebSockets.Client\src\System\Net\WebSockets\ManagedWebSocket.cs", + "src\Common\src\System\Net\WebSockets\WebSocketValidate.cs" +) + +if(!$CoreFxRepoRoot) { + $CoreFxRepoRoot = "$RepoRoot\..\..\dotnet\corefx" +} + +if(!(Test-Path $CoreFxRepoRoot)) { + throw "Could not find CoreFx repo at $CoreFxRepoRoot" +} +$CoreFxRepoRoot = Convert-Path $CoreFxRepoRoot + +$DestinationRoot = "$RepoRoot\src\Microsoft.AspNetCore.WebSockets.Protocol\ext" + +$FilesToCopy | foreach { + $Source = Join-Path $CoreFxRepoRoot $_ + $Destination = Join-Path $DestinationRoot $_ + $DestinationDir = Split-Path -Parent $Destination + + if(!(Test-Path $Source)) { + Write-Warning "Can't find source file: $Source" + } else { + if(!(Test-Path $DestinationDir)) { + mkdir $DestinationDir | Out-Null + } + if(Test-Path $Destination) { + del $Destination + } + Write-Host "Copying $_" + + $SourceCode = [IO.File]::ReadAllText($Source) + $SourceCode = $SourceCode.Replace("Task.FromException", "CompatHelpers.FromException") + $SourceCode = $SourceCode.Replace("Task.CompletedTask", "CompatHelpers.CompletedTask") + $SourceCode = $SourceCode.Replace("Array.Empty", "CompatHelpers.Empty") + $SourceCode = $SourceCode.Replace("nameof(ClientWebSocket)", "`"ClientWebSocket`"") + [IO.File]::WriteAllText($Destination, $SourceCode) + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets.Client/WebSocketClient.cs b/src/Microsoft.AspNetCore.WebSockets.Client/WebSocketClient.cs index 8e924734f1..7445a80873 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Client/WebSocketClient.cs +++ b/src/Microsoft.AspNetCore.WebSockets.Client/WebSocketClient.cs @@ -53,12 +53,6 @@ namespace Microsoft.AspNetCore.WebSockets.Client set; } - public bool UseZeroMask - { - get; - set; - } - public Action ConfigureRequest { get; @@ -114,7 +108,7 @@ namespace Microsoft.AspNetCore.WebSockets.Client Stream stream = response.GetResponseStream(); - return CommonWebSocket.CreateClientWebSocket(stream, subProtocol, KeepAliveInterval, ReceiveBufferSize, useZeroMask: UseZeroMask); + return CommonWebSocket.CreateClientWebSocket(stream, subProtocol, KeepAliveInterval, ReceiveBufferSize); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/CommonWebSocket.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/CommonWebSocket.cs index 56baf28d2f..78f29aa9ca 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/CommonWebSocket.cs +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/CommonWebSocket.cs @@ -2,644 +2,31 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Diagnostics.Contracts; using System.IO; -using System.Linq; using System.Net.WebSockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading; -using System.Threading.Tasks; namespace Microsoft.AspNetCore.WebSockets.Protocol { - // https://tools.ietf.org/html/rfc6455 - public class CommonWebSocket : WebSocket + public static class CommonWebSocket { - private readonly static byte[] PingBuffer = Encoding.ASCII.GetBytes("abcdefghijklmnopqrstuvwxyz"); - private static readonly RandomNumberGenerator _rng = RandomNumberGenerator.Create(); - - private readonly Stream _stream; - private readonly string _subProtocl; - private readonly bool _maskOutput; - private readonly bool _unmaskInput; - private readonly bool _useZeroMask; - private readonly SemaphoreSlim _writeLock; - private readonly Timer _keepAliveTimer; - - private WebSocketState _state; - - private WebSocketCloseStatus? _closeStatus; - private string _closeStatusDescription; - - private bool _isOutgoingMessageInProgress; - - private byte[] _receiveBuffer; - private int _receiveBufferOffset; - private int _receiveBufferBytes; - - private FrameHeader _frameInProgress; - private long _frameBytesRemaining; - private int? _firstDataOpCode; - private int _dataUnmaskOffset; - private Utilities.Utf8MessageState _incomingUtf8MessageState = new Utilities.Utf8MessageState(); - - public CommonWebSocket(Stream stream, string subProtocol, TimeSpan keepAliveInterval, int receiveBufferSize, bool maskOutput, bool useZeroMask, bool unmaskInput) + public static WebSocket CreateClientWebSocket(Stream stream, string subProtocol, TimeSpan keepAliveInterval, int receiveBufferSize) { - _stream = stream; - _subProtocl = subProtocol; - _state = WebSocketState.Open; - _receiveBuffer = new byte[receiveBufferSize]; - _maskOutput = maskOutput; - _useZeroMask = useZeroMask; - _unmaskInput = unmaskInput; - _writeLock = new SemaphoreSlim(1); - if (keepAliveInterval != Timeout.InfiniteTimeSpan) - { - _keepAliveTimer = new Timer(SendKeepAlive, this, keepAliveInterval, keepAliveInterval); - } + return ManagedWebSocket.CreateFromConnectedStream( + stream, + isServer: false, + subprotocol: subProtocol, + keepAliveIntervalSeconds: (int)keepAliveInterval.TotalSeconds, + receiveBufferSize: receiveBufferSize); } - public static CommonWebSocket CreateClientWebSocket(Stream stream, string subProtocol, TimeSpan keepAliveInterval, int receiveBufferSize, bool useZeroMask) + public static WebSocket CreateServerWebSocket(Stream stream, string subProtocol, TimeSpan keepAliveInterval, int receiveBufferSize) { - return new CommonWebSocket(stream, subProtocol, keepAliveInterval, receiveBufferSize, maskOutput: true, useZeroMask: useZeroMask, unmaskInput: false); - } - - public static CommonWebSocket CreateServerWebSocket(Stream stream, string subProtocol, TimeSpan keepAliveInterval, int receiveBufferSize) - { - return new CommonWebSocket(stream, subProtocol, keepAliveInterval, receiveBufferSize, maskOutput: false, useZeroMask: false, unmaskInput: true); - } - - public override WebSocketCloseStatus? CloseStatus - { - get { return _closeStatus; } - } - - public override string CloseStatusDescription - { - get { return _closeStatusDescription; } - } - - public override WebSocketState State - { - get { return _state; } - } - - public override string SubProtocol - { - get { return _subProtocl; } - } - - // https://tools.ietf.org/html/rfc6455#section-5.3 - // The masking key is a 32-bit value chosen at random by the client. - // When preparing a masked frame, the client MUST pick a fresh masking - // key from the set of allowed 32-bit values. The masking key needs to - // be unpredictable; thus, the masking key MUST be derived from a strong - // source of entropy, and the masking key for a given frame MUST NOT - // make it simple for a server/proxy to predict the masking key for a - // subsequent frame. The unpredictability of the masking key is - // essential to prevent authors of malicious applications from selecting - // the bytes that appear on the wire. RFC 4086 [RFC4086] discusses what - // entails a suitable source of entropy for security-sensitive - // applications. - private int GetNextMask() - { - if (_useZeroMask) - { - return 0; - } - - // Get 32-bits of randomness and convert it to an int - var buffer = new byte[sizeof(int)]; - _rng.GetBytes(buffer); - return BitConverter.ToInt32(buffer, 0); - } - - public override async Task SendAsync(ArraySegment buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken) - { - ValidateSegment(buffer); - if (messageType != WebSocketMessageType.Binary && messageType != WebSocketMessageType.Text) - { - // Block control frames - throw new ArgumentOutOfRangeException(nameof(messageType), messageType, string.Empty); - } - - // Check concurrent writes, pings & pongs, or closes - await _writeLock.WaitAsync(cancellationToken); - try - { - ThrowIfDisposed(); - ThrowIfOutputClosed(); - - int mask = GetNextMask(); - int opcode = _isOutgoingMessageInProgress ? Constants.OpCodes.ContinuationFrame : Utilities.GetOpCode(messageType); - FrameHeader frameHeader = new FrameHeader(endOfMessage, opcode, _maskOutput, mask, buffer.Count); - ArraySegment headerSegment = frameHeader.Buffer; - - if (_maskOutput && mask != 0) - { - // TODO: For larger messages consider using a limited size buffer and masking & sending in segments. - byte[] maskedFrame = Utilities.MergeAndMask(mask, headerSegment, buffer); - await _stream.WriteAsync(maskedFrame, 0, maskedFrame.Length, cancellationToken); - } - else - { - await _stream.WriteAsync(headerSegment.Array, headerSegment.Offset, headerSegment.Count, cancellationToken); - await _stream.WriteAsync(buffer.Array, buffer.Offset, buffer.Count, cancellationToken); - } - - _isOutgoingMessageInProgress = !endOfMessage; - } - finally - { - _writeLock.Release(); - } - } - - private static void SendKeepAlive(object state) - { - CommonWebSocket websocket = (CommonWebSocket)state; - websocket.SendKeepAliveAsync(); - } - - private async void SendKeepAliveAsync() - { - // Check concurrent writes, pings & pongs, or closes - if (!_writeLock.Wait(0)) - { - // Sending real data is better than a ping, discard it. - return; - } - try - { - if (State == WebSocketState.CloseSent || State >= WebSocketState.Closed) - { - _keepAliveTimer.Dispose(); - return; - } - - int mask = GetNextMask(); - FrameHeader frameHeader = new FrameHeader(true, Constants.OpCodes.PingFrame, _maskOutput, mask, PingBuffer.Length); - ArraySegment headerSegment = frameHeader.Buffer; - - // TODO: CancelationToken / timeout? - if (_maskOutput && mask != 0) - { - byte[] maskedFrame = Utilities.MergeAndMask(mask, headerSegment, new ArraySegment(PingBuffer)); - await _stream.WriteAsync(maskedFrame, 0, maskedFrame.Length); - } - else - { - await _stream.WriteAsync(headerSegment.Array, headerSegment.Offset, headerSegment.Count); - await _stream.WriteAsync(PingBuffer, 0, PingBuffer.Length); - } - } - catch (Exception) - { - // TODO: Log exception, this is a background thread. - - // Shut down, we must be in a faulted state; - Abort(); - } - finally - { - _writeLock.Release(); - } - } - - public async override Task ReceiveAsync(ArraySegment buffer, CancellationToken cancellationToken) - { - ThrowIfDisposed(); - ThrowIfInputClosed(); - ValidateSegment(buffer); - // TODO: InvalidOperationException if any receives are currently in progress. - - // No active frame. Loop because we may be discarding ping/pong frames. - while (_frameInProgress == null) - { - await ReadNextFrameAsync(cancellationToken); - } - - int opCode = _frameInProgress.OpCode; - - if (opCode == Constants.OpCodes.CloseFrame) - { - return await ProcessCloseFrameAsync(cancellationToken); - } - - // Handle fragmentation, remember the first frame type - if (opCode == Constants.OpCodes.ContinuationFrame) - { - if (!_firstDataOpCode.HasValue) - { - await SendErrorAbortAndThrow(WebSocketCloseStatus.ProtocolError, "Invalid continuation frame", cancellationToken); - } - opCode = _firstDataOpCode.Value; - } - else - { - _firstDataOpCode = opCode; - } - - // Make sure there's at least some data in the buffer - int bytesToBuffer = (int)Math.Min((long)_receiveBuffer.Length, _frameBytesRemaining); - await EnsureDataAvailableOrReadAsync(bytesToBuffer, cancellationToken); - - // Copy buffered data to the users buffer - int bytesToRead = (int)Math.Min((long)buffer.Count, _frameBytesRemaining); - int bytesToCopy = Math.Min(bytesToRead, _receiveBufferBytes); - Array.Copy(_receiveBuffer, _receiveBufferOffset, buffer.Array, buffer.Offset, bytesToCopy); - - if (_unmaskInput) - { - // _frameInProgress.Masked == _unmaskInput already verified - Utilities.MaskInPlace(_frameInProgress.MaskKey, ref _dataUnmaskOffset, new ArraySegment(buffer.Array, buffer.Offset, bytesToCopy)); - } - - WebSocketReceiveResult result; - WebSocketMessageType messageType = Utilities.GetMessageType(opCode); - - if (messageType == WebSocketMessageType.Text - && !Utilities.TryValidateUtf8(new ArraySegment(buffer.Array, buffer.Offset, bytesToCopy), _frameInProgress.Fin, _incomingUtf8MessageState)) - { - await SendErrorAbortAndThrow(WebSocketCloseStatus.InvalidPayloadData, "Invalid UTF-8", cancellationToken); - } - - if (bytesToCopy == _frameBytesRemaining) - { - result = new WebSocketReceiveResult(bytesToCopy, messageType, _frameInProgress.Fin); - if (_frameInProgress.Fin) - { - _firstDataOpCode = null; - } - _frameInProgress = null; - _dataUnmaskOffset = 0; - } - else - { - result = new WebSocketReceiveResult(bytesToCopy, messageType, false); - } - - _frameBytesRemaining -= bytesToCopy; - _receiveBufferBytes -= bytesToCopy; - _receiveBufferOffset += bytesToCopy; - - return result; - } - - private async Task ReadNextFrameAsync(CancellationToken cancellationToken) - { - await EnsureDataAvailableOrReadAsync(2, cancellationToken); - int frameHeaderSize = FrameHeader.CalculateFrameHeaderSize(_receiveBuffer[_receiveBufferOffset + 1]); - await EnsureDataAvailableOrReadAsync(frameHeaderSize, cancellationToken); - _frameInProgress = new FrameHeader(new ArraySegment(_receiveBuffer, _receiveBufferOffset, frameHeaderSize)); - _receiveBufferOffset += frameHeaderSize; - _receiveBufferBytes -= frameHeaderSize; - _frameBytesRemaining = _frameInProgress.DataLength; - - if (_frameInProgress.AreReservedSet()) - { - await SendErrorAbortAndThrow(WebSocketCloseStatus.ProtocolError, "Unexpected reserved bits set", cancellationToken); - } - - if (_unmaskInput != _frameInProgress.Masked) - { - await SendErrorAbortAndThrow(WebSocketCloseStatus.ProtocolError, "Incorrect masking", cancellationToken); - } - - if (!ValidateOpCode(_frameInProgress.OpCode)) - { - await SendErrorAbortAndThrow(WebSocketCloseStatus.ProtocolError, "Invalid opcode: " + _frameInProgress.OpCode, cancellationToken); - } - - if (_frameInProgress.IsControlFrame) - { - if (_frameBytesRemaining > 125) - { - await SendErrorAbortAndThrow(WebSocketCloseStatus.ProtocolError, "Invalid control frame size", cancellationToken); - } - - if (!_frameInProgress.Fin) - { - await SendErrorAbortAndThrow(WebSocketCloseStatus.ProtocolError, "Fragmented control frame", cancellationToken); - } - - if (_frameInProgress.OpCode == Constants.OpCodes.PingFrame || _frameInProgress.OpCode == Constants.OpCodes.PongFrame) - { - // Drain it, should be less than 125 bytes - await EnsureDataAvailableOrReadAsync((int)_frameBytesRemaining, cancellationToken); - - if (_frameInProgress.OpCode == Constants.OpCodes.PingFrame) - { - await SendPongReplyAsync(cancellationToken); - } - - _receiveBufferOffset += (int)_frameBytesRemaining; - _receiveBufferBytes -= (int)_frameBytesRemaining; - _frameBytesRemaining = 0; - _frameInProgress = null; - } - } - else if (_firstDataOpCode.HasValue && _frameInProgress.OpCode != Constants.OpCodes.ContinuationFrame) - { - // A data frame is already in progress, but this new frame is not a continuation frame. - await SendErrorAbortAndThrow(WebSocketCloseStatus.ProtocolError, "Expected a continuation frame: " + _frameInProgress.OpCode, cancellationToken); - } - } - - private async Task EnsureDataAvailableOrReadAsync(int bytesNeeded, CancellationToken cancellationToken) - { - // Adequate buffer space? - Contract.Assert(bytesNeeded <= _receiveBuffer.Length); - - // Insufficient buffered data - while (_receiveBufferBytes < bytesNeeded) - { - cancellationToken.ThrowIfCancellationRequested(); - - int spaceRemaining = _receiveBuffer.Length - (_receiveBufferOffset + _receiveBufferBytes); - if (_receiveBufferOffset > 0 && bytesNeeded > spaceRemaining) - { - // Some data in the buffer, shift down to make room - Array.Copy(_receiveBuffer, _receiveBufferOffset, _receiveBuffer, 0, _receiveBufferBytes); - _receiveBufferOffset = 0; - spaceRemaining = _receiveBuffer.Length - _receiveBufferBytes; - } - // Add to the end - int read = await _stream.ReadAsync(_receiveBuffer, _receiveBufferOffset + _receiveBufferBytes, spaceRemaining, cancellationToken); - if (read == 0) - { - throw new IOException("Unexpected end of stream"); - } - _receiveBufferBytes += read; - } - } - - // We received a ping, send a pong in reply - private async Task SendPongReplyAsync(CancellationToken cancellationToken) - { - await _writeLock.WaitAsync(cancellationToken); - try - { - if (State != WebSocketState.Open) - { - // Output closed, discard the pong. - return; - } - - ArraySegment dataSegment = new ArraySegment(_receiveBuffer, _receiveBufferOffset, (int)_frameBytesRemaining); - if (_unmaskInput) - { - // _frameInProgress.Masked == _unmaskInput already verified - Utilities.MaskInPlace(_frameInProgress.MaskKey, dataSegment); - } - - int mask = GetNextMask(); - FrameHeader header = new FrameHeader(true, Constants.OpCodes.PongFrame, _maskOutput, mask, _frameBytesRemaining); - if (_maskOutput) - { - Utilities.MaskInPlace(mask, dataSegment); - } - - ArraySegment headerSegment = header.Buffer; - await _stream.WriteAsync(headerSegment.Array, headerSegment.Offset, headerSegment.Count, cancellationToken); - await _stream.WriteAsync(dataSegment.Array, dataSegment.Offset, dataSegment.Count, cancellationToken); - } - finally - { - _writeLock.Release(); - } - } - - private async Task ProcessCloseFrameAsync(CancellationToken cancellationToken) - { - // The close message should be less than 125 bytes and fit in the buffer. - await EnsureDataAvailableOrReadAsync((int)_frameBytesRemaining, CancellationToken.None); - - // Status code and message are optional - if (_frameBytesRemaining >= 2) - { - if (_unmaskInput) - { - Utilities.MaskInPlace(_frameInProgress.MaskKey, new ArraySegment(_receiveBuffer, _receiveBufferOffset, (int)_frameBytesRemaining)); - } - _closeStatus = (WebSocketCloseStatus)((_receiveBuffer[_receiveBufferOffset] << 8) | _receiveBuffer[_receiveBufferOffset + 1]); - if (!ValidateCloseStatus(_closeStatus.Value)) - { - await SendErrorAbortAndThrow(WebSocketCloseStatus.ProtocolError, "Invalid close status code.", cancellationToken); - } - try - { - var encoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true); - _closeStatusDescription = encoding.GetString(_receiveBuffer, _receiveBufferOffset + 2, (int)_frameBytesRemaining - 2) ?? string.Empty; - } - catch (DecoderFallbackException) - { - await SendErrorAbortAndThrow(WebSocketCloseStatus.ProtocolError, "Invalid UTF-8 close message.", cancellationToken); - } - } - else if (_frameBytesRemaining == 1) - { - await SendErrorAbortAndThrow(WebSocketCloseStatus.ProtocolError, "Invalid close body.", cancellationToken); - } - else - { - _closeStatus = _closeStatus ?? WebSocketCloseStatus.NormalClosure; - _closeStatusDescription = _closeStatusDescription ?? string.Empty; - } - - Contract.Assert(_frameInProgress.Fin); - WebSocketReceiveResult result = new WebSocketReceiveResult(0, WebSocketMessageType.Close, _frameInProgress.Fin, - _closeStatus.Value, _closeStatusDescription); - - if (State == WebSocketState.Open) - { - _state = WebSocketState.CloseReceived; - } - else if (State == WebSocketState.CloseSent) - { - _state = WebSocketState.Closed; - _stream.Dispose(); - } - - return result; - } - - public async override Task CloseAsync(WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken) - { - ThrowIfDisposed(); - - if (State == WebSocketState.Open || State == WebSocketState.CloseReceived) - { - // Send a close message. - await CloseOutputAsync(closeStatus, statusDescription, cancellationToken); - } - - if (State == WebSocketState.CloseSent) - { - // Do a receiving drain - byte[] data = new byte[_receiveBuffer.Length]; - WebSocketReceiveResult result; - do - { - result = await ReceiveAsync(new ArraySegment(data), cancellationToken); - } - while (result.MessageType != WebSocketMessageType.Close); - } - } - - public override async Task CloseOutputAsync(WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken) - { - await _writeLock.WaitAsync(cancellationToken); - try - { - ThrowIfDisposed(); - ThrowIfOutputClosed(); - if (_keepAliveTimer != null) - { - _keepAliveTimer.Dispose(); - } - - byte[] descriptionBytes = Encoding.UTF8.GetBytes(statusDescription ?? string.Empty); - byte[] fullData = new byte[descriptionBytes.Length + 2]; - fullData[0] = (byte)((int)closeStatus >> 8); - fullData[1] = (byte)closeStatus; - Array.Copy(descriptionBytes, 0, fullData, 2, descriptionBytes.Length); - - int mask = GetNextMask(); - if (_maskOutput) - { - Utilities.MaskInPlace(mask, new ArraySegment(fullData)); - } - - FrameHeader frameHeader = new FrameHeader(true, Constants.OpCodes.CloseFrame, _maskOutput, mask, fullData.Length); - - ArraySegment segment = frameHeader.Buffer; - await _stream.WriteAsync(segment.Array, segment.Offset, segment.Count, cancellationToken); - await _stream.WriteAsync(fullData, 0, fullData.Length, cancellationToken); - - if (State == WebSocketState.Open) - { - _state = WebSocketState.CloseSent; - } - else if (State == WebSocketState.CloseReceived) - { - _state = WebSocketState.Closed; - _stream.Dispose(); - } - } - finally - { - _writeLock.Release(); - } - } - - public override void Abort() - { - if (_state >= WebSocketState.Closed) // or Aborted - { - return; - } - - _state = WebSocketState.Aborted; - if (_keepAliveTimer != null) - { - _keepAliveTimer.Dispose(); - } - _stream.Dispose(); - } - - public override void Dispose() - { - if (_state >= WebSocketState.Closed) // or Aborted - { - return; - } - - _state = WebSocketState.Closed; - if (_keepAliveTimer != null) - { - _keepAliveTimer.Dispose(); - } - _stream.Dispose(); - } - - private void ThrowIfDisposed() - { - if (_state >= WebSocketState.Closed) // or Aborted - { - throw new ObjectDisposedException(typeof(CommonWebSocket).FullName); - } - } - - private void ThrowIfOutputClosed() - { - if (State == WebSocketState.CloseSent) - { - throw new InvalidOperationException("Close already sent."); - } - } - - private void ThrowIfInputClosed() - { - if (State == WebSocketState.CloseReceived) - { - throw new InvalidOperationException("Close already received."); - } - } - - private void ValidateSegment(ArraySegment buffer) - { - if (buffer.Array == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - if (buffer.Offset < 0 || buffer.Offset > buffer.Array.Length) - { - throw new ArgumentOutOfRangeException(nameof(buffer.Offset), buffer.Offset, string.Empty); - } - if (buffer.Count < 0 || buffer.Count > buffer.Array.Length - buffer.Offset) - { - throw new ArgumentOutOfRangeException(nameof(buffer.Count), buffer.Count, string.Empty); - } - } - - private bool ValidateOpCode(int opCode) - { - return Constants.OpCodes.ValidOpCodes.Contains(opCode); - } - - private static bool ValidateCloseStatus(WebSocketCloseStatus closeStatus) - { - if (closeStatus < (WebSocketCloseStatus)1000 || closeStatus >= (WebSocketCloseStatus)5000) - { - return false; - } - else if (closeStatus >= (WebSocketCloseStatus)3000) - { - // 3000-3999 - Reserved for frameworks - // 4000-4999 - Reserved for private usage - return true; - } - int[] validCodes = new[] { 1000, 1001, 1002, 1003, 1007, 1008, 1009, 1010, 1011 }; - foreach (var validCode in validCodes) - { - if (closeStatus == (WebSocketCloseStatus)validCode) - { - return true; - } - } - return false; - } - - private async Task SendErrorAbortAndThrow(WebSocketCloseStatus error, string message, CancellationToken cancellationToken) - { - if (State == WebSocketState.Open || State == WebSocketState.CloseReceived) - { - await CloseOutputAsync(error, message, cancellationToken); - } - Abort(); - throw new InvalidOperationException(message); // TODO: WebSocketException + return ManagedWebSocket.CreateFromConnectedStream( + stream, + isServer: true, + subprotocol: subProtocol, + keepAliveIntervalSeconds: (int)keepAliveInterval.TotalSeconds, + receiveBufferSize: receiveBufferSize); } } } diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/CompatHelpers.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/CompatHelpers.cs new file mode 100644 index 0000000000..53dc09608f --- /dev/null +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/CompatHelpers.cs @@ -0,0 +1,49 @@ +using System.Threading.Tasks; + +namespace System.Net.WebSockets +{ + // Needed to support the WebSockets code from CoreFX. + internal static class CompatHelpers + { + internal static readonly Task CompletedTask; + + static CompatHelpers() + { + var tcs = new TaskCompletionSource(); + tcs.SetResult(null); + CompletedTask = tcs.Task; + } + + public static Task FromException(Exception ex) + { +#if NET451 + return FromException(ex); +#else + return Task.FromException(ex); +#endif + } + + public static Task FromException(Exception ex) + { +#if NET451 + var tcs = new TaskCompletionSource(); + tcs.SetException(ex); + return tcs.Task; +#else + return Task.FromException(ex); +#endif + } + + internal static T[] Empty() + { +#if NET451 + return new T[0]; +#else + return Array.Empty(); +#endif + } + } + + // This is just here to be used by a nameof in the CoreFX code. + //internal static class ClientWebSocket { } +} diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/FrameHeader.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/FrameHeader.cs deleted file mode 100644 index 50fe6060b4..0000000000 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/FrameHeader.cs +++ /dev/null @@ -1,252 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.WebSockets; -using System.Text; -using System.Threading.Tasks; - -namespace Microsoft.AspNetCore.WebSockets.Protocol -{ - public class FrameHeader - { - private byte[] _header; - - public FrameHeader(ArraySegment header) - { - _header = new byte[header.Count]; - Array.Copy(header.Array, header.Offset, _header, 0, _header.Length); - } - - public FrameHeader(bool final, int opCode, bool masked, int maskKey, long dataLength) - { - int headerLength = 2; - if (masked) - { - headerLength += 4; - } - - if (dataLength <= 125) - { - } - else if (125 < dataLength && dataLength <= 0xFFFF) - { - headerLength += 2; - } - else - { - headerLength += 8; - } - _header = new byte[headerLength]; - - Fin = final; - OpCode = opCode; - Masked = masked; - DataLength = dataLength; - if (masked) - { - MaskKey = maskKey; - } - } - - public bool Fin - { - get - { - return (_header[0] & 0x80) == 0x80; - } - private set - { - if (value) - { - _header[0] |= 0x80; - } - else - { - _header[0] &= 0x7F; - } - } - } - - public int OpCode - { - get - { - return (_header[0] & 0xF); - } - private set - { - // TODO: Clear out a prior value? - _header[0] |= (byte)(value & 0xF); - } - } - - public bool Masked - { - get - { - return (_header[1] & 0x80) == 0x80; - } - private set - { - if (value) - { - _header[1] |= 0x80; - } - else - { - _header[1] &= 0x7F; - } - } - } - - public int MaskKey - { - get - { - if (!Masked) - { - return 0; - } - int offset = ExtendedLengthFieldSize + 2; - return (_header[offset] << 24) + (_header[offset + 1] << 16) - + (_header[offset + 2] << 8) + _header[offset + 3]; - } - private set - { - int offset = ExtendedLengthFieldSize + 2; - _header[offset] = (byte)(value >> 24); - _header[offset + 1] = (byte)(value >> 16); - _header[offset + 2] = (byte)(value >> 8); - _header[offset + 3] = (byte)value; - } - } - - public int PayloadField - { - get - { - return (_header[1] & 0x7F); - } - private set - { - // TODO: Clear out a prior value? - _header[1] |= (byte)(value & 0x7F); - } - } - - public int ExtendedLengthFieldSize - { - get - { - int payloadField = PayloadField; - if (payloadField <= 125) - { - return 0; - } - if (payloadField == 126) - { - return 2; - } - return 8; - } - } - - public long DataLength - { - get - { - int extendedFieldSize = ExtendedLengthFieldSize; - if (extendedFieldSize == 0) - { - return PayloadField; - } - if (extendedFieldSize == 2) - { - return (_header[2] << 8) + _header[3]; - } - return (_header[2] << 56) + (_header[3] << 48) - + (_header[4] << 40) + (_header[5] << 32) - + (_header[6] << 24) + (_header[7] << 16) - + (_header[8] << 8) + _header[9]; - } - private set - { - if (value <= 125) - { - PayloadField = (int)value; - } - else if (125 < value && value <= 0xFFFF) - { - PayloadField = 0x7E; - - _header[2] = (byte)(value >> 8); - _header[3] = (byte)value; - } - else - { - PayloadField = 0x7F; - - _header[2] = (byte)(value >> 56); - _header[3] = (byte)(value >> 48); - _header[4] = (byte)(value >> 40); - _header[5] = (byte)(value >> 32); - _header[6] = (byte)(value >> 24); - _header[7] = (byte)(value >> 16); - _header[8] = (byte)(value >> 8); - _header[9] = (byte)value; - } - } - } - - public ArraySegment Buffer - { - get - { - return new ArraySegment(_header); - } - } - - public bool IsControlFrame - { - get - { - return OpCode >= Constants.OpCodes.CloseFrame; - } - } - - // bits 1-3. - internal bool AreReservedSet() - { - return (_header[0] & 0x70) != 0; - } - - // Given the second bytes of a frame, calculate how long the whole frame header should be. - // Range 2-12 bytes - public static int CalculateFrameHeaderSize(byte b2) - { - int headerLength = 2; - if ((b2 & 0x80) == 0x80) // Masked - { - headerLength += 4; - } - - int payloadField = (b2 & 0x7F); - if (payloadField <= 125) - { - // headerLength += 0 - } - else if (payloadField == 126) - { - headerLength += 2; - } - else - { - headerLength += 8; - } - return headerLength; - } - } -} diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/SR.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/SR.cs new file mode 100644 index 0000000000..4466198e20 --- /dev/null +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/SR.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace System.Net.WebSockets +{ + // Needed to support the WebSockets code from CoreFX. + internal static class SR + { + internal static readonly string net_Websockets_AlreadyOneOutstandingOperation = nameof(net_Websockets_AlreadyOneOutstandingOperation); + internal static readonly string net_WebSockets_Argument_InvalidMessageType = nameof(net_WebSockets_Argument_InvalidMessageType); + internal static readonly string net_WebSockets_InvalidCharInProtocolString = nameof(net_WebSockets_InvalidCharInProtocolString); + internal static readonly string net_WebSockets_InvalidCloseStatusCode = nameof(net_WebSockets_InvalidCloseStatusCode); + internal static readonly string net_WebSockets_InvalidCloseStatusDescription = nameof(net_WebSockets_InvalidCloseStatusDescription); + internal static readonly string net_WebSockets_InvalidEmptySubProtocol = nameof(net_WebSockets_InvalidEmptySubProtocol); + internal static readonly string net_WebSockets_InvalidState = nameof(net_WebSockets_InvalidState); + internal static readonly string net_WebSockets_InvalidState_ClosedOrAborted = nameof(net_WebSockets_InvalidState_ClosedOrAborted); + internal static readonly string net_WebSockets_ReasonNotNull = nameof(net_WebSockets_ReasonNotNull); + internal static readonly string net_WebSockets_UnsupportedPlatform = nameof(net_WebSockets_UnsupportedPlatform); + + internal static string Format(string name, params object[] args) => $"TODO, RESX: {name}; ({string.Join(",", args)})"; + } +} diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/Utilities.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/Utilities.cs deleted file mode 100644 index c8ec5768c2..0000000000 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/Utilities.cs +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Net.WebSockets; - -namespace Microsoft.AspNetCore.WebSockets.Protocol -{ - public static class Utilities - { - // Copies the header and data into a new buffer and masks the data. - public static byte[] MergeAndMask(int mask, ArraySegment header, ArraySegment data) - { - byte[] frame = new byte[header.Count + data.Count]; - Array.Copy(header.Array, header.Offset, frame, 0, header.Count); - Array.Copy(data.Array, data.Offset, frame, header.Count, data.Count); - - MaskInPlace(mask, new ArraySegment(frame, header.Count, data.Count)); - return frame; - } - - public static void MaskInPlace(int mask, ArraySegment data) - { - int maskOffset = 0; - MaskInPlace(mask, ref maskOffset, data); - } - - public static void MaskInPlace(int mask, ref int maskOffset, ArraySegment data) - { - if (mask == 0) - { - return; - } - - byte[] maskBytes = new byte[] - { - (byte)(mask >> 24), - (byte)(mask >> 16), - (byte)(mask >> 8), - (byte)mask, - }; - - int end = data.Offset + data.Count; - for (int i = data.Offset; i < end; i++) - { - data.Array[i] ^= maskBytes[maskOffset]; - maskOffset = (maskOffset + 1) & 0x3; // fast % 4; - } - } - - public static int GetOpCode(WebSocketMessageType messageType) - { - switch (messageType) - { - case WebSocketMessageType.Text: return Constants.OpCodes.TextFrame; - case WebSocketMessageType.Binary: return Constants.OpCodes.BinaryFrame; - case WebSocketMessageType.Close: return Constants.OpCodes.CloseFrame; - default: throw new NotImplementedException(messageType.ToString()); - } - } - - public static WebSocketMessageType GetMessageType(int opCode) - { - switch (opCode) - { - case Constants.OpCodes.TextFrame: return WebSocketMessageType.Text; - case Constants.OpCodes.BinaryFrame: return WebSocketMessageType.Binary; - case Constants.OpCodes.CloseFrame: return WebSocketMessageType.Close; - default: throw new NotImplementedException(opCode.ToString()); - } - } - - // Performs a stateful validation of UTF-8 bytes. - // It checks for valid formatting, overlong encodings, surrogates, and value ranges. - public static bool TryValidateUtf8(ArraySegment arraySegment, bool endOfMessage, Utf8MessageState state) - { - for (int i = arraySegment.Offset; i < arraySegment.Offset + arraySegment.Count; ) - { - // Have we started a character sequence yet? - if (!state.SequenceInProgress) - { - // The first byte tells us how many bytes are in the sequence. - state.SequenceInProgress = true; - byte b = arraySegment.Array[i]; - i++; - if ((b & 0x80) == 0) // 0bbbbbbb, single byte - { - state.AdditionalBytesExpected = 0; - state.CurrentDecodeBits = b & 0x7F; - state.ExpectedValueMin = 0; - } - else if ((b & 0xC0) == 0x80) - { - // Misplaced 10bbbbbb continuation byte. This cannot be the first byte. - return false; - } - else if ((b & 0xE0) == 0xC0) // 110bbbbb 10bbbbbb - { - state.AdditionalBytesExpected = 1; - state.CurrentDecodeBits = b & 0x1F; - state.ExpectedValueMin = 0x80; - } - else if ((b & 0xF0) == 0xE0) // 1110bbbb 10bbbbbb 10bbbbbb - { - state.AdditionalBytesExpected = 2; - state.CurrentDecodeBits = b & 0xF; - state.ExpectedValueMin = 0x800; - } - else if ((b & 0xF8) == 0xF0) // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb - { - state.AdditionalBytesExpected = 3; - state.CurrentDecodeBits = b & 0x7; - state.ExpectedValueMin = 0x10000; - } - else // 111110bb & 1111110b & 11111110 && 11111111 are not valid - { - return false; - } - } - while (state.AdditionalBytesExpected > 0 && i < arraySegment.Offset + arraySegment.Count) - { - byte b = arraySegment.Array[i]; - if ((b & 0xC0) != 0x80) - { - return false; - } - - i++; - state.AdditionalBytesExpected--; - - // Each continuation byte carries 6 bits of data 0x10bbbbbb. - state.CurrentDecodeBits = (state.CurrentDecodeBits << 6) | (b & 0x3F); - - if (state.AdditionalBytesExpected == 1 && state.CurrentDecodeBits >= 0x360 && state.CurrentDecodeBits <= 0x37F) - { - // This is going to end up in the range of 0xD800-0xDFFF UTF-16 surrogates that are not allowed in UTF-8; - return false; - } - if (state.AdditionalBytesExpected == 2 && state.CurrentDecodeBits >= 0x110) - { - // This is going to be out of the upper Unicode bound 0x10FFFF. - return false; - } - } - if (state.AdditionalBytesExpected == 0) - { - state.SequenceInProgress = false; - if (state.CurrentDecodeBits < state.ExpectedValueMin) - { - // Overlong encoding (e.g. using 2 bytes to encode something that only needed 1). - return false; - } - } - } - if (endOfMessage && state.SequenceInProgress) - { - return false; - } - return true; - } - - public class Utf8MessageState - { - public bool SequenceInProgress { get; set; } - public int AdditionalBytesExpected { get; set; } - public int ExpectedValueMin { get; set; } - public int CurrentDecodeBits { get; set; } - } - } -} diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/ext/README.md b/src/Microsoft.AspNetCore.WebSockets.Protocol/ext/README.md new file mode 100644 index 0000000000..4b8f84b7ed --- /dev/null +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/ext/README.md @@ -0,0 +1,5 @@ +# External Code + +External code copied from CoreFX. Do not modify files in this directory, use the `scripts\UpdateCoreFxCore.ps1` script in the repo root. + +This folder structure is designed to exactly mirror the structure in the CoreFX repo (hence the deep nesting). \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/ext/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/ext/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs new file mode 100644 index 0000000000..06e07f29dd --- /dev/null +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/ext/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs @@ -0,0 +1,132 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Globalization; +using System.Text; + +namespace System.Net.WebSockets +{ + internal static class WebSocketValidate + { + internal const int MaxControlFramePayloadLength = 123; + private const int CloseStatusCodeAbort = 1006; + private const int CloseStatusCodeFailedTLSHandshake = 1015; + private const int InvalidCloseStatusCodesFrom = 0; + private const int InvalidCloseStatusCodesTo = 999; + private const string Separators = "()<>@,;:\\\"/[]?={} "; + + internal static void ValidateSubprotocol(string subProtocol) + { + if (string.IsNullOrWhiteSpace(subProtocol)) + { + throw new ArgumentException(SR.net_WebSockets_InvalidEmptySubProtocol, nameof(subProtocol)); + } + + string invalidChar = null; + int i = 0; + while (i < subProtocol.Length) + { + char ch = subProtocol[i]; + if (ch < 0x21 || ch > 0x7e) + { + invalidChar = string.Format(CultureInfo.InvariantCulture, "[{0}]", (int)ch); + break; + } + + if (!char.IsLetterOrDigit(ch) && + Separators.IndexOf(ch) >= 0) + { + invalidChar = ch.ToString(); + break; + } + + i++; + } + + if (invalidChar != null) + { + throw new ArgumentException(SR.Format(SR.net_WebSockets_InvalidCharInProtocolString, subProtocol, invalidChar), nameof(subProtocol)); + } + } + + internal static void ValidateCloseStatus(WebSocketCloseStatus closeStatus, string statusDescription) + { + if (closeStatus == WebSocketCloseStatus.Empty && !string.IsNullOrEmpty(statusDescription)) + { + throw new ArgumentException(SR.Format(SR.net_WebSockets_ReasonNotNull, + statusDescription, + WebSocketCloseStatus.Empty), + nameof(statusDescription)); + } + + int closeStatusCode = (int)closeStatus; + + if ((closeStatusCode >= InvalidCloseStatusCodesFrom && + closeStatusCode <= InvalidCloseStatusCodesTo) || + closeStatusCode == CloseStatusCodeAbort || + closeStatusCode == CloseStatusCodeFailedTLSHandshake) + { + // CloseStatus 1006 means Aborted - this will never appear on the wire and is reflected by calling WebSocket.Abort + throw new ArgumentException(SR.Format(SR.net_WebSockets_InvalidCloseStatusCode, + closeStatusCode), + nameof(closeStatus)); + } + + int length = 0; + if (!string.IsNullOrEmpty(statusDescription)) + { + length = Encoding.UTF8.GetByteCount(statusDescription); + } + + if (length > MaxControlFramePayloadLength) + { + throw new ArgumentException(SR.Format(SR.net_WebSockets_InvalidCloseStatusDescription, + statusDescription, + MaxControlFramePayloadLength), + nameof(statusDescription)); + } + } + + internal static void ThrowPlatformNotSupportedException() + { + throw new PlatformNotSupportedException(SR.net_WebSockets_UnsupportedPlatform); + } + + internal static void ValidateArraySegment(ArraySegment arraySegment, string parameterName) + { + if (arraySegment.Array == null) + { + throw new ArgumentNullException(parameterName + ".Array"); + } + } + + internal static void ThrowIfInvalidState(WebSocketState currentState, bool isDisposed, WebSocketState[] validStates) + { + string validStatesText = string.Empty; + + if (validStates != null && validStates.Length > 0) + { + foreach (WebSocketState validState in validStates) + { + if (currentState == validState) + { + // Ordering is important to maintain .NET 4.5 WebSocket implementation exception behavior. + if (isDisposed) + { + throw new ObjectDisposedException("ClientWebSocket"); + } + + return; + } + } + + validStatesText = string.Join(", ", validStates); + } + + throw new WebSocketException( + WebSocketError.InvalidState, + SR.Format(SR.net_WebSockets_InvalidState, currentState, validStatesText)); + } + } +} diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/ext/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ManagedWebSocket.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/ext/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ManagedWebSocket.cs new file mode 100644 index 0000000000..738b0a7348 --- /dev/null +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/ext/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ManagedWebSocket.cs @@ -0,0 +1,1312 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Diagnostics; +using System.IO; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Security.Cryptography; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +// NOTE: This file is shared between CoreFX and ASP.NET. Be very thoughtful when changing it. + +namespace System.Net.WebSockets +{ + /// A managed implementation of a web socket that sends and receives data via a . + /// + /// Thread-safety: + /// - It's acceptable to call ReceiveAsync and SendAsync in parallel. One of each may run concurrently. + /// - It's acceptable to have a pending ReceiveAsync while CloseOutputAsync or CloseAsync is called. + /// - Attemping to invoke any other operations in parallel may corrupt the instance. Attempting to invoke + /// a send operation while another is in progress or a receive operation while another is in progress will + /// result in an exception. + /// + internal sealed class ManagedWebSocket : WebSocket + { + /// Creates a from a connected to a websocket endpoint. + /// The connected Stream. + /// true if this is the server-side of the connection; false if this is the client-side of the connection. + /// The agreed upon subprotocol for the connection. + /// The current state of the websocket connection. + /// The interval to use for keep-alive pings. + /// The buffer size to use for received data. + /// The created instance. + public static ManagedWebSocket CreateFromConnectedStream( + Stream stream, bool isServer, string subprotocol, + int keepAliveIntervalSeconds = 30, int receiveBufferSize = 0x1000) + { + return new ManagedWebSocket(stream, isServer, subprotocol, TimeSpan.FromSeconds(keepAliveIntervalSeconds), receiveBufferSize); + } + + /// Per-thread cached 4-byte mask byte array. + [ThreadStatic] + private static byte[] t_headerMask; + + /// Thread-safe random number generator used to generate masks for each send. + private static readonly RandomNumberGenerator s_random = RandomNumberGenerator.Create(); + /// Encoding for the payload of text messages: UTF8 encoding that throws if invalid bytes are discovered, per the RFC. + private static readonly UTF8Encoding s_textEncoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true); + + /// Valid states to be in when calling SendAsync. + private static readonly WebSocketState[] s_validSendStates = { WebSocketState.Open, WebSocketState.CloseReceived }; + /// Valid states to be in when calling ReceiveAsync. + private static readonly WebSocketState[] s_validReceiveStates = { WebSocketState.Open, WebSocketState.CloseSent }; + /// Valid states to be in when calling CloseOutputAsync. + private static readonly WebSocketState[] s_validCloseOutputStates = { WebSocketState.Open, WebSocketState.CloseReceived }; + /// Valid states to be in when calling CloseAsync. + private static readonly WebSocketState[] s_validCloseStates = { WebSocketState.Open, WebSocketState.CloseReceived, WebSocketState.CloseSent }; + + /// The maximum size in bytes of a message frame header that includes mask bytes. + private const int MaxMessageHeaderLength = 14; + /// The maximum size of a control message payload. + private const int MaxControlPayloadLength = 125; + /// Length of the mask XOR'd with the payload data. + private const int MaskLength = 4; + + /// The stream used to communicate with the remote server. + private readonly Stream _stream; + /// + /// true if this is the server-side of the connection; false if it's client. + /// This impacts masking behavior: clients always mask payloads they send and + /// expect to always receive unmasked payloads, whereas servers always send + /// unmasked payloads and expect to always receive masked payloads. + /// + private readonly bool _isServer = false; + /// The agreed upon subprotocol with the server. + private readonly string _subprotocol; + /// Timer used to send periodic pings to the server, at the interval specified + private readonly Timer _keepAliveTimer; + /// CancellationTokenSource used to abort all current and future operations when anything is canceled or any error occurs. + private readonly CancellationTokenSource _abortSource = new CancellationTokenSource(); + /// Buffer used for reading data from the network. + private readonly byte[] _receiveBuffer; + /// + /// Tracks the state of the validity of the UTF8 encoding of text payloads. Text may be split across fragments. + /// + private readonly Utf8MessageState _utf8TextState = new Utf8MessageState(); + /// + /// Semaphore used to ensure that calls to SendFrameAsync don't run concurrently. While + /// is used to fail if a caller tries to issue another SendAsync while a previous one is running, internally + /// we use SendFrameAsync as an implementation detail, and it should not cause user requests to SendAsync to fail, + /// nor should such internal usage be allowed to run concurrently with other internal usage or with SendAsync. + /// + private readonly SemaphoreSlim _sendFrameAsyncLock = new SemaphoreSlim(1, 1); + + // We maintain the current WebSocketState in _state. However, we separately maintain _sentCloseFrame and _receivedCloseFrame + // as there isn't a strict ordering between CloseSent and CloseReceived. If we receive a close frame from the server, we need to + // transition to CloseReceived even if we're currently in CloseSent, and if we send a close frame, we need to transition to + // CloseSent even if we're currently in CloseReceived. + + /// The current state of the web socket in the protocol. + private WebSocketState _state = WebSocketState.Open; + /// true if Dispose has been called; otherwise, false. + private bool _disposed; + /// Whether we've ever sent a close frame. + private bool _sentCloseFrame; + /// Whether we've ever received a close frame. + private bool _receivedCloseFrame; + /// The reason for the close, as sent by the server, or null if not yet closed. + private WebSocketCloseStatus? _closeStatus = null; + /// A description of the close reason as sent by the server, or null if not yet closed. + private string _closeStatusDescription = null; + + /// + /// The last header received in a ReceiveAsync. If ReceiveAsync got a header but then + /// returned fewer bytes than was indicated in the header, subsequent ReceiveAsync calls + /// will use the data from the header to construct the subsequent receive results, and + /// the payload length in this header will be decremented to indicate the number of bytes + /// remaining to be received for that header. As a result, between fragments, the payload + /// length in this header should be 0. + /// + private MessageHeader _lastReceiveHeader = new MessageHeader { Opcode = MessageOpcode.Text, Fin = true }; + /// The offset of the next available byte in the _receiveBuffer. + private int _receiveBufferOffset = 0; + /// The number of bytes available in the _receiveBuffer. + private int _receiveBufferCount = 0; + /// + /// When dealing with partially read fragments of binary/text messages, a mask previously received may still + /// apply, and the first new byte received may not correspond to the 0th position in the mask. This value is + /// the next offset into the mask that should be applied. + /// + private int _receivedMaskOffsetOffset = 0; + /// + /// Buffer used to store the complete message to be sent to the stream. This is needed + /// rather than just sending a header and then the user's buffer, as we need to mutate the + /// buffered data with the mask, and we don't want to change the data in the user's buffer. + /// + private byte[] _sendBuffer; + /// + /// Whether the last SendAsync had endOfMessage==false. We need to track this so that we + /// can send the subsequent message with a continuation opcode if the last message was a fragment. + /// + private bool _lastSendWasFragment; + /// + /// The task returned from the last SendAsync operation to not complete synchronously. + /// If this is not null and not completed when a subsequent SendAsync is issued, an exception occurs. + /// + private Task _lastSendAsync; + /// + /// The task returned from the last ReceiveAsync operation to not complete synchronously. + /// If this is not null and not completed when a subsequent ReceiveAsync is issued, an exception occurs. + /// + private Task _lastReceiveAsync; + + /// Lock used to protect update and check-and-update operations on _state. + private object StateUpdateLock => _abortSource; + /// + /// We need to coordinate between receives and close operations happening concurrently, as a ReceiveAsync may + /// be pending while a Close{Output}Async is issued, which itself needs to loop until a close frame is received. + /// As such, we need thread-safety in the management of . + /// + private object ReceiveAsyncLock => _utf8TextState; // some object, as we're simply lock'ing on it + + /// Initializes the websocket. + /// The connected Stream. + /// true if this is the server-side of the connection; false if this is the client-side of the connection. + /// The agreed upon subprotocol for the connection. + /// The interval to use for keep-alive pings. + /// The buffer size to use for received data. + private ManagedWebSocket(Stream stream, bool isServer, string subprotocol, TimeSpan keepAliveInterval, int receiveBufferSize) + { + Debug.Assert(StateUpdateLock != null, $"Expected {nameof(StateUpdateLock)} to be non-null"); + Debug.Assert(ReceiveAsyncLock != null, $"Expected {nameof(ReceiveAsyncLock)} to be non-null"); + Debug.Assert(StateUpdateLock != ReceiveAsyncLock, "Locks should be different objects"); + + Debug.Assert(stream != null, $"Expected non-null stream"); + Debug.Assert(stream.CanRead, $"Expected readable stream"); + Debug.Assert(stream.CanWrite, $"Expected writeable stream"); + Debug.Assert(keepAliveInterval == Timeout.InfiniteTimeSpan || keepAliveInterval >= TimeSpan.Zero, $"Invalid keepalive interval: {keepAliveInterval}"); + Debug.Assert(receiveBufferSize >= MaxMessageHeaderLength, $"Receive buffer size {receiveBufferSize} is too small"); + + _stream = stream; + _isServer = isServer; + _subprotocol = subprotocol; + _receiveBuffer = new byte[Math.Max(receiveBufferSize, MaxMessageHeaderLength)]; + + // Set up the abort source so that if it's triggered, we transition the instance appropriately. + _abortSource.Token.Register(s => + { + var thisRef = (ManagedWebSocket)s; + + lock (thisRef.StateUpdateLock) + { + WebSocketState state = thisRef._state; + if (state != WebSocketState.Closed && state != WebSocketState.Aborted) + { + thisRef._state = state != WebSocketState.None && state != WebSocketState.Connecting ? + WebSocketState.Aborted : + WebSocketState.Closed; + } + } + }, this); + + // Now that we're opened, initiate the keep alive timer to send periodic pings + if (keepAliveInterval > TimeSpan.Zero) + { + _keepAliveTimer = new Timer(s => ((ManagedWebSocket)s).SendKeepAliveFrameAsync(), this, keepAliveInterval, keepAliveInterval); + } + } + + public override void Dispose() + { + lock (StateUpdateLock) + { + DisposeCore(); + } + } + + private void DisposeCore() + { + Debug.Assert(Monitor.IsEntered(StateUpdateLock), $"Expected {nameof(StateUpdateLock)} to be held"); + if (!_disposed) + { + _disposed = true; + _keepAliveTimer?.Dispose(); + _stream?.Dispose(); + if (_state < WebSocketState.Aborted) + { + _state = WebSocketState.Closed; + } + } + } + + public override WebSocketCloseStatus? CloseStatus => _closeStatus; + + public override string CloseStatusDescription => _closeStatusDescription; + + public override WebSocketState State => _state; + + public override string SubProtocol => _subprotocol; + + public override Task SendAsync(ArraySegment buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken) + { + if (messageType != WebSocketMessageType.Text && messageType != WebSocketMessageType.Binary) + { + throw new ArgumentException(SR.Format( + SR.net_WebSockets_Argument_InvalidMessageType, + nameof(WebSocketMessageType.Close), nameof(SendAsync), nameof(WebSocketMessageType.Binary), nameof(WebSocketMessageType.Text), nameof(CloseOutputAsync)), + nameof(messageType)); + } + WebSocketValidate.ValidateArraySegment(buffer, nameof(buffer)); + + try + { + WebSocketValidate.ThrowIfInvalidState(_state, _disposed, s_validSendStates); + ThrowIfOperationInProgress(_lastSendAsync); + } + catch (Exception exc) + { + return CompatHelpers.FromException(exc); + } + + MessageOpcode opcode = + _lastSendWasFragment ? MessageOpcode.Continuation : + messageType == WebSocketMessageType.Binary ? MessageOpcode.Binary : + MessageOpcode.Text; + + Task t = SendFrameAsync(opcode, endOfMessage, buffer, cancellationToken); + _lastSendWasFragment = !endOfMessage; + _lastSendAsync = t; + return t; + } + + public override Task ReceiveAsync(ArraySegment buffer, CancellationToken cancellationToken) + { + WebSocketValidate.ValidateArraySegment(buffer, nameof(buffer)); + + try + { + WebSocketValidate.ThrowIfInvalidState(_state, _disposed, s_validReceiveStates); + + Debug.Assert(!Monitor.IsEntered(StateUpdateLock), $"{nameof(StateUpdateLock)} must never be held when acquiring {nameof(ReceiveAsyncLock)}"); + lock (ReceiveAsyncLock) // synchronize with receives in CloseAsync + { + ThrowIfOperationInProgress(_lastReceiveAsync); + Task t = ReceiveAsyncPrivate(buffer, cancellationToken); + _lastReceiveAsync = t; + return t; + } + } + catch (Exception exc) + { + return CompatHelpers.FromException(exc); + } + } + + public override Task CloseAsync(WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken) + { + WebSocketValidate.ValidateCloseStatus(closeStatus, statusDescription); + + try + { + WebSocketValidate.ThrowIfInvalidState(_state, _disposed, s_validCloseStates); + } + catch (Exception exc) + { + return CompatHelpers.FromException(exc); + } + + return CloseAsyncPrivate(closeStatus, statusDescription, cancellationToken); + } + + public override Task CloseOutputAsync(WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken) + { + WebSocketValidate.ValidateCloseStatus(closeStatus, statusDescription); + + try + { + WebSocketValidate.ThrowIfInvalidState(_state, _disposed, s_validCloseOutputStates); + } + catch (Exception exc) + { + return CompatHelpers.FromException(exc); + } + + return SendCloseFrameAsync(closeStatus, statusDescription, cancellationToken); + } + + public override void Abort() + { + _abortSource.Cancel(); + Dispose(); // forcibly tear down connection + } + + /// Sends a websocket frame to the network. + /// The opcode for the message. + /// The value of the FIN bit for the message. + /// The buffer containing the payload data fro the message. + /// The CancellationToken to use to cancel the websocket. + private Task SendFrameAsync(MessageOpcode opcode, bool endOfMessage, ArraySegment payloadBuffer, CancellationToken cancellationToken) + { + // TODO: #4900 SendFrameAsync should in theory typically complete synchronously, making it fast and allocation free. + // However, due to #4900, it almost always yields, resulting in all of the allocations involved in an async method + // yielding, e.g. the boxed state machine, the Action delegate, the MoveNextRunner, and the resulting Task, plus it's + // common that the awaited operation completes so fast after the await that we may end up allocating an AwaitTaskContinuation + // inside of the TaskAwaiter. Since SendFrameAsync is such a core code path, until that can be fixed, we put some + // optimizations in place to avoid a few of those expenses, at the expense of more complicated code; for the common case, + // this code has fewer than half the number and size of allocations. If/when that issue is fixed, this method should be deleted + // and replaced by SendFrameFallbackAsync, which is the same logic but in a much more easily understand flow. + + // If a cancelable cancellation token was provided, that would require registering with it, which means more state we have to + // pass around (the CancellationTokenRegistration), so if it is cancelable, just immediately go to the fallback path. + // Similarly, it should be rare that there are multiple outstanding calls to SendFrameAsync, but if there are, again + // fall back to the fallback path. + return cancellationToken.CanBeCanceled || !_sendFrameAsyncLock.Wait(0) ? + SendFrameFallbackAsync(opcode, endOfMessage, payloadBuffer, cancellationToken) : + SendFrameLockAcquiredNonCancelableAsync(opcode, endOfMessage, payloadBuffer); + } + + /// Sends a websocket frame to the network. The caller must hold the sending lock. + /// The opcode for the message. + /// The value of the FIN bit for the message. + /// The buffer containing the payload data fro the message. + private Task SendFrameLockAcquiredNonCancelableAsync(MessageOpcode opcode, bool endOfMessage, ArraySegment payloadBuffer) + { + Debug.Assert(_sendFrameAsyncLock.CurrentCount == 0, "Caller should hold the _sendFrameAsyncLock"); + + // If we get here, the cancellation token is not cancelable so we don't have to worry about it, + // and we own the semaphore, so we don't need to asynchronously wait for it. + Task writeTask = null; + bool releaseSemaphore = true; + try + { + // Write the payload synchronously to the buffer, then write that buffer out to the network. + int sendBytes = WriteFrameToSendBuffer(opcode, endOfMessage, payloadBuffer); + writeTask = _stream.WriteAsync(_sendBuffer, 0, sendBytes, CancellationToken.None); + + // If the operation happens to complete synchronously (or, more specifically, by + // the time we get from the previous line to here, release the semaphore, propagate + // exceptions, and we're done. + if (writeTask.IsCompleted) + { + writeTask.GetAwaiter().GetResult(); // propagate any exceptions + return CompatHelpers.CompletedTask; + } + + // Up until this point, if an exception occurred (such as when accessing _stream or when + // calling GetResult), we want to release the semaphore. After this point, the semaphore needs + // to remain held until writeTask completes. + releaseSemaphore = false; + } + catch (Exception exc) + { + return CompatHelpers.FromException(_state == WebSocketState.Aborted ? + CreateOperationCanceledException(exc) : + new WebSocketException(WebSocketError.ConnectionClosedPrematurely, exc)); + } + finally + { + if (releaseSemaphore) + { + _sendFrameAsyncLock.Release(); + } + } + + // The write was not yet completed. Create and return a continuation that will + // release the semaphore and translate any exception that occurred. + return writeTask.ContinueWith((t, s) => + { + var thisRef = (ManagedWebSocket)s; + thisRef._sendFrameAsyncLock.Release(); + + try { t.GetAwaiter().GetResult(); } + catch (Exception exc) + { + throw thisRef._state == WebSocketState.Aborted ? + CreateOperationCanceledException(exc) : + new WebSocketException(WebSocketError.ConnectionClosedPrematurely, exc); + } + }, this, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default); + } + + private async Task SendFrameFallbackAsync(MessageOpcode opcode, bool endOfMessage, ArraySegment payloadBuffer, CancellationToken cancellationToken) + { + await _sendFrameAsyncLock.WaitAsync().ConfigureAwait(false); + try + { + int sendBytes = WriteFrameToSendBuffer(opcode, endOfMessage, payloadBuffer); + using (cancellationToken.Register(s => ((ManagedWebSocket)s).Abort(), this)) + { + await _stream.WriteAsync(_sendBuffer, 0, sendBytes, cancellationToken).ConfigureAwait(false); + } + } + catch (Exception exc) + { + throw _state == WebSocketState.Aborted ? + CreateOperationCanceledException(exc, cancellationToken) : + new WebSocketException(WebSocketError.ConnectionClosedPrematurely, exc); + } + finally + { + _sendFrameAsyncLock.Release(); + } + } + + /// Writes a frame into the send buffer, which can then be sent over the network. + private int WriteFrameToSendBuffer(MessageOpcode opcode, bool endOfMessage, ArraySegment payloadBuffer) + { + // Grow our send buffer as needed. We reuse the buffer for all messages, with it protected by the send frame lock. + EnsureBufferLength(ref _sendBuffer, payloadBuffer.Count + MaxMessageHeaderLength); + + // Write the message header data to the buffer. + int headerLength; + int? maskOffset = null; + if (_isServer) + { + // The server doesn't send a mask, so the mask offset returned by WriteHeader + // is actually the end of the header. + headerLength = WriteHeader(opcode, _sendBuffer, payloadBuffer, endOfMessage, useMask: false); + } + else + { + // We need to know where the mask starts so that we can use the mask to manipulate the payload data, + // and we need to know the total length for sending it on the wire. + maskOffset = WriteHeader(opcode, _sendBuffer, payloadBuffer, endOfMessage, useMask: true); + headerLength = maskOffset.GetValueOrDefault() + MaskLength; + } + + // Write the payload + if (payloadBuffer.Count > 0) + { + Buffer.BlockCopy(payloadBuffer.Array, payloadBuffer.Offset, _sendBuffer, headerLength, payloadBuffer.Count); + + // If we added a mask to the header, XOR the payload with the mask. We do the manipulation in the send buffer so as to avoid + // changing the data in the caller-supplied payload buffer. + if (maskOffset.HasValue) + { + ApplyMask(_sendBuffer, headerLength, _sendBuffer, maskOffset.Value, 0, payloadBuffer.Count); + } + } + + // Return the number of bytes in the send buffer + return headerLength + payloadBuffer.Count; + } + + private void SendKeepAliveFrameAsync() + { + bool acquiredLock = _sendFrameAsyncLock.Wait(0); + if (acquiredLock) + { + // This exists purely to keep the connection alive; don't wait for the result, and ignore any failures. + // The call will handle releasing the lock. + SendFrameLockAcquiredNonCancelableAsync(MessageOpcode.Ping, true, new ArraySegment(CompatHelpers.Empty())); + } + else + { + // If the lock is already held, something is already getting sent, + // so there's no need to send a keep-alive ping. + } + } + + private static int WriteHeader(MessageOpcode opcode, byte[] sendBuffer, ArraySegment payload, bool endOfMessage, bool useMask) + { + // Client header format: + // 1 bit - FIN - 1 if this is the final fragment in the message (it could be the only fragment), otherwise 0 + // 1 bit - RSV1 - Reserved - 0 + // 1 bit - RSV2 - Reserved - 0 + // 1 bit - RSV3 - Reserved - 0 + // 4 bits - Opcode - How to interpret the payload + // - 0x0 - continuation + // - 0x1 - text + // - 0x2 - binary + // - 0x8 - connection close + // - 0x9 - ping + // - 0xA - pong + // - (0x3 to 0x7, 0xB-0xF - reserved) + // 1 bit - Masked - 1 if the payload is masked, 0 if it's not. Must be 1 for the client + // 7 bits, 7+16 bits, or 7+64 bits - Payload length + // - For length 0 through 125, 7 bits storing the length + // - For lengths 126 through 2^16, 7 bits storing the value 126, followed by 16 bits storing the length + // - For lengths 2^16+1 through 2^64, 7 bits storing the value 127, followed by 64 bytes storing the length + // 0 or 4 bytes - Mask, if Masked is 1 - random value XOR'd with each 4 bytes of the payload, round-robin + // Length bytes - Payload data + + Debug.Assert(sendBuffer.Length >= MaxMessageHeaderLength, $"Expected sendBuffer to be at least {MaxMessageHeaderLength}, got {sendBuffer.Length}"); + + sendBuffer[0] = (byte)opcode; // 4 bits for the opcode + if (endOfMessage) + { + sendBuffer[0] |= 0x80; // 1 bit for FIN + } + + // Store the payload length. + int maskOffset; + if (payload.Count <= 125) + { + sendBuffer[1] = (byte)payload.Count; + maskOffset = 2; // no additional payload length + } + else if (payload.Count <= ushort.MaxValue) + { + sendBuffer[1] = 126; + sendBuffer[2] = (byte)(payload.Count / 256); + sendBuffer[3] = (byte)payload.Count; + maskOffset = 2 + sizeof(ushort); // additional 2 bytes for 16-bit length + } + else + { + sendBuffer[1] = 127; + int length = payload.Count; + for (int i = 9; i >= 2; i--) + { + sendBuffer[i] = (byte)length; + length = length / 256; + } + maskOffset = 2 + sizeof(ulong); // additional 8 bytes for 64-bit length + } + + if (useMask) + { + // Generate the mask. + sendBuffer[1] |= 0x80; + WriteRandomMask(sendBuffer, maskOffset); + } + + // Return the position of the mask. + return maskOffset; + } + + /// Writes a 4-byte random mask to the specified buffer at the specified offset. + /// The buffer to which to write the mask. + /// The offset into the buffer at which to write the mask. + private static void WriteRandomMask(byte[] buffer, int offset) + { + byte[] mask = t_headerMask ?? (t_headerMask = new byte[MaskLength]); + Debug.Assert(mask.Length == MaskLength, $"Expected mask of length {MaskLength}, got {mask.Length}"); + s_random.GetBytes(mask); + Buffer.BlockCopy(mask, 0, buffer, offset, MaskLength); + } + + /// + /// Receive the next text, binary, continuation, or close message, returning information about it and + /// writing its payload into the supplied buffer. Other control messages may be consumed and processed + /// as part of this operation, but data about them will not be returned. + /// + /// The buffer into which payload data should be written. + /// The CancellationToken used to cancel the websocket. + /// Information about the received message. + private async Task ReceiveAsyncPrivate(ArraySegment payloadBuffer, CancellationToken cancellationToken) + { + // This is a long method. While splitting it up into pieces would arguably help with readability, doing so would + // also result in more allocations, as each async method that yields ends up with multiple allocations. The impact + // of those allocations is amortized across all of the awaits in the method, and since we generally expect a receive + // operation to require at most a single yield (while waiting for data to arrive), it's more efficient to have + // everything in the one method. We do separate out pieces for handling close and ping/pong messages, as we expect + // those to be much less frequent (e.g. we should only get one close per websocket), and thus we can afford to pay + // a bit more for readability and maintainability. + + CancellationTokenRegistration registration = cancellationToken.Register(s => ((ManagedWebSocket)s).Abort(), this); + try + { + while (true) // in case we get control frames that should be ignored from the user's perspective + { + // Get the last received header. If its payload length is non-zero, that means we previously + // received the header but were only able to read a part of the fragment, so we should skip + // reading another header and just proceed to use that same header and read more data associated + // with it. If instead its payload length is zero, then we've completed the processing of + // thta message, and we should read the next header. + MessageHeader header = _lastReceiveHeader; + if (header.PayloadLength == 0) + { + if (_receiveBufferCount < (_isServer ? (MaxMessageHeaderLength - MaskLength) : MaxMessageHeaderLength)) + { + // Make sure we have the first two bytes, which includes the start of the payload length. + if (_receiveBufferCount < 2) + { + await EnsureBufferContainsAsync(2, cancellationToken, throwOnPrematureClosure: false).ConfigureAwait(false); + if (_receiveBufferCount < 2) + { + // The connection closed; nothing more to read. + return new WebSocketReceiveResult(0, WebSocketMessageType.Text, true); + } + } + + // Then make sure we have the full header based on the payload length. + // If this is the server, we also need room for the received mask. + long payloadLength = _receiveBuffer[_receiveBufferOffset + 1] & 0x7F; + if (_isServer || payloadLength > 125) + { + int minNeeded = + 2 + + (_isServer ? MaskLength : 0) + + (payloadLength <= 125 ? 0 : payloadLength == 126 ? sizeof(ushort) : sizeof(ulong)); // additional 2 or 8 bytes for 16-bit or 64-bit length + await EnsureBufferContainsAsync(minNeeded, cancellationToken).ConfigureAwait(false); + } + } + + if (!TryParseMessageHeaderFromReceiveBuffer(out header)) + { + await CloseWithReceiveErrorAndThrowAsync(WebSocketCloseStatus.ProtocolError, WebSocketError.Faulted, cancellationToken).ConfigureAwait(false); + } + _receivedMaskOffsetOffset = 0; + } + + // If the header represents a ping or a pong, it's a control message meant + // to be transparent to the user, so handle it and then loop around to read again. + // Alternatively, if it's a close message, handle it and exit. + if (header.Opcode == MessageOpcode.Ping || header.Opcode == MessageOpcode.Pong) + { + await HandleReceivedPingPongAsync(header, cancellationToken).ConfigureAwait(false); + continue; + } + else if (header.Opcode == MessageOpcode.Close) + { + return await HandleReceivedCloseAsync(header, cancellationToken).ConfigureAwait(false); + } + + // If this is a continuation, replace the opcode with the one of the message it's continuing + if (header.Opcode == MessageOpcode.Continuation) + { + header.Opcode = _lastReceiveHeader.Opcode; + } + + // The message should now be a binary or text message. Handle it by reading the payload and returning the contents. + Debug.Assert(header.Opcode == MessageOpcode.Binary || header.Opcode == MessageOpcode.Text, $"Unexpected opcode {header.Opcode}"); + + // If there's no data to read, return an appropriate result. + int bytesToRead = (int)Math.Min(payloadBuffer.Count, header.PayloadLength); + if (bytesToRead == 0) + { + _lastReceiveHeader = header; + return new WebSocketReceiveResult( + 0, + header.Opcode == MessageOpcode.Text ? WebSocketMessageType.Text : WebSocketMessageType.Binary, + header.PayloadLength == 0 ? header.Fin : false); + } + + // Otherwise, read as much of the payload as we can efficiently, and upate the header to reflect how much data + // remains for future reads. + + if (_receiveBufferCount == 0) + { + await EnsureBufferContainsAsync(1, cancellationToken, throwOnPrematureClosure: false).ConfigureAwait(false); + } + + int bytesToCopy = Math.Min(bytesToRead, _receiveBufferCount); + if (_isServer) + { + _receivedMaskOffsetOffset = ApplyMask(_receiveBuffer, _receiveBufferOffset, header.Mask, _receivedMaskOffsetOffset, bytesToCopy); + } + Buffer.BlockCopy(_receiveBuffer, _receiveBufferOffset, payloadBuffer.Array, payloadBuffer.Offset, bytesToCopy); + ConsumeFromBuffer(bytesToCopy); + header.PayloadLength -= bytesToCopy; + + // If this a text message, validate that it contains valid UTF8. + if (header.Opcode == MessageOpcode.Text && + !TryValidateUtf8(new ArraySegment(payloadBuffer.Array, payloadBuffer.Offset, bytesToCopy), header.Fin, _utf8TextState)) + { + await CloseWithReceiveErrorAndThrowAsync(WebSocketCloseStatus.InvalidPayloadData, WebSocketError.Faulted, cancellationToken).ConfigureAwait(false); + } + + _lastReceiveHeader = header; + return new WebSocketReceiveResult( + bytesToCopy, + header.Opcode == MessageOpcode.Text ? WebSocketMessageType.Text : WebSocketMessageType.Binary, + bytesToCopy == 0 || (header.Fin && header.PayloadLength == 0)); + } + } + catch (Exception exc) + { + throw _state == WebSocketState.Aborted ? + new WebSocketException(WebSocketError.InvalidState, SR.Format(SR.net_WebSockets_InvalidState_ClosedOrAborted, "System.Net.WebSockets.InternalClientWebSocket", "Aborted"), exc) : + new WebSocketException(WebSocketError.ConnectionClosedPrematurely, exc); + } + finally + { + registration.Dispose(); + } + } + + /// Processes a received close message. + /// The message header. + /// The cancellation token to use to cancel the websocket. + /// The received result message. + private async Task HandleReceivedCloseAsync( + MessageHeader header, CancellationToken cancellationToken) + { + lock (StateUpdateLock) + { + _receivedCloseFrame = true; + if (_state < WebSocketState.CloseReceived) + { + _state = WebSocketState.CloseReceived; + } + } + + WebSocketCloseStatus closeStatus = WebSocketCloseStatus.NormalClosure; + string closeStatusDescription = string.Empty; + + // Handle any payload by parsing it into the close status and description. + if (header.PayloadLength == 1) + { + // The close payload length can be 0 or >= 2, but not 1. + await CloseWithReceiveErrorAndThrowAsync(WebSocketCloseStatus.ProtocolError, WebSocketError.Faulted, cancellationToken).ConfigureAwait(false); + } + else if (header.PayloadLength >= 2) + { + if (_receiveBufferCount < header.PayloadLength) + { + await EnsureBufferContainsAsync((int)header.PayloadLength, cancellationToken).ConfigureAwait(false); + } + + if (_isServer) + { + ApplyMask(_receiveBuffer, _receiveBufferOffset, header.Mask, 0, header.PayloadLength); + } + + closeStatus = (WebSocketCloseStatus)(_receiveBuffer[_receiveBufferOffset] << 8 | _receiveBuffer[_receiveBufferOffset + 1]); + if (!IsValidCloseStatus(closeStatus)) + { + await CloseWithReceiveErrorAndThrowAsync(WebSocketCloseStatus.ProtocolError, WebSocketError.Faulted, cancellationToken).ConfigureAwait(false); + } + + if (header.PayloadLength > 2) + { + try + { + closeStatusDescription = s_textEncoding.GetString(_receiveBuffer, _receiveBufferOffset + 2, (int)header.PayloadLength - 2); + } + catch (DecoderFallbackException exc) + { + await CloseWithReceiveErrorAndThrowAsync(WebSocketCloseStatus.ProtocolError, WebSocketError.Faulted, cancellationToken, exc).ConfigureAwait(false); + } + } + ConsumeFromBuffer((int)header.PayloadLength); + } + + // Store the close status and description onto the instance. + _closeStatus = closeStatus; + _closeStatusDescription = closeStatusDescription; + + // And return them as part of the result message. + return new WebSocketReceiveResult(0, WebSocketMessageType.Close, true, closeStatus, closeStatusDescription); + } + + /// Processes a received ping or pong message. + /// The message header. + /// The cancellation token to use to cancel the websocket. + private async Task HandleReceivedPingPongAsync(MessageHeader header, CancellationToken cancellationToken) + { + // Consume any (optional) payload associated with the ping/pong. + if (header.PayloadLength > 0 && _receiveBufferCount < header.PayloadLength) + { + await EnsureBufferContainsAsync((int)header.PayloadLength, cancellationToken).ConfigureAwait(false); + } + + // If this was a ping, send back a pong response. + if (header.Opcode == MessageOpcode.Ping) + { + if (_isServer) + { + ApplyMask(_receiveBuffer, _receiveBufferOffset, header.Mask, 0, header.PayloadLength); + } + + await SendFrameAsync( + MessageOpcode.Pong, true, + new ArraySegment(_receiveBuffer, _receiveBufferOffset, (int)header.PayloadLength), cancellationToken).ConfigureAwait(false); + } + + // Regardless of whether it was a ping or pong, we no longer need the payload. + if (header.PayloadLength > 0) + { + ConsumeFromBuffer((int)header.PayloadLength); + } + } + + /// Check whether a close status is valid according to the RFC. + /// The status to validate. + /// true if the status if valid; otherwise, false. + private static bool IsValidCloseStatus(WebSocketCloseStatus closeStatus) + { + // 0-999: "not used" + // 1000-2999: reserved for the protocol; we need to check individual codes manually + // 3000-3999: reserved for use by higher-level code + // 4000-4999: reserved for private use + // 5000-: not mentioned in RFC + + if (closeStatus < (WebSocketCloseStatus)1000 || closeStatus >= (WebSocketCloseStatus)5000) + { + return false; + } + + if (closeStatus >= (WebSocketCloseStatus)3000) + { + return true; + } + + switch (closeStatus) // check for the 1000-2999 range known codes + { + case WebSocketCloseStatus.EndpointUnavailable: + case WebSocketCloseStatus.InternalServerError: + case WebSocketCloseStatus.InvalidMessageType: + case WebSocketCloseStatus.InvalidPayloadData: + case WebSocketCloseStatus.MandatoryExtension: + case WebSocketCloseStatus.MessageTooBig: + case WebSocketCloseStatus.NormalClosure: + case WebSocketCloseStatus.PolicyViolation: + case WebSocketCloseStatus.ProtocolError: + return true; + + default: + return false; + } + } + + /// Send a close message to the server and throw an exception, in response to getting bad data from the server. + /// The close status code to use. + /// The error reason. + /// The CancellationToken used to cancel the websocket. + /// An optional inner exception to include in the thrown exception. + private async Task CloseWithReceiveErrorAndThrowAsync( + WebSocketCloseStatus closeStatus, WebSocketError error, CancellationToken cancellationToken, Exception innerException = null) + { + // Close the connection if it hasn't already been closed + if (!_sentCloseFrame) + { + await CloseOutputAsync(closeStatus, string.Empty, cancellationToken).ConfigureAwait(false); + } + + // Dump our receive buffer; we're in a bad state to do any further processing + _receiveBufferCount = 0; + + // Let the caller know we've failed + throw new WebSocketException(error, innerException); + } + + /// Parses a message header from the buffer. This assumes the header is in the buffer. + /// The read header. + /// true if a header was read; false if the header was invalid. + private bool TryParseMessageHeaderFromReceiveBuffer(out MessageHeader resultHeader) + { + Debug.Assert(_receiveBufferCount >= 2, $"Expected to at least have the first two bytes of the header."); + + var header = new MessageHeader(); + + header.Fin = (_receiveBuffer[_receiveBufferOffset] & 0x80) != 0; + bool reservedSet = (_receiveBuffer[_receiveBufferOffset] & 0x70) != 0; + header.Opcode = (MessageOpcode)(_receiveBuffer[_receiveBufferOffset] & 0xF); + + bool masked = (_receiveBuffer[_receiveBufferOffset + 1] & 0x80) != 0; + header.PayloadLength = _receiveBuffer[_receiveBufferOffset + 1] & 0x7F; + + ConsumeFromBuffer(2); + + // Read the remainder of the payload length, if necessary + if (header.PayloadLength == 126) + { + Debug.Assert(_receiveBufferCount >= 2, $"Expected to have two bytes for the payload length."); + header.PayloadLength = (_receiveBuffer[_receiveBufferOffset] << 8) | _receiveBuffer[_receiveBufferOffset + 1]; + ConsumeFromBuffer(2); + } + else if (header.PayloadLength == 127) + { + Debug.Assert(_receiveBufferCount >= 8, $"Expected to have eight bytes for the payload length."); + header.PayloadLength = 0; + for (int i = 0; i < 8; i++) + { + header.PayloadLength = (header.PayloadLength << 8) | _receiveBuffer[_receiveBufferOffset + i]; + } + ConsumeFromBuffer(8); + } + + bool shouldFail = reservedSet; + if (masked) + { + if (!_isServer) + { + shouldFail = true; + } + header.Mask = CombineMaskBytes(_receiveBuffer, _receiveBufferOffset); + + // Consume the mask bytes + ConsumeFromBuffer(4); + } + + // Do basic validation of the header + switch (header.Opcode) + { + case MessageOpcode.Continuation: + if (_lastReceiveHeader.Fin) + { + // Can't continue from a final message + shouldFail = true; + } + break; + + case MessageOpcode.Binary: + case MessageOpcode.Text: + if (!_lastReceiveHeader.Fin) + { + // Must continue from a non-final message + shouldFail = true; + } + break; + + case MessageOpcode.Close: + case MessageOpcode.Ping: + case MessageOpcode.Pong: + if (header.PayloadLength > MaxControlPayloadLength || !header.Fin) + { + // Invalid control messgae + shouldFail = true; + } + break; + + default: + // Unknown opcode + shouldFail = true; + break; + } + + // Return the read header + resultHeader = header; + return !shouldFail; + } + + /// Send a close message, then receive until we get a close response message. + /// The close status to send. + /// The close status description to send. + /// The CancellationToken to use to cancel the websocket. + private async Task CloseAsyncPrivate(WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken) + { + // Send the close message. Skip sending a close frame if we're currently in a CloseSent state, + // for example having just done a CloseOutputAsync. + if (!_sentCloseFrame) + { + await SendCloseFrameAsync(closeStatus, statusDescription, cancellationToken).ConfigureAwait(false); + } + + // We should now either be in a CloseSent case (because we just sent one), or in a CloseReceived state, in case + // there was a concurrent receive that ended up handling an immediate close frame response from the server. + // Of course it could also be Aborted if something happened concurrently to cause things to blow up. + Debug.Assert( + State == WebSocketState.CloseSent || + State == WebSocketState.CloseReceived || + State == WebSocketState.Aborted, + $"Unexpected state {State}."); + + // Wait until we've received a close response + byte[] closeBuffer = new byte[MaxMessageHeaderLength + MaxControlPayloadLength]; + while (!_receivedCloseFrame) + { + Debug.Assert(!Monitor.IsEntered(StateUpdateLock), $"{nameof(StateUpdateLock)} must never be held when acquiring {nameof(ReceiveAsyncLock)}"); + Task receiveTask; + lock (ReceiveAsyncLock) + { + // Now that we're holding the ReceiveAsyncLock, double-check that we've not yet received the close frame. + // It could have been received between our check above and now due to a concurrent receive completing. + if (_receivedCloseFrame) + { + break; + } + + // We've not yet processed a received close frame, which means we need to wait for a received close to complete. + // There may already be one in flight, in which case we want to just wait for that one rather than kicking off + // another (we don't support concurrent receive operations). We need to kick off a new receive if either we've + // never issued a receive or if the last issued receive completed for reasons other than a close frame. There is + // a race condition here, e.g. if there's a in-flight receive that completes after we check, but that's fine: worst + // case is we then await it, find that it's not what we need, and try again. + receiveTask = _lastReceiveAsync; + if (receiveTask == null || + (receiveTask.Status == TaskStatus.RanToCompletion && receiveTask.Result.MessageType != WebSocketMessageType.Close)) + { + _lastReceiveAsync = receiveTask = ReceiveAsyncPrivate(new ArraySegment(closeBuffer), cancellationToken); + } + } + + // Wait for whatever receive task we have. We'll then loop around again to re-check our state. + Debug.Assert(receiveTask != null); + await receiveTask.ConfigureAwait(false); + } + + // We're closed. Close the connection and update the status. + lock (StateUpdateLock) + { + DisposeCore(); + if (_state < WebSocketState.Closed) + { + _state = WebSocketState.Closed; + } + } + } + + /// Sends a close message to the server. + /// The close status to send. + /// The close status description to send. + /// The CancellationToken to use to cancel the websocket. + private async Task SendCloseFrameAsync(WebSocketCloseStatus closeStatus, string closeStatusDescription, CancellationToken cancellationToken) + { + // Close payload is two bytes containing the close status followed by a UTF8-encoding of the status description, if it exists. + + byte[] buffer; + if (string.IsNullOrEmpty(closeStatusDescription)) + { + buffer = new byte[2]; + } + else + { + buffer = new byte[2 + s_textEncoding.GetByteCount(closeStatusDescription)]; + int encodedLength = s_textEncoding.GetBytes(closeStatusDescription, 0, closeStatusDescription.Length, buffer, 2); + Debug.Assert(buffer.Length - 2 == encodedLength, $"GetByteCount and GetBytes encoded count didn't match"); + } + + ushort closeStatusValue = (ushort)closeStatus; + buffer[0] = (byte)(closeStatusValue >> 8); + buffer[1] = (byte)(closeStatusValue & 0xFF); + + await SendFrameAsync(MessageOpcode.Close, true, new ArraySegment(buffer), cancellationToken).ConfigureAwait(false); + + lock (StateUpdateLock) + { + _sentCloseFrame = true; + if (_state <= WebSocketState.CloseReceived) + { + _state = WebSocketState.CloseSent; + } + } + } + + private void ConsumeFromBuffer(int count) + { + Debug.Assert(count >= 0, $"Expected non-negative count, got {count}"); + Debug.Assert(count <= _receiveBufferCount, $"Trying to consume {count}, which is more than exists {_receiveBufferCount}"); + _receiveBufferCount -= count; + _receiveBufferOffset += count; + } + + private async Task EnsureBufferContainsAsync(int minimumRequiredBytes, CancellationToken cancellationToken, bool throwOnPrematureClosure = true) + { + Debug.Assert(minimumRequiredBytes <= _receiveBuffer.Length, $"Requested number of bytes {minimumRequiredBytes} must not exceed {_receiveBuffer.Length}"); + + // If we don't have enough data in the buffer to satisfy the minimum required, read some more. + if (_receiveBufferCount < minimumRequiredBytes) + { + // If there's any data in the buffer, shift it down. + if (_receiveBufferCount > 0) + { + Buffer.BlockCopy(_receiveBuffer, _receiveBufferOffset, _receiveBuffer, 0, _receiveBufferCount); + } + _receiveBufferOffset = 0; + + // While we don't have enough data, read more. + while (_receiveBufferCount < minimumRequiredBytes) + { + int numRead = await _stream.ReadAsync(_receiveBuffer, _receiveBufferCount, _receiveBuffer.Length - _receiveBufferCount, cancellationToken).ConfigureAwait(false); + Debug.Assert(numRead >= 0, $"Expected non-negative bytes read, got {numRead}"); + _receiveBufferCount += numRead; + if (numRead == 0) + { + // The connection closed before we were able to read everything we needed. + // If it was due to use being disposed, fail. If it was due to the connection + // being closed and it wasn't expected, fail. If it was due to the connection + // being closed and that was expected, exit gracefully. + if (_disposed) + { + throw new ObjectDisposedException("ClientWebSocket"); + } + else if (throwOnPrematureClosure) + { + throw new WebSocketException(WebSocketError.ConnectionClosedPrematurely); + } + break; + } + } + } + } + + /// + /// Grows the specified buffer if it's not at least the specified minimum length. + /// Data is not copied if the buffer is grown. + /// + private static void EnsureBufferLength(ref byte[] buffer, int minLength) + { + if (buffer == null || buffer.Length < minLength) + { + buffer = new byte[minLength]; + } + } + + private static unsafe int CombineMaskBytes(byte[] buffer, int maskOffset) => + BitConverter.ToInt32(buffer, maskOffset); + + /// Applies a mask to a portion of a byte array. + /// The buffer to which the mask should be applied. + /// The offset into at which the mask should start to be applied. + /// The array containing the mask to apply. + /// The offset into of the mask to apply of length . + /// The next position offset from of which by to apply next from the mask. + /// The number of bytes starting from to which the mask should be applied. + /// The updated maskOffsetOffset value. + private static int ApplyMask(byte[] toMask, int toMaskOffset, byte[] mask, int maskOffset, int maskOffsetIndex, long count) + { + Debug.Assert(maskOffsetIndex < MaskLength, $"Unexpected {nameof(maskOffsetIndex)}: {maskOffsetIndex}"); + Debug.Assert(mask.Length >= MaskLength + maskOffset, $"Unexpected inputs: {mask.Length}, {maskOffset}"); + return ApplyMask(toMask, toMaskOffset, CombineMaskBytes(mask, maskOffset), maskOffsetIndex, count); + } + + /// Applies a mask to a portion of a byte array. + /// The buffer to which the mask should be applied. + /// The offset into at which the mask should start to be applied. + /// The four-byte mask, stored as an Int32. + /// The index into the mas + /// The number of bytes to mask. + /// + private static unsafe int ApplyMask(byte[] toMask, int toMaskOffset, int mask, int maskIndex, long count) + { + Debug.Assert(toMaskOffset <= toMask.Length - count, $"Unexpected inputs: {toMaskOffset}, {toMask.Length}, {count}"); + Debug.Assert(maskIndex < sizeof(int), $"Unexpected {nameof(maskIndex)}: {maskIndex}"); + + byte* maskPtr = (byte*)&mask; + fixed (byte* toMaskPtr = toMask) + { + byte* p = toMaskPtr + toMaskOffset; + byte* end = p + count; + while (p < end) + { + *p++ ^= maskPtr[maskIndex]; + maskIndex = (maskIndex + 1) & 3; // & 3 == faster % MaskLength + } + return maskIndex; + } + } + + /// Aborts the websocket and throws an exception if an existing operation is in progress. + private void ThrowIfOperationInProgress(Task operationTask, [CallerMemberName] string methodName = null) + { + if (operationTask != null && !operationTask.IsCompleted) + { + Abort(); + throw new InvalidOperationException(SR.Format(SR.net_Websockets_AlreadyOneOutstandingOperation, methodName)); + } + } + + /// Creates an OperationCanceledException instance, using a default message and the specified inner exception and token. + private static Exception CreateOperationCanceledException(Exception innerException, CancellationToken cancellationToken = default(CancellationToken)) + { + return new OperationCanceledException( + new OperationCanceledException().Message, + innerException, + cancellationToken); + } + + // From https://raw.githubusercontent.com/aspnet/WebSockets/dev/src/Microsoft.AspNetCore.WebSockets.Protocol/Utilities.cs + // Performs a stateful validation of UTF-8 bytes. + // It checks for valid formatting, overlong encodings, surrogates, and value ranges. + private static bool TryValidateUtf8(ArraySegment arraySegment, bool endOfMessage, Utf8MessageState state) + { + for (int i = arraySegment.Offset; i < arraySegment.Offset + arraySegment.Count;) + { + // Have we started a character sequence yet? + if (!state.SequenceInProgress) + { + // The first byte tells us how many bytes are in the sequence. + state.SequenceInProgress = true; + byte b = arraySegment.Array[i]; + i++; + if ((b & 0x80) == 0) // 0bbbbbbb, single byte + { + state.AdditionalBytesExpected = 0; + state.CurrentDecodeBits = b & 0x7F; + state.ExpectedValueMin = 0; + } + else if ((b & 0xC0) == 0x80) + { + // Misplaced 10bbbbbb continuation byte. This cannot be the first byte. + return false; + } + else if ((b & 0xE0) == 0xC0) // 110bbbbb 10bbbbbb + { + state.AdditionalBytesExpected = 1; + state.CurrentDecodeBits = b & 0x1F; + state.ExpectedValueMin = 0x80; + } + else if ((b & 0xF0) == 0xE0) // 1110bbbb 10bbbbbb 10bbbbbb + { + state.AdditionalBytesExpected = 2; + state.CurrentDecodeBits = b & 0xF; + state.ExpectedValueMin = 0x800; + } + else if ((b & 0xF8) == 0xF0) // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb + { + state.AdditionalBytesExpected = 3; + state.CurrentDecodeBits = b & 0x7; + state.ExpectedValueMin = 0x10000; + } + else // 111110bb & 1111110b & 11111110 && 11111111 are not valid + { + return false; + } + } + while (state.AdditionalBytesExpected > 0 && i < arraySegment.Offset + arraySegment.Count) + { + byte b = arraySegment.Array[i]; + if ((b & 0xC0) != 0x80) + { + return false; + } + + i++; + state.AdditionalBytesExpected--; + + // Each continuation byte carries 6 bits of data 0x10bbbbbb. + state.CurrentDecodeBits = (state.CurrentDecodeBits << 6) | (b & 0x3F); + + if (state.AdditionalBytesExpected == 1 && state.CurrentDecodeBits >= 0x360 && state.CurrentDecodeBits <= 0x37F) + { + // This is going to end up in the range of 0xD800-0xDFFF UTF-16 surrogates that are not allowed in UTF-8; + return false; + } + if (state.AdditionalBytesExpected == 2 && state.CurrentDecodeBits >= 0x110) + { + // This is going to be out of the upper Unicode bound 0x10FFFF. + return false; + } + } + if (state.AdditionalBytesExpected == 0) + { + state.SequenceInProgress = false; + if (state.CurrentDecodeBits < state.ExpectedValueMin) + { + // Overlong encoding (e.g. using 2 bytes to encode something that only needed 1). + return false; + } + } + } + if (endOfMessage && state.SequenceInProgress) + { + return false; + } + return true; + } + + private sealed class Utf8MessageState + { + internal bool SequenceInProgress; + internal int AdditionalBytesExpected; + internal int ExpectedValueMin; + internal int CurrentDecodeBits; + } + + private enum MessageOpcode : byte + { + Continuation = 0x0, + Text = 0x1, + Binary = 0x2, + Close = 0x8, + Ping = 0x9, + Pong = 0xA + } + + [StructLayout(LayoutKind.Auto)] + private struct MessageHeader + { + internal MessageOpcode Opcode; + internal bool Fin; + internal long PayloadLength; + internal int Mask; + } + } +} diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json index 8acb4508e4..c0ebe738b3 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json @@ -11,14 +11,18 @@ "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", "nowarn": [ - "CS1591" + "CS1591", + "CS1572", + "CS1573" ], - "xmlDoc": true + "xmlDoc": true, + "allowUnsafe": true }, "frameworks": { "net451": {}, "netstandard1.3": { "dependencies": { + "System.Diagnostics.Debug": "4.0.11-*", "System.Diagnostics.Contracts": "4.0.1-*", "System.Globalization": "4.0.11-*", "System.IO": "4.1.0-*", diff --git a/test/AutobahnTestApp/scripts/RunAutobahnTests.ps1 b/test/AutobahnTestApp/scripts/RunAutobahnTests.ps1 index 52f35e492f..d109182eac 100644 --- a/test/AutobahnTestApp/scripts/RunAutobahnTests.ps1 +++ b/test/AutobahnTestApp/scripts/RunAutobahnTests.ps1 @@ -1,7 +1,7 @@ # # RunAutobahnTests.ps1 # -param([Parameter(Mandatory=$true)][string]$ServerUrl, [string[]]$Cases = @("*"), [string]$OutputDir) +param([Parameter(Mandatory=$true)][string]$ServerUrl, [string[]]$Cases = @("*"), [string]$OutputDir, [int]$Iterations = 1) if(!(Get-Command wstest -ErrorAction SilentlyContinue)) { throw "Missing required command 'wstest'. See README.md in Microsoft.AspNetCore.WebSockets.Server.Test project for information on installing Autobahn Test Suite." @@ -12,19 +12,32 @@ if(!$OutputDir) { $OutputDir = Join-Path $OutputDir "autobahnreports" } -$Spec = Convert-Path (Join-Path $PSScriptRoot "autobahn.spec.json") +Write-Host "Launching Autobahn Test Suite ($Iterations iteration(s))..." -$CasesArray = [string]::Join(",", @($Cases | ForEach-Object { "`"$_`"" })) +0..($Iterations-1) | % { + $iteration = $_ -$SpecJson = [IO.File]::ReadAllText($Spec).Replace("OUTPUTDIR", $OutputDir.Replace("\", "\\")).Replace("WEBSOCKETURL", $ServerUrl).Replace("`"CASES`"", $CasesArray) + $Spec = Convert-Path (Join-Path $PSScriptRoot "autobahn.spec.json") -$TempFile = [IO.Path]::GetTempFileName() + $CasesArray = [string]::Join(",", @($Cases | ForEach-Object { "`"$_`"" })) -try { - [IO.File]::WriteAllText($TempFile, $SpecJson) - & wstest -m fuzzingclient -s $TempFile -} finally { - if(Test-Path $TempFile) { - rm $TempFile + $SpecJson = [IO.File]::ReadAllText($Spec).Replace("OUTPUTDIR", $OutputDir.Replace("\", "\\")).Replace("WEBSOCKETURL", $ServerUrl).Replace("`"CASES`"", $CasesArray) + + $TempFile = [IO.Path]::GetTempFileName() + + try { + [IO.File]::WriteAllText($TempFile, $SpecJson) + $wstestOutput = & wstest -m fuzzingclient -s $TempFile + } finally { + if(Test-Path $TempFile) { + rm $TempFile + } + } + + $report = ConvertFrom-Json ([IO.File]::ReadAllText((Convert-Path (Join-Path $OutputDir "index.json")))) + + $report.Server | gm | ? { $_.MemberType -eq "NoteProperty" } | % { + $case = $report.Server."$($_.Name)" + Write-Host "[#$($iteration.ToString().PadRight(2))] [$($case.behavior.PadRight(6))] Case $($_.Name)" } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Client.Test/WebSocketClientTests.cs b/test/Microsoft.AspNetCore.WebSockets.Client.Test/WebSocketClientTests.cs index fe3e0d6852..1b742cd8e8 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Client.Test/WebSocketClientTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Client.Test/WebSocketClientTests.cs @@ -290,9 +290,11 @@ namespace Microsoft.AspNetCore.WebSockets.Client.Test } } - [ConditionalFact] + [ConditionalTheory] + [InlineData(1024 * 16)] + [InlineData(0xFFFFFF)] [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - public async Task ReceiveLongDataInSmallBuffer_Success() + public async Task ReceiveLongData(int receiveBufferSize) { var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); using (var server = KestrelWebSocketHelpers.CreateServer(async context => @@ -303,7 +305,7 @@ namespace Microsoft.AspNetCore.WebSockets.Client.Test await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); })) { - var client = new WebSocketClient(); + var client = new WebSocketClient() { ReceiveBufferSize = receiveBufferSize }; using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) { var clientBuffer = new byte[orriginalData.Length]; @@ -324,32 +326,6 @@ namespace Microsoft.AspNetCore.WebSockets.Client.Test } } - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - public async Task ReceiveLongDataInLargeBuffer_Success() - { - var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); - using (var server = KestrelWebSocketHelpers.CreateServer(async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - })) - { - var client = new WebSocketClient() { ReceiveBufferSize = 0xFFFFFF }; - using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) - { - var clientBuffer = new byte[orriginalData.Length]; - var result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(orriginalData.Length, result.Count); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - Assert.Equal(orriginalData, clientBuffer); - } - } - } - [ConditionalFact] [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ReceiveFragmentedData_Success() diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/BufferStream.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/BufferStream.cs index 2e900c2a5e..0d8454162f 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/BufferStream.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/BufferStream.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. +// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. using System; using System.Collections.Concurrent; @@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.WebSockets.Protocol.Test private SemaphoreSlim _readLock; private SemaphoreSlim _writeLock; private TaskCompletionSource _readWaitingForData; - + internal BufferStream() { _readLock = new SemaphoreSlim(1, 1); diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexStream.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexStream.cs index 0355fa44aa..9d0c40bfc2 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexStream.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexStream.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. +// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. using System; using System.IO; @@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.WebSockets.Protocol.Test public DuplexStream() : this (new BufferStream(), new BufferStream()) - { + { } public DuplexStream(Stream readStream, Stream writeStream) diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexTests.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexTests.cs deleted file mode 100644 index c0fe5dc66c..0000000000 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexTests.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Net.WebSockets; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Xunit; - -namespace Microsoft.AspNetCore.WebSockets.Protocol.Test -{ - public class DuplexTests - { - [Fact] - public async Task SendAndReceive() - { - DuplexStream serverStream = new DuplexStream(); - DuplexStream clientStream = serverStream.CreateReverseDuplexStream(); - - WebSocket serverWebSocket = CommonWebSocket.CreateServerWebSocket(serverStream, null, TimeSpan.FromMinutes(2), 1024); - WebSocket clientWebSocket = CommonWebSocket.CreateClientWebSocket(clientStream, null, TimeSpan.FromMinutes(2), 1024, false); - - byte[] clientBuffer = Encoding.ASCII.GetBytes("abcdefghijklmnopqrstuvwxyz"); - byte[] serverBuffer = new byte[clientBuffer.Length]; - - await clientWebSocket.SendAsync(new ArraySegment(clientBuffer), WebSocketMessageType.Text, true, CancellationToken.None); - WebSocketReceiveResult serverResult = await serverWebSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(serverResult.EndOfMessage); - Assert.Equal(clientBuffer.Length, serverResult.Count); - Assert.Equal(WebSocketMessageType.Text, serverResult.MessageType); - Assert.Equal(clientBuffer, serverBuffer); - } - - [Fact] - // Tests server unmasking with offset masks - public async Task ServerReceiveOffsetData() - { - DuplexStream serverStream = new DuplexStream(); - DuplexStream clientStream = serverStream.CreateReverseDuplexStream(); - - WebSocket serverWebSocket = CommonWebSocket.CreateServerWebSocket(serverStream, null, TimeSpan.FromMinutes(2), 1024); - WebSocket clientWebSocket = CommonWebSocket.CreateClientWebSocket(clientStream, null, TimeSpan.FromMinutes(2), 1024, false); - - byte[] clientBuffer = Encoding.ASCII.GetBytes("abcdefghijklmnopqrstuvwxyz"); - byte[] serverBuffer = new byte[clientBuffer.Length]; - - await clientWebSocket.SendAsync(new ArraySegment(clientBuffer), WebSocketMessageType.Text, true, CancellationToken.None); - WebSocketReceiveResult serverResult = await serverWebSocket.ReceiveAsync(new ArraySegment(serverBuffer, 0, 3), CancellationToken.None); - Assert.False(serverResult.EndOfMessage); - Assert.Equal(3, serverResult.Count); - Assert.Equal(WebSocketMessageType.Text, serverResult.MessageType); - - serverResult = await serverWebSocket.ReceiveAsync(new ArraySegment(serverBuffer, 3, 10), CancellationToken.None); - Assert.False(serverResult.EndOfMessage); - Assert.Equal(10, serverResult.Count); - Assert.Equal(WebSocketMessageType.Text, serverResult.MessageType); - - serverResult = await serverWebSocket.ReceiveAsync(new ArraySegment(serverBuffer, 13, 13), CancellationToken.None); - Assert.True(serverResult.EndOfMessage); - Assert.Equal(13, serverResult.Count); - Assert.Equal(WebSocketMessageType.Text, serverResult.MessageType); - Assert.Equal(clientBuffer, serverBuffer); - } - } -} diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj index 80b9e72b45..bbc4595fcc 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj @@ -4,11 +4,13 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + - 62a07a24-4d06-4dda-b6bf-02d0c9cb7d32 + aaf2dfcf-845e-4410-bbf0-0683ad60dd6a + Microsoft.AspNetCore.WebSockets.Protocol.Test .\obj .\bin\ + v4.6.1 2.0 @@ -16,5 +18,5 @@ - + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.Net.WebSockets.Test.csproj b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.Net.WebSockets.Test.csproj deleted file mode 100644 index 70cae1a0ff..0000000000 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.Net.WebSockets.Test.csproj +++ /dev/null @@ -1,69 +0,0 @@ - - - - - Debug - AnyCPU - {EF1FE910-6E0C-4DE8-8CC1-6118B726A59E} - Library - Properties - Microsoft.Net.WebSockets.Test - Microsoft.Net.WebSockets.Test - v4.5 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - ..\..\packages\xunit.1.9.2\lib\net20\xunit.dll - - - ..\..\packages\xunit.extensions.1.9.2\lib\net20\xunit.extensions.dll - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Properties/AssemblyInfo.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Properties/AssemblyInfo.cs index f30741c6b2..e1fe33792e 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Properties/AssemblyInfo.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Properties/AssemblyInfo.cs @@ -2,35 +2,18 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("Microsoft.Net.WebSockets.Test")] -[assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Microsoft.Net.WebSockets.Test")] -[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyProduct("Microsoft.AspNetCore.WebSockets.Protocol.Test")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("237d6e8f-6e5e-4c3f-96b4-b19cf3bf4d80")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: Guid("aaf2dfcf-845e-4410-bbf0-0683ad60dd6a")] diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/SendReceiveTests.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/SendReceiveTests.cs new file mode 100644 index 0000000000..109c4b821a --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/SendReceiveTests.cs @@ -0,0 +1,77 @@ +using System; +using System.Linq; +using System.Net.WebSockets; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Microsoft.AspNetCore.WebSockets.Protocol.Test +{ + public class SendReceiveTests + { + [Fact] + public async Task ClientToServerTextMessage() + { + const string message = "Hello, World!"; + + var pair = WebSocketPair.Create(); + var sendBuffer = Encoding.UTF8.GetBytes(message); + + await pair.ClientSocket.SendAsync(new ArraySegment(sendBuffer), WebSocketMessageType.Text, endOfMessage: true, cancellationToken: CancellationToken.None); + + var receiveBuffer = new byte[32]; + var result = await pair.ServerSocket.ReceiveAsync(new ArraySegment(receiveBuffer), CancellationToken.None); + + Assert.Equal(WebSocketMessageType.Text, result.MessageType); + Assert.Equal(message, Encoding.UTF8.GetString(receiveBuffer, 0, result.Count)); + } + + [Fact] + public async Task ServerToClientTextMessage() + { + const string message = "Hello, World!"; + + var pair = WebSocketPair.Create(); + var sendBuffer = Encoding.UTF8.GetBytes(message); + + await pair.ServerSocket.SendAsync(new ArraySegment(sendBuffer), WebSocketMessageType.Text, endOfMessage: true, cancellationToken: CancellationToken.None); + + var receiveBuffer = new byte[32]; + var result = await pair.ClientSocket.ReceiveAsync(new ArraySegment(receiveBuffer), CancellationToken.None); + + Assert.Equal(WebSocketMessageType.Text, result.MessageType); + Assert.Equal(message, Encoding.UTF8.GetString(receiveBuffer, 0, result.Count)); + } + + [Fact] + public async Task ClientToServerBinaryMessage() + { + var pair = WebSocketPair.Create(); + var sendBuffer = new byte[] { 0xde, 0xad, 0xbe, 0xef }; + + await pair.ClientSocket.SendAsync(new ArraySegment(sendBuffer), WebSocketMessageType.Binary, endOfMessage: true, cancellationToken: CancellationToken.None); + + var receiveBuffer = new byte[32]; + var result = await pair.ServerSocket.ReceiveAsync(new ArraySegment(receiveBuffer), CancellationToken.None); + + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(sendBuffer, receiveBuffer.Take(result.Count).ToArray()); + } + + [Fact] + public async Task ServerToClientBinaryMessage() + { + var pair = WebSocketPair.Create(); + var sendBuffer = new byte[] { 0xde, 0xad, 0xbe, 0xef }; + + await pair.ServerSocket.SendAsync(new ArraySegment(sendBuffer), WebSocketMessageType.Binary, endOfMessage: true, cancellationToken: CancellationToken.None); + + var receiveBuffer = new byte[32]; + var result = await pair.ClientSocket.ReceiveAsync(new ArraySegment(receiveBuffer), CancellationToken.None); + + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(sendBuffer, receiveBuffer.Take(result.Count).ToArray()); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Utf8ValidationTests.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Utf8ValidationTests.cs deleted file mode 100644 index 10641f0dbd..0000000000 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Utf8ValidationTests.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Text; -using Xunit; - -namespace Microsoft.AspNetCore.WebSockets.Protocol.Test -{ - public class Utf8ValidationTests - { - [Theory] - [InlineData(new byte[] { })] - [InlineData(new byte[] { 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64 })] // Hello World - [InlineData(new byte[] { 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x2D, 0xC2, 0xB5, 0x40, 0xC3, 0x9F, 0xC3, 0xB6, 0xC3, 0xA4, 0xC3, 0xBC, 0xC3, 0xA0, 0xC3, 0xA1 })] // "Hello-µ@ßöäüàá"; - // [InlineData(new byte[] { 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0xf0, 0xa4, 0xad, 0xa2, 0x77, 0x6f, 0x72, 0x6c, 0x64 })] // "hello\U00024b62world" - [InlineData(new byte[] { 0xf0, 0xa4, 0xad, 0xa2 })] // "\U00024b62" - public void ValidateSingleValidSegments_Valid(byte[] data) - { - var state = new Utilities.Utf8MessageState(); - Assert.True(Utilities.TryValidateUtf8(new ArraySegment(data), endOfMessage: true, state: state)); - } - - [Theory] - [InlineData(new byte[] { }, new byte[] { }, new byte[] { })] - [InlineData(new byte[] { 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20 }, new byte[] { }, new byte[] { 0x57, 0x6F, 0x72, 0x6C, 0x64 })] // Hello ,, World - [InlineData(new byte[] { 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x2D, 0xC2, }, new byte[] { 0xB5, 0x40, 0xC3, 0x9F, 0xC3, 0xB6, 0xC3, 0xA4, }, new byte[] { 0xC3, 0xBC, 0xC3, 0xA0, 0xC3, 0xA1 })] // "Hello-µ@ßöäüàá"; - public void ValidateMultipleValidSegments_Valid(byte[] data1, byte[] data2, byte[] data3) - { - var state = new Utilities.Utf8MessageState(); - Assert.True(Utilities.TryValidateUtf8(new ArraySegment(data1), endOfMessage: false, state: state)); - Assert.True(Utilities.TryValidateUtf8(new ArraySegment(data2), endOfMessage: false, state: state)); - Assert.True(Utilities.TryValidateUtf8(new ArraySegment(data3), endOfMessage: true, state: state)); - } - - [Theory] - [InlineData(new byte[] { 0xfe })] - [InlineData(new byte[] { 0xff })] - [InlineData(new byte[] { 0xfe, 0xfe, 0xff, 0xff })] - [InlineData(new byte[] { 0xc0, 0xb1 })] // Overlong Ascii - [InlineData(new byte[] { 0xc1, 0xb1 })] // Overlong Ascii - [InlineData(new byte[] { 0xe0, 0x80, 0xaf })] // Overlong - [InlineData(new byte[] { 0xf0, 0x80, 0x80, 0xaf })] // Overlong - [InlineData(new byte[] { 0xf8, 0x80, 0x80, 0x80, 0xaf })] // Overlong - [InlineData(new byte[] { 0xfc, 0x80, 0x80, 0x80, 0x80, 0xaf })] // Overlong - [InlineData(new byte[] { 0xed, 0xa0, 0x80, 0x65, 0x64, 0x69, 0x74, 0x65, 0x64 })] // 0xEDA080 decodes to 0xD800, which is a reserved high surrogate character. - public void ValidateSingleInvalidSegment_Invalid(byte[] data) - { - var state = new Utilities.Utf8MessageState(); - Assert.False(Utilities.TryValidateUtf8(new ArraySegment(data), endOfMessage: true, state: state)); - } - - [Fact] - public void ValidateIndividualInvalidSegments_Invalid() - { - var data = new byte[] { 0xce, 0xba, 0xe1, 0xbd, 0xb9, 0xcf, 0x83, 0xce, 0xbc, 0xce, 0xb5, 0xed, 0xa0, 0x80, 0x65, 0x64, 0x69, 0x74, 0x65, 0x64 }; - var state = new Utilities.Utf8MessageState(); - for (int i = 0; i < 12; i++) - { - Assert.True(Utilities.TryValidateUtf8(new ArraySegment(data, i, 1), endOfMessage: false, state: state), i.ToString()); - } - Assert.False(Utilities.TryValidateUtf8(new ArraySegment(data, 12, 1), endOfMessage: false, state: state), 12.ToString()); - } - - [Fact] - public void ValidateMultipleInvalidSegments_Invalid() - { - var data0 = new byte[] { 0xce, 0xba, 0xe1, 0xbd, 0xb9, 0xcf, 0x83, 0xce, 0xbc, 0xce, 0xb5, 0xf4 }; - var data1 = new byte[] { 0x90 }; - var state = new Utilities.Utf8MessageState(); - Assert.True(Utilities.TryValidateUtf8(new ArraySegment(data0), endOfMessage: false, state: state)); - Assert.False(Utilities.TryValidateUtf8(new ArraySegment(data1), endOfMessage: false, state: state)); - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/UtilitiesTests.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/UtilitiesTests.cs deleted file mode 100644 index 0d69ed89f7..0000000000 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/UtilitiesTests.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Text; -using Xunit; - -namespace Microsoft.AspNetCore.WebSockets.Protocol.Test -{ - public class UtilitiesTests - { - [Fact] - public void MaskDataRoundTrips() - { - byte[] data = Encoding.UTF8.GetBytes("Hello World"); - byte[] orriginal = Encoding.UTF8.GetBytes("Hello World"); - Utilities.MaskInPlace(16843009, new ArraySegment(data)); - Utilities.MaskInPlace(16843009, new ArraySegment(data)); - Assert.Equal(orriginal, data); - } - } -} diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/WebSocketPair.cs b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/WebSocketPair.cs new file mode 100644 index 0000000000..1bf3512468 --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/WebSocketPair.cs @@ -0,0 +1,28 @@ +using System; +using System.Net.WebSockets; + +namespace Microsoft.AspNetCore.WebSockets.Protocol.Test +{ + internal class WebSocketPair + { + public WebSocket ClientSocket { get; } + public WebSocket ServerSocket { get; } + + public WebSocketPair(WebSocket clientSocket, WebSocket serverSocket) + { + ClientSocket = clientSocket; + ServerSocket = serverSocket; + } + + public static WebSocketPair Create() + { + // Create streams + var serverStream = new DuplexStream(); + var clientStream = serverStream.CreateReverseDuplexStream(); + + return new WebSocketPair( + clientSocket: CommonWebSocket.CreateClientWebSocket(clientStream, null, TimeSpan.FromMinutes(2), 1024), + serverSocket: CommonWebSocket.CreateServerWebSocket(serverStream, null, TimeSpan.FromMinutes(2), 1024)); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json index ff14cc11fb..9eb586b89b 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json @@ -1,4 +1,4 @@ -{ +{ "dependencies": { "dotnet-test-xunit": "2.2.0-*", "Microsoft.AspNetCore.WebSockets.Protocol": "0.2.0-*", @@ -13,7 +13,6 @@ "type": "platform" } } - }, - "net451": {} + } } -} \ No newline at end of file +} diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnCaseResult.cs b/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnCaseResult.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnCaseResult.cs rename to test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnCaseResult.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnExpectations.cs b/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnExpectations.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnExpectations.cs rename to test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnExpectations.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnResult.cs b/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnResult.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnResult.cs rename to test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnResult.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnServerResult.cs b/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnServerResult.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnServerResult.cs rename to test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnServerResult.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnSpec.cs b/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnSpec.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnSpec.cs rename to test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnSpec.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnTester.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/AutobahnTester.cs rename to test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnTester.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/Executable.cs b/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/Executable.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/Executable.cs rename to test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/Executable.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/Expectation.cs b/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/Expectation.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/Expectation.cs rename to test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/Expectation.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/ServerSpec.cs b/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/ServerSpec.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/ServerSpec.cs rename to test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/ServerSpec.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/Wstest.cs b/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/Wstest.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Server.Test/Autobahn/Wstest.cs rename to test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/Wstest.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/AutobahnTests.cs similarity index 85% rename from test/Microsoft.AspNetCore.WebSockets.Server.Test/AutobahnTests.cs rename to test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/AutobahnTests.cs index 8e6d3ab191..0a55c8b0d1 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Server.Test/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/AutobahnTests.cs @@ -37,19 +37,22 @@ namespace Microsoft.AspNetCore.WebSockets.Server.Test .IncludeCase("*") .ExcludeCase("9.*", "12.*", "13.*"); - var loggerFactory = new LoggerFactory(); // No logging! It's very loud... + var loggerFactory = new LoggerFactory(); // No logging by default! It's very loud... + + if(string.Equals(Environment.GetEnvironmentVariable("AUTOBAHN_SUITES_LOG"), "1", StringComparison.Ordinal)) + { + loggerFactory.AddConsole(); + } AutobahnResult result; using (var tester = new AutobahnTester(loggerFactory, spec)) { - await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: false, environment: "ManagedSockets", expectationConfig: expect => expect - .NonStrict("6.4.3", "6.4.4")); // https://github.com/aspnet/WebSockets/issues/99 + await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: false, environment: "ManagedSockets"); // Windows-only IIS tests, and Kestrel SSL tests (due to: https://github.com/aspnet/WebSockets/issues/102) if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: true, environment: "ManagedSockets", expectationConfig: expect => expect - .NonStrict("6.4.3", "6.4.4")); // https://github.com/aspnet/WebSockets/issues/99 + await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: true, environment: "ManagedSockets"); if (IsWindows8OrHigher()) { @@ -62,9 +65,7 @@ namespace Microsoft.AspNetCore.WebSockets.Server.Test .OkOrNonStrict("3.2", "3.3", "3.4", "4.1.3", "4.1.4", "4.1.5", "4.2.3", "4.2.4", "4.2.5", "5.15")); // These occasionally get non-strict results } - await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "ManagedSockets", expectationConfig: expect => expect - .Fail("6.1.2", "6.1.3") // https://github.com/aspnet/WebSockets/issues/97 - .NonStrict("6.4.3", "6.4.4")); // https://github.com/aspnet/WebSockets/issues/99 + await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "ManagedSockets"); } } diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Helpers.cs b/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Helpers.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Server.Test/Helpers.cs rename to test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Helpers.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Microsoft.AspNetCore.WebSockets.Server.Test.xproj b/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest.xproj similarity index 73% rename from test/Microsoft.AspNetCore.WebSockets.Server.Test/Microsoft.AspNetCore.WebSockets.Server.Test.xproj rename to test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest.xproj index 11f55fd48c..10e9e7c82d 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Microsoft.AspNetCore.WebSockets.Server.Test.xproj +++ b/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest.xproj @@ -1,12 +1,13 @@  - + - 14.0 + 14.0.25420 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - e82d9f64-8afa-4dcb-a842-2283fda73be8 + a722bb6c-9114-4f25-9bb0-2191d4405f3a + Microsoft.AspNetCore.WebSockets.Server.ConformanceTest .\obj .\bin\ diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/Properties/AssemblyInfo.cs b/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Properties/AssemblyInfo.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Server.Test/Properties/AssemblyInfo.cs rename to test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Properties/AssemblyInfo.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/SkipIfWsTestNotPresentAttribute.cs b/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Server.Test/SkipIfWsTestNotPresentAttribute.cs rename to test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/project.json similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Server.Test/project.json rename to test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/project.json From 33e3e5b1860a1cbae679e80b880a8418b680d558 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Wed, 3 Aug 2016 13:48:52 -0700 Subject: [PATCH 228/453] remove our WebSocket client we'll use the one from dotnet/corefx now instead fixes #108 --- WebSockets.sln | 73 +-- samples/TestServer/Program.cs | 2 +- scripts/UpdateCoreFxCode.ps1 | 10 +- ...crosoft.AspNetCore.WebSockets.Client.xproj | 17 - .../WebSocketClient.cs | 114 ---- .../project.json | 24 - .../Constants.cs | 41 -- ...osoft.AspNetCore.WebSockets.Protocol.xproj | 17 - .../Properties/AssemblyInfo.cs | 17 - .../ext/README.md | 5 - .../project.json | 42 -- ...crosoft.AspNetCore.WebSockets.Server.xproj | 17 - .../Properties/AssemblyInfo.cs | 11 - .../ExtendedWebSocketAcceptContext.cs | 4 +- .../Internal}/Constants.cs | 2 +- .../Internal}/HandshakeHelpers.cs | 34 +- .../Internal/WebSocketFactory.cs} | 4 +- .../Internal/fx}/CompatHelpers.cs | 0 .../Internal/fx/README.md | 5 + .../Internal/fx}/SR.cs | 0 .../Net/WebSockets/WebSocketValidate.cs | 2 + .../System/Net/WebSockets/ManagedWebSocket.cs | 2 + .../Microsoft.AspNetCore.WebSockets.xproj | 13 +- .../Properties/AssemblyInfo.cs | 0 .../WebSocketMiddleware.cs | 6 +- .../WebSocketMiddlewareExtensions.cs | 2 +- .../WebSocketOptions.cs | 0 .../project.json | 9 +- test/AutobahnTestApp/project.json | 2 +- .../WebSocketClientTests.cs | 536 ----------------- .../project.json | 14 - .../Autobahn/AutobahnCaseResult.cs | 2 +- .../Autobahn/AutobahnExpectations.cs | 2 +- .../Autobahn/AutobahnResult.cs | 2 +- .../Autobahn/AutobahnServerResult.cs | 2 +- .../Autobahn/AutobahnSpec.cs | 2 +- .../Autobahn/AutobahnTester.cs | 2 +- .../Autobahn/Executable.cs | 2 +- .../Autobahn/Expectation.cs | 2 +- .../Autobahn/ServerSpec.cs | 2 +- .../Autobahn/Wstest.cs | 2 +- .../AutobahnTests.cs | 4 +- .../Helpers.cs | 2 +- ...pNetCore.WebSockets.ConformanceTest.xproj} | 4 +- .../Properties/AssemblyInfo.cs | 0 .../SkipIfWsTestNotPresentAttribute.cs | 4 +- .../project.json | 0 .../BufferStream.cs | 2 +- .../DuplexStream.cs | 2 +- .../KestrelWebSocketHelpers.cs | 2 +- ...icrosoft.AspNetCore.WebSockets.Test.xproj} | 15 +- .../Properties/AssemblyInfo.cs | 0 .../SendReceiveTests.cs | 2 +- .../WebSocketMiddlewareTests.cs | 541 ++++++++++++++++++ .../WebSocketPair.cs | 7 +- .../project.json | 8 +- 56 files changed, 651 insertions(+), 987 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.WebSockets.Client/Microsoft.AspNetCore.WebSockets.Client.xproj delete mode 100644 src/Microsoft.AspNetCore.WebSockets.Client/WebSocketClient.cs delete mode 100644 src/Microsoft.AspNetCore.WebSockets.Client/project.json delete mode 100644 src/Microsoft.AspNetCore.WebSockets.Protocol/Constants.cs delete mode 100644 src/Microsoft.AspNetCore.WebSockets.Protocol/Microsoft.AspNetCore.WebSockets.Protocol.xproj delete mode 100644 src/Microsoft.AspNetCore.WebSockets.Protocol/Properties/AssemblyInfo.cs delete mode 100644 src/Microsoft.AspNetCore.WebSockets.Protocol/ext/README.md delete mode 100644 src/Microsoft.AspNetCore.WebSockets.Protocol/project.json delete mode 100644 src/Microsoft.AspNetCore.WebSockets.Server/Microsoft.AspNetCore.WebSockets.Server.xproj delete mode 100644 src/Microsoft.AspNetCore.WebSockets.Server/Properties/AssemblyInfo.cs rename src/{Microsoft.AspNetCore.WebSockets.Server => Microsoft.AspNetCore.WebSockets}/ExtendedWebSocketAcceptContext.cs (79%) rename src/{Microsoft.AspNetCore.WebSockets.Client => Microsoft.AspNetCore.WebSockets/Internal}/Constants.cs (94%) rename src/{Microsoft.AspNetCore.WebSockets.Protocol => Microsoft.AspNetCore.WebSockets/Internal}/HandshakeHelpers.cs (84%) rename src/{Microsoft.AspNetCore.WebSockets.Protocol/CommonWebSocket.cs => Microsoft.AspNetCore.WebSockets/Internal/WebSocketFactory.cs} (92%) rename src/{Microsoft.AspNetCore.WebSockets.Protocol => Microsoft.AspNetCore.WebSockets/Internal/fx}/CompatHelpers.cs (100%) create mode 100644 src/Microsoft.AspNetCore.WebSockets/Internal/fx/README.md rename src/{Microsoft.AspNetCore.WebSockets.Protocol => Microsoft.AspNetCore.WebSockets/Internal/fx}/SR.cs (100%) rename src/{Microsoft.AspNetCore.WebSockets.Protocol/ext => Microsoft.AspNetCore.WebSockets/Internal/fx}/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs (98%) rename src/{Microsoft.AspNetCore.WebSockets.Protocol/ext => Microsoft.AspNetCore.WebSockets/Internal/fx}/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ManagedWebSocket.cs (99%) rename test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj => src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.xproj (64%) rename src/{Microsoft.AspNetCore.WebSockets.Client => Microsoft.AspNetCore.WebSockets}/Properties/AssemblyInfo.cs (100%) rename src/{Microsoft.AspNetCore.WebSockets.Server => Microsoft.AspNetCore.WebSockets}/WebSocketMiddleware.cs (95%) rename src/{Microsoft.AspNetCore.WebSockets.Server => Microsoft.AspNetCore.WebSockets}/WebSocketMiddlewareExtensions.cs (95%) rename src/{Microsoft.AspNetCore.WebSockets.Server => Microsoft.AspNetCore.WebSockets}/WebSocketOptions.cs (100%) rename src/{Microsoft.AspNetCore.WebSockets.Server => Microsoft.AspNetCore.WebSockets}/project.json (76%) delete mode 100644 test/Microsoft.AspNetCore.WebSockets.Client.Test/WebSocketClientTests.cs delete mode 100644 test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json rename test/{Microsoft.AspNetCore.WebSockets.Server.ConformanceTest => Microsoft.AspNetCore.WebSockets.ConformanceTest}/Autobahn/AutobahnCaseResult.cs (92%) rename test/{Microsoft.AspNetCore.WebSockets.Server.ConformanceTest => Microsoft.AspNetCore.WebSockets.ConformanceTest}/Autobahn/AutobahnExpectations.cs (98%) rename test/{Microsoft.AspNetCore.WebSockets.Server.ConformanceTest => Microsoft.AspNetCore.WebSockets.ConformanceTest}/Autobahn/AutobahnResult.cs (89%) rename test/{Microsoft.AspNetCore.WebSockets.Server.ConformanceTest => Microsoft.AspNetCore.WebSockets.ConformanceTest}/Autobahn/AutobahnServerResult.cs (94%) rename test/{Microsoft.AspNetCore.WebSockets.Server.ConformanceTest => Microsoft.AspNetCore.WebSockets.ConformanceTest}/Autobahn/AutobahnSpec.cs (96%) rename test/{Microsoft.AspNetCore.WebSockets.Server.ConformanceTest => Microsoft.AspNetCore.WebSockets.ConformanceTest}/Autobahn/AutobahnTester.cs (98%) rename test/{Microsoft.AspNetCore.WebSockets.Server.ConformanceTest => Microsoft.AspNetCore.WebSockets.ConformanceTest}/Autobahn/Executable.cs (95%) rename test/{Microsoft.AspNetCore.WebSockets.Server.ConformanceTest => Microsoft.AspNetCore.WebSockets.ConformanceTest}/Autobahn/Expectation.cs (64%) rename test/{Microsoft.AspNetCore.WebSockets.Server.ConformanceTest => Microsoft.AspNetCore.WebSockets.ConformanceTest}/Autobahn/ServerSpec.cs (88%) rename test/{Microsoft.AspNetCore.WebSockets.Server.ConformanceTest => Microsoft.AspNetCore.WebSockets.ConformanceTest}/Autobahn/Wstest.cs (88%) rename test/{Microsoft.AspNetCore.WebSockets.Server.ConformanceTest => Microsoft.AspNetCore.WebSockets.ConformanceTest}/AutobahnTests.cs (97%) rename test/{Microsoft.AspNetCore.WebSockets.Server.ConformanceTest => Microsoft.AspNetCore.WebSockets.ConformanceTest}/Helpers.cs (94%) rename test/{Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest.xproj => Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.xproj} (86%) rename test/{Microsoft.AspNetCore.WebSockets.Server.ConformanceTest => Microsoft.AspNetCore.WebSockets.ConformanceTest}/Properties/AssemblyInfo.cs (100%) rename test/{Microsoft.AspNetCore.WebSockets.Server.ConformanceTest => Microsoft.AspNetCore.WebSockets.ConformanceTest}/SkipIfWsTestNotPresentAttribute.cs (75%) rename test/{Microsoft.AspNetCore.WebSockets.Server.ConformanceTest => Microsoft.AspNetCore.WebSockets.ConformanceTest}/project.json (100%) rename test/{Microsoft.AspNetCore.WebSockets.Protocol.Test => Microsoft.AspNetCore.WebSockets.Test}/BufferStream.cs (99%) rename test/{Microsoft.AspNetCore.WebSockets.Protocol.Test => Microsoft.AspNetCore.WebSockets.Test}/DuplexStream.cs (98%) rename test/{Microsoft.AspNetCore.WebSockets.Client.Test => Microsoft.AspNetCore.WebSockets.Test}/KestrelWebSocketHelpers.cs (97%) rename test/{Microsoft.AspNetCore.WebSockets.Client.Test/Microsoft.AspNetCore.WebSockets.Client.Test.xproj => Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.xproj} (54%) rename test/{Microsoft.AspNetCore.WebSockets.Protocol.Test => Microsoft.AspNetCore.WebSockets.Test}/Properties/AssemblyInfo.cs (100%) rename test/{Microsoft.AspNetCore.WebSockets.Protocol.Test => Microsoft.AspNetCore.WebSockets.Test}/SendReceiveTests.cs (98%) create mode 100644 test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs rename test/{Microsoft.AspNetCore.WebSockets.Protocol.Test => Microsoft.AspNetCore.WebSockets.Test}/WebSocketPair.cs (64%) rename test/{Microsoft.AspNetCore.WebSockets.Protocol.Test => Microsoft.AspNetCore.WebSockets.Test}/project.json (57%) diff --git a/WebSockets.sln b/WebSockets.sln index 8c2c5904a1..b755faab40 100644 --- a/WebSockets.sln +++ b/WebSockets.sln @@ -8,21 +8,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{C45106D0-7 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Protocol", "src\Microsoft.AspNetCore.WebSockets.Protocol\Microsoft.AspNetCore.WebSockets.Protocol.xproj", "{E0C10DEC-3339-4A47-85BC-3100C5D34AD4}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Client", "src\Microsoft.AspNetCore.WebSockets.Client\Microsoft.AspNetCore.WebSockets.Client.xproj", "{4A1C4875-AE21-4A78-979A-F0E4DF5EB518}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Client.Test", "test\Microsoft.AspNetCore.WebSockets.Client.Test\Microsoft.AspNetCore.WebSockets.Client.Test.xproj", "{6604D154-817F-4BC5-BE95-FF7E851179D9}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Server", "src\Microsoft.AspNetCore.WebSockets.Server\Microsoft.AspNetCore.WebSockets.Server.xproj", "{78A097D0-C0A4-4AED-93E2-84A65392FB52}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{86E1ADA2-631C-484F-906C-2D0BCF628E65}" ProjectSection(SolutionItems) = preProject global.json = global.json EndProjectSection EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestClient", "samples\TestClient\TestClient.xproj", "{8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestServer", "samples\TestServer\TestServer.csproj", "{4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AutobahnTestApp", "test\AutobahnTestApp\AutobahnTestApp.xproj", "{9755F612-A155-4BDD-9E20-37ADE0B4B3BA}" @@ -36,9 +26,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{1959 scripts\UpdateCoreFxCode.ps1 = scripts\UpdateCoreFxCode.ps1 EndProjectSection EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Server.ConformanceTest", "test\Microsoft.AspNetCore.WebSockets.Server.ConformanceTest\Microsoft.AspNetCore.WebSockets.Server.ConformanceTest.xproj", "{A722BB6C-9114-4F25-9BB0-2191D4405F3A}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets", "src\Microsoft.AspNetCore.WebSockets\Microsoft.AspNetCore.WebSockets.xproj", "{CDE16880-0374-46FA-8896-99F1B90B4B6F}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Protocol.Test", "test\Microsoft.AspNetCore.WebSockets.Protocol.Test\Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj", "{AAF2DFCF-845E-4410-BBF0-0683AD60DD6A}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Test", "test\Microsoft.AspNetCore.WebSockets.Test\Microsoft.AspNetCore.WebSockets.Test.xproj", "{5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.ConformanceTest", "test\Microsoft.AspNetCore.WebSockets.ConformanceTest\Microsoft.AspNetCore.WebSockets.ConformanceTest.xproj", "{74F45408-1959-4FEE-9511-25D40F4913FD}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestClient", "samples\TestClient\TestClient.xproj", "{8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -46,26 +40,6 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E0C10DEC-3339-4A47-85BC-3100C5D34AD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E0C10DEC-3339-4A47-85BC-3100C5D34AD4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E0C10DEC-3339-4A47-85BC-3100C5D34AD4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E0C10DEC-3339-4A47-85BC-3100C5D34AD4}.Release|Any CPU.Build.0 = Release|Any CPU - {4A1C4875-AE21-4A78-979A-F0E4DF5EB518}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4A1C4875-AE21-4A78-979A-F0E4DF5EB518}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4A1C4875-AE21-4A78-979A-F0E4DF5EB518}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4A1C4875-AE21-4A78-979A-F0E4DF5EB518}.Release|Any CPU.Build.0 = Release|Any CPU - {6604D154-817F-4BC5-BE95-FF7E851179D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6604D154-817F-4BC5-BE95-FF7E851179D9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6604D154-817F-4BC5-BE95-FF7E851179D9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6604D154-817F-4BC5-BE95-FF7E851179D9}.Release|Any CPU.Build.0 = Release|Any CPU - {78A097D0-C0A4-4AED-93E2-84A65392FB52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {78A097D0-C0A4-4AED-93E2-84A65392FB52}.Debug|Any CPU.Build.0 = Debug|Any CPU - {78A097D0-C0A4-4AED-93E2-84A65392FB52}.Release|Any CPU.ActiveCfg = Release|Any CPU - {78A097D0-C0A4-4AED-93E2-84A65392FB52}.Release|Any CPU.Build.0 = Release|Any CPU - {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Release|Any CPU.Build.0 = Release|Any CPU {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Debug|Any CPU.Build.0 = Debug|Any CPU {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -82,29 +56,34 @@ Global {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Debug|Any CPU.Build.0 = Debug|Any CPU {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Release|Any CPU.ActiveCfg = Release|Any CPU {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Release|Any CPU.Build.0 = Release|Any CPU - {A722BB6C-9114-4F25-9BB0-2191D4405F3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A722BB6C-9114-4F25-9BB0-2191D4405F3A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A722BB6C-9114-4F25-9BB0-2191D4405F3A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A722BB6C-9114-4F25-9BB0-2191D4405F3A}.Release|Any CPU.Build.0 = Release|Any CPU - {AAF2DFCF-845E-4410-BBF0-0683AD60DD6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AAF2DFCF-845E-4410-BBF0-0683AD60DD6A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AAF2DFCF-845E-4410-BBF0-0683AD60DD6A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AAF2DFCF-845E-4410-BBF0-0683AD60DD6A}.Release|Any CPU.Build.0 = Release|Any CPU + {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Release|Any CPU.Build.0 = Release|Any CPU + {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Release|Any CPU.Build.0 = Release|Any CPU + {74F45408-1959-4FEE-9511-25D40F4913FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {74F45408-1959-4FEE-9511-25D40F4913FD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {74F45408-1959-4FEE-9511-25D40F4913FD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {74F45408-1959-4FEE-9511-25D40F4913FD}.Release|Any CPU.Build.0 = Release|Any CPU + {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {E0C10DEC-3339-4A47-85BC-3100C5D34AD4} = {2C7947A5-9FBD-4267-97C1-2D726D7B3BAF} - {4A1C4875-AE21-4A78-979A-F0E4DF5EB518} = {2C7947A5-9FBD-4267-97C1-2D726D7B3BAF} - {6604D154-817F-4BC5-BE95-FF7E851179D9} = {C45106D0-76C8-4776-A140-F7DD83CA2958} - {78A097D0-C0A4-4AED-93E2-84A65392FB52} = {2C7947A5-9FBD-4267-97C1-2D726D7B3BAF} - {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} {9755F612-A155-4BDD-9E20-37ADE0B4B3BA} = {C45106D0-76C8-4776-A140-F7DD83CA2958} {72E3AB32-682F-42AF-B7C7-0B777244FF11} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} {B7246F23-6A4B-492F-AB61-292AA1A9E9D5} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} - {A722BB6C-9114-4F25-9BB0-2191D4405F3A} = {C45106D0-76C8-4776-A140-F7DD83CA2958} - {AAF2DFCF-845E-4410-BBF0-0683AD60DD6A} = {C45106D0-76C8-4776-A140-F7DD83CA2958} + {CDE16880-0374-46FA-8896-99F1B90B4B6F} = {2C7947A5-9FBD-4267-97C1-2D726D7B3BAF} + {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF} = {C45106D0-76C8-4776-A140-F7DD83CA2958} + {74F45408-1959-4FEE-9511-25D40F4913FD} = {C45106D0-76C8-4776-A140-F7DD83CA2958} + {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} EndGlobalSection EndGlobal diff --git a/samples/TestServer/Program.cs b/samples/TestServer/Program.cs index b365247e40..68e62bfdf6 100644 --- a/samples/TestServer/Program.cs +++ b/samples/TestServer/Program.cs @@ -41,7 +41,7 @@ namespace TestServer while (received.MessageType != WebSocketMessageType.Close) { - // Console.WriteLine("Echo, " + received.Count + ", " + received.MessageType + ", " + received.EndOfMessage); + Console.WriteLine($"Echoing {received.Count} bytes received in a {received.MessageType} message; Fin={received.EndOfMessage}"); // Echo anything we receive await webSocket.SendAsync(new ArraySegment(buffer, 0, received.Count), received.MessageType, received.EndOfMessage, CancellationToken.None); diff --git a/scripts/UpdateCoreFxCode.ps1 b/scripts/UpdateCoreFxCode.ps1 index bc1d772500..c6e2be846a 100644 --- a/scripts/UpdateCoreFxCode.ps1 +++ b/scripts/UpdateCoreFxCode.ps1 @@ -16,7 +16,7 @@ if(!(Test-Path $CoreFxRepoRoot)) { } $CoreFxRepoRoot = Convert-Path $CoreFxRepoRoot -$DestinationRoot = "$RepoRoot\src\Microsoft.AspNetCore.WebSockets.Protocol\ext" +$DestinationRoot = "$RepoRoot\src\Microsoft.AspNetCore.WebSockets\Internal\fx" $FilesToCopy | foreach { $Source = Join-Path $CoreFxRepoRoot $_ @@ -34,7 +34,15 @@ $FilesToCopy | foreach { } Write-Host "Copying $_" + # The trailing blank line is important! + $Pragmas = @" +#pragma warning disable 1572 +#pragma warning disable 1573 + +"@; + $SourceCode = [IO.File]::ReadAllText($Source) + $SourceCode = $Pragmas + $SourceCode $SourceCode = $SourceCode.Replace("Task.FromException", "CompatHelpers.FromException") $SourceCode = $SourceCode.Replace("Task.CompletedTask", "CompatHelpers.CompletedTask") $SourceCode = $SourceCode.Replace("Array.Empty", "CompatHelpers.Empty") diff --git a/src/Microsoft.AspNetCore.WebSockets.Client/Microsoft.AspNetCore.WebSockets.Client.xproj b/src/Microsoft.AspNetCore.WebSockets.Client/Microsoft.AspNetCore.WebSockets.Client.xproj deleted file mode 100644 index ad1997b9e5..0000000000 --- a/src/Microsoft.AspNetCore.WebSockets.Client/Microsoft.AspNetCore.WebSockets.Client.xproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 4a1c4875-ae21-4a78-979a-f0e4df5eb518 - .\obj - .\bin\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets.Client/WebSocketClient.cs b/src/Microsoft.AspNetCore.WebSockets.Client/WebSocketClient.cs deleted file mode 100644 index 7445a80873..0000000000 --- a/src/Microsoft.AspNetCore.WebSockets.Client/WebSocketClient.cs +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Net.WebSockets; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.AspNetCore.WebSockets.Protocol; - -namespace Microsoft.AspNetCore.WebSockets.Client -{ - public class WebSocketClient - { - static WebSocketClient() - { - try - { - // Only call once - WebSocket.RegisterPrefixes(); - } - catch (Exception) - { - // Already registered - } - } - - public WebSocketClient() - { - ReceiveBufferSize = 1024 * 16; - KeepAliveInterval = TimeSpan.FromMinutes(2); - SubProtocols = new List(); - } - - public IList SubProtocols - { - get; - private set; - } - - public TimeSpan KeepAliveInterval - { - get; - set; - } - - public int ReceiveBufferSize - { - get; - set; - } - - public Action ConfigureRequest - { - get; - set; - } - - public Action InspectResponse - { - get; - set; - } - - public async Task ConnectAsync(Uri uri, CancellationToken cancellationToken) - { - HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); - - CancellationTokenRegistration cancellation = cancellationToken.Register(() => request.Abort()); - - request.Headers[Constants.Headers.SecWebSocketVersion] = Constants.Headers.SupportedVersion; - if (SubProtocols.Count > 0) - { - request.Headers[Constants.Headers.SecWebSocketProtocol] = string.Join(", ", SubProtocols); - } - - if (ConfigureRequest != null) - { - ConfigureRequest(request); - } - - HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync(); - - cancellation.Dispose(); - - if (InspectResponse != null) - { - InspectResponse(response); - } - - // TODO: Validate handshake - HttpStatusCode statusCode = response.StatusCode; - if (statusCode != HttpStatusCode.SwitchingProtocols) - { - response.Dispose(); - throw new InvalidOperationException("Incomplete handshake, invalid status code: " + statusCode); - } - // TODO: Validate Sec-WebSocket-Key/Sec-WebSocket-Accept - - string subProtocol = response.Headers[Constants.Headers.SecWebSocketProtocol]; - if (!string.IsNullOrEmpty(subProtocol) && !SubProtocols.Contains(subProtocol, StringComparer.OrdinalIgnoreCase)) - { - throw new InvalidOperationException("Incomplete handshake, the server specified an unknown sub-protocol: " + subProtocol); - } - - Stream stream = response.GetResponseStream(); - - return CommonWebSocket.CreateClientWebSocket(stream, subProtocol, KeepAliveInterval, ReceiveBufferSize); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets.Client/project.json b/src/Microsoft.AspNetCore.WebSockets.Client/project.json deleted file mode 100644 index e39b3dafae..0000000000 --- a/src/Microsoft.AspNetCore.WebSockets.Client/project.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "version": "0.2.0-*", - "description": "Client for communicating over web sockets.", - "packOptions": { - "repository": { - "type": "git", - "url": "git://github.com/aspnet/websockets" - } - }, - "buildOptions": { - "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk", - "nowarn": [ - "CS1591" - ], - "xmlDoc": true - }, - "dependencies": { - "Microsoft.AspNetCore.WebSockets.Protocol": "0.2.0-*" - }, - "frameworks": { - "net451": {} - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/Constants.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/Constants.cs deleted file mode 100644 index 56e125afc2..0000000000 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/Constants.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -namespace Microsoft.AspNetCore.WebSockets.Protocol -{ - public static class Constants - { - public static class Headers - { - public const string Upgrade = "Upgrade"; - public const string UpgradeWebSocket = "websocket"; - public const string Connection = "Connection"; - public const string ConnectionUpgrade = "Upgrade"; - public const string SecWebSocketKey = "Sec-WebSocket-Key"; - public const string SecWebSocketVersion = "Sec-WebSocket-Version"; - public const string SecWebSocketProtocol = "Sec-WebSocket-Protocol"; - public const string SecWebSocketAccept = "Sec-WebSocket-Accept"; - public const string SupportedVersion = "13"; - } - - public static class OpCodes - { - public const int ContinuationFrame = 0x0; - public const int TextFrame = 0x1; - public const int BinaryFrame = 0x2; - public const int CloseFrame = 0x8; - public const int PingFrame = 0x9; - public const int PongFrame = 0xA; - - internal static readonly int[] ValidOpCodes = new int[] - { - ContinuationFrame, - TextFrame, - BinaryFrame, - CloseFrame, - PingFrame, - PongFrame, - }; - } - } -} diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/Microsoft.AspNetCore.WebSockets.Protocol.xproj b/src/Microsoft.AspNetCore.WebSockets.Protocol/Microsoft.AspNetCore.WebSockets.Protocol.xproj deleted file mode 100644 index 5b35ce65e5..0000000000 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/Microsoft.AspNetCore.WebSockets.Protocol.xproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - e0c10dec-3339-4a47-85bc-3100c5d34ad4 - .\obj - .\bin\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.WebSockets.Protocol/Properties/AssemblyInfo.cs deleted file mode 100644 index 916862c41d..0000000000 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("Microsoft.Net.WebSockets")] -[assembly: ComVisible(false)] - -[assembly: Guid("9a9e41ae-1494-4d87-a66f-a4019ff68ce5")] -[assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] -[assembly: AssemblyCompany("Microsoft Corporation.")] -[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] -[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/ext/README.md b/src/Microsoft.AspNetCore.WebSockets.Protocol/ext/README.md deleted file mode 100644 index 4b8f84b7ed..0000000000 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/ext/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# External Code - -External code copied from CoreFX. Do not modify files in this directory, use the `scripts\UpdateCoreFxCore.ps1` script in the repo root. - -This folder structure is designed to exactly mirror the structure in the CoreFX repo (hence the deep nesting). \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json b/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json deleted file mode 100644 index c0ebe738b3..0000000000 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/project.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "version": "0.2.0-*", - "description": "Managed web socket protocol parser.", - "packOptions": { - "repository": { - "type": "git", - "url": "git://github.com/aspnet/websockets" - } - }, - "buildOptions": { - "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk", - "nowarn": [ - "CS1591", - "CS1572", - "CS1573" - ], - "xmlDoc": true, - "allowUnsafe": true - }, - "frameworks": { - "net451": {}, - "netstandard1.3": { - "dependencies": { - "System.Diagnostics.Debug": "4.0.11-*", - "System.Diagnostics.Contracts": "4.0.1-*", - "System.Globalization": "4.0.11-*", - "System.IO": "4.1.0-*", - "System.Linq": "4.1.0-*", - "System.Net.WebSockets": "4.0.0-*", - "System.Resources.ResourceManager": "4.0.1-*", - "System.Runtime.InteropServices": "4.1.0-*", - "System.Runtime.Extensions": "4.1.0-*", - "System.Security.Cryptography.Algorithms": "4.2.0-*", - "System.Text.Encoding.Extensions": "4.0.11-*", - "System.Threading": "4.0.11-*", - "System.Threading.Tasks": "4.0.11-*", - "System.Threading.Timer": "4.0.1-*" - } - } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/Microsoft.AspNetCore.WebSockets.Server.xproj b/src/Microsoft.AspNetCore.WebSockets.Server/Microsoft.AspNetCore.WebSockets.Server.xproj deleted file mode 100644 index cace316cad..0000000000 --- a/src/Microsoft.AspNetCore.WebSockets.Server/Microsoft.AspNetCore.WebSockets.Server.xproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 78a097d0-c0a4-4aed-93e2-84a65392fb52 - .\obj - .\bin\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.WebSockets.Server/Properties/AssemblyInfo.cs deleted file mode 100644 index 76feceeff0..0000000000 --- a/src/Microsoft.AspNetCore.WebSockets.Server/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Reflection; -using System.Resources; - -[assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] -[assembly: AssemblyCompany("Microsoft Corporation.")] -[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] -[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/ExtendedWebSocketAcceptContext.cs b/src/Microsoft.AspNetCore.WebSockets/ExtendedWebSocketAcceptContext.cs similarity index 79% rename from src/Microsoft.AspNetCore.WebSockets.Server/ExtendedWebSocketAcceptContext.cs rename to src/Microsoft.AspNetCore.WebSockets/ExtendedWebSocketAcceptContext.cs index eb6fd197c1..23186d7eb5 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Server/ExtendedWebSocketAcceptContext.cs +++ b/src/Microsoft.AspNetCore.WebSockets/ExtendedWebSocketAcceptContext.cs @@ -4,14 +4,12 @@ using System; using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNetCore.WebSockets.Server +namespace Microsoft.AspNetCore.WebSockets { public class ExtendedWebSocketAcceptContext : WebSocketAcceptContext { public override string SubProtocol { get; set; } public int? ReceiveBufferSize { get; set; } public TimeSpan? KeepAliveInterval { get; set; } - - // public ArraySegment? Buffer { get; set; } // TODO } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets.Client/Constants.cs b/src/Microsoft.AspNetCore.WebSockets/Internal/Constants.cs similarity index 94% rename from src/Microsoft.AspNetCore.WebSockets.Client/Constants.cs rename to src/Microsoft.AspNetCore.WebSockets/Internal/Constants.cs index 941c75c63b..ffc5db2c14 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Client/Constants.cs +++ b/src/Microsoft.AspNetCore.WebSockets/Internal/Constants.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNetCore.WebSockets.Client +namespace Microsoft.AspNetCore.WebSockets.Internal { public static class Constants { diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/HandshakeHelpers.cs b/src/Microsoft.AspNetCore.WebSockets/Internal/HandshakeHelpers.cs similarity index 84% rename from src/Microsoft.AspNetCore.WebSockets.Protocol/HandshakeHelpers.cs rename to src/Microsoft.AspNetCore.WebSockets/Internal/HandshakeHelpers.cs index 8afe0a9ce5..019f84a08c 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/HandshakeHelpers.cs +++ b/src/Microsoft.AspNetCore.WebSockets/Internal/HandshakeHelpers.cs @@ -6,26 +6,20 @@ using System.Collections.Generic; using System.Security.Cryptography; using System.Text; -namespace Microsoft.AspNetCore.WebSockets.Protocol +namespace Microsoft.AspNetCore.WebSockets.Internal { public static class HandshakeHelpers { /// /// Gets request headers needed process the handshake on the server. /// - public static IEnumerable NeededHeaders + public static readonly IEnumerable NeededHeaders = new[] { - get - { - return new[] - { - Constants.Headers.Upgrade, - Constants.Headers.Connection, - Constants.Headers.SecWebSocketKey, - Constants.Headers.SecWebSocketVersion - }; - } - } + Constants.Headers.Upgrade, + Constants.Headers.Connection, + Constants.Headers.SecWebSocketKey, + Constants.Headers.SecWebSocketVersion + }; // Verify Method, Upgrade, Connection, version, key, etc.. public static bool CheckSupportedWebSocketRequest(string method, IEnumerable> headers) @@ -103,20 +97,6 @@ namespace Microsoft.AspNetCore.WebSockets.Protocol } } - public static bool IsResponseKeyValid(string value) - { - throw new NotImplementedException(); - } - - /// - /// "The value of this header field MUST be a nonce consisting of a randomly selected 16-byte value that has been base64-encoded." - /// - /// - public static string CreateRequestKey() - { - throw new NotImplementedException(); - } - /// /// "...the base64-encoded SHA-1 of the concatenation of the |Sec-WebSocket-Key| (as a string, not base64-decoded) with the string /// '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'" diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/CommonWebSocket.cs b/src/Microsoft.AspNetCore.WebSockets/Internal/WebSocketFactory.cs similarity index 92% rename from src/Microsoft.AspNetCore.WebSockets.Protocol/CommonWebSocket.cs rename to src/Microsoft.AspNetCore.WebSockets/Internal/WebSocketFactory.cs index 78f29aa9ca..9946d5e9b2 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/CommonWebSocket.cs +++ b/src/Microsoft.AspNetCore.WebSockets/Internal/WebSocketFactory.cs @@ -5,9 +5,9 @@ using System; using System.IO; using System.Net.WebSockets; -namespace Microsoft.AspNetCore.WebSockets.Protocol +namespace Microsoft.AspNetCore.WebSockets.Internal { - public static class CommonWebSocket + public static class WebSocketFactory { public static WebSocket CreateClientWebSocket(Stream stream, string subProtocol, TimeSpan keepAliveInterval, int receiveBufferSize) { diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/CompatHelpers.cs b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/CompatHelpers.cs similarity index 100% rename from src/Microsoft.AspNetCore.WebSockets.Protocol/CompatHelpers.cs rename to src/Microsoft.AspNetCore.WebSockets/Internal/fx/CompatHelpers.cs diff --git a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/README.md b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/README.md new file mode 100644 index 0000000000..ac2ad020a7 --- /dev/null +++ b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/README.md @@ -0,0 +1,5 @@ +# Code copied from dotnet/corefx + +This is code copied out of dotnet/corefx. **Do not** modify anything under the `src` subdirectory as it is copied by `scripts\UpdateCoreFxCore.ps1` in this repo. The files in the root of this directory are only here to shim out code that the corefx code depends on. + +Any changes to code under `src` in this directory MUST be made in dotnet/corefx as well and should mention `Tratcher`, `anurse` and `stephentoub`. \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/SR.cs b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/SR.cs similarity index 100% rename from src/Microsoft.AspNetCore.WebSockets.Protocol/SR.cs rename to src/Microsoft.AspNetCore.WebSockets/Internal/fx/SR.cs diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/ext/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs similarity index 98% rename from src/Microsoft.AspNetCore.WebSockets.Protocol/ext/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs rename to src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs index 06e07f29dd..284b9ee0b4 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/ext/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs +++ b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs @@ -1,3 +1,5 @@ +#pragma warning disable 1572 +#pragma warning disable 1573 // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. diff --git a/src/Microsoft.AspNetCore.WebSockets.Protocol/ext/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ManagedWebSocket.cs b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ManagedWebSocket.cs similarity index 99% rename from src/Microsoft.AspNetCore.WebSockets.Protocol/ext/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ManagedWebSocket.cs rename to src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ManagedWebSocket.cs index 738b0a7348..5b6f1e94da 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Protocol/ext/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ManagedWebSocket.cs +++ b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ManagedWebSocket.cs @@ -1,3 +1,5 @@ +#pragma warning disable 1572 +#pragma warning disable 1573 // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.xproj similarity index 64% rename from test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj rename to src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.xproj index bbc4595fcc..a0c37d1140 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Microsoft.AspNetCore.WebSockets.Protocol.Test.xproj +++ b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.xproj @@ -1,22 +1,19 @@  - + - 14.0 + 14.0.25420 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - aaf2dfcf-845e-4410-bbf0-0683ad60dd6a - Microsoft.AspNetCore.WebSockets.Protocol.Test + cde16880-0374-46fa-8896-99f1b90b4b6f + Microsoft.AspNetCore.WebSockets .\obj .\bin\ - v4.6.1 + 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets.Client/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.WebSockets/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.AspNetCore.WebSockets.Client/Properties/AssemblyInfo.cs rename to src/Microsoft.AspNetCore.WebSockets/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/WebSocketMiddleware.cs b/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs similarity index 95% rename from src/Microsoft.AspNetCore.WebSockets.Server/WebSocketMiddleware.cs rename to src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs index 9bfccfd5c1..006912b29c 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Server/WebSocketMiddleware.cs +++ b/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs @@ -9,10 +9,10 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; -using Microsoft.AspNetCore.WebSockets.Protocol; +using Microsoft.AspNetCore.WebSockets.Internal; using Microsoft.Extensions.Options; -namespace Microsoft.AspNetCore.WebSockets.Server +namespace Microsoft.AspNetCore.WebSockets { public class WebSocketMiddleware { @@ -121,7 +121,7 @@ namespace Microsoft.AspNetCore.WebSockets.Server } Stream opaqueTransport = await _upgradeFeature.UpgradeAsync(); // Sets status code to 101 - return CommonWebSocket.CreateServerWebSocket(opaqueTransport, subProtocol, keepAliveInterval, receiveBufferSize); + return WebSocketFactory.CreateServerWebSocket(opaqueTransport, subProtocol, keepAliveInterval, receiveBufferSize); } } } diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/WebSocketMiddlewareExtensions.cs b/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddlewareExtensions.cs similarity index 95% rename from src/Microsoft.AspNetCore.WebSockets.Server/WebSocketMiddlewareExtensions.cs rename to src/Microsoft.AspNetCore.WebSockets/WebSocketMiddlewareExtensions.cs index 32295ab5af..403271f09a 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Server/WebSocketMiddlewareExtensions.cs +++ b/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddlewareExtensions.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNetCore.WebSockets.Server; +using Microsoft.AspNetCore.WebSockets; using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Builder diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/WebSocketOptions.cs b/src/Microsoft.AspNetCore.WebSockets/WebSocketOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.WebSockets.Server/WebSocketOptions.cs rename to src/Microsoft.AspNetCore.WebSockets/WebSocketOptions.cs diff --git a/src/Microsoft.AspNetCore.WebSockets.Server/project.json b/src/Microsoft.AspNetCore.WebSockets/project.json similarity index 76% rename from src/Microsoft.AspNetCore.WebSockets.Server/project.json rename to src/Microsoft.AspNetCore.WebSockets/project.json index 33a2d2a0c5..5364d0e805 100644 --- a/src/Microsoft.AspNetCore.WebSockets.Server/project.json +++ b/src/Microsoft.AspNetCore.WebSockets/project.json @@ -6,7 +6,8 @@ "nowarn": [ "CS1591" ], - "xmlDoc": true + "xmlDoc": true, + "allowUnsafe": true }, "description": "ASP.NET 5 web socket middleware for use on top of opaque servers.", "packOptions": { @@ -17,13 +18,15 @@ }, "dependencies": { "Microsoft.AspNetCore.Http.Extensions": "1.1.0-*", - "Microsoft.AspNetCore.WebSockets.Protocol": "0.2.0-*", "Microsoft.Extensions.Options": "1.1.0-*" }, "frameworks": { "net451": {}, "netstandard1.3": { - "dependencies": {} + "dependencies": { + "System.Text.Encoding.Extensions": "4.0.11", + "System.Threading.Timer": "4.0.1" + } } } } \ No newline at end of file diff --git a/test/AutobahnTestApp/project.json b/test/AutobahnTestApp/project.json index db9aab27e7..2269497e8a 100644 --- a/test/AutobahnTestApp/project.json +++ b/test/AutobahnTestApp/project.json @@ -1,6 +1,6 @@ { "dependencies": { - "Microsoft.AspNetCore.WebSockets.Server": "0.2.0-*", + "Microsoft.AspNetCore.WebSockets": "0.2.0-*", "Microsoft.NETCore.App": { "version": "1.0.0", "type": "platform" diff --git a/test/Microsoft.AspNetCore.WebSockets.Client.Test/WebSocketClientTests.cs b/test/Microsoft.AspNetCore.WebSockets.Client.Test/WebSocketClientTests.cs deleted file mode 100644 index 1b742cd8e8..0000000000 --- a/test/Microsoft.AspNetCore.WebSockets.Client.Test/WebSocketClientTests.cs +++ /dev/null @@ -1,536 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Net.WebSockets; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Testing.xunit; -using Xunit; - -namespace Microsoft.AspNetCore.WebSockets.Client.Test -{ - public class WebSocketClientTests - { - private static string ClientAddress = "ws://localhost:54321/"; - - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - public async Task Connect_Success() - { - using (var server = KestrelWebSocketHelpers.CreateServer(async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - })) - { - var client = new WebSocketClient(); - using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) - { - } - } - } - - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - public async Task NegotiateSubProtocol_Success() - { - using (var server = KestrelWebSocketHelpers.CreateServer(async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - Assert.Equal("alpha, bravo, charlie", context.Request.Headers["Sec-WebSocket-Protocol"]); - var webSocket = await context.WebSockets.AcceptWebSocketAsync("Bravo"); - })) - { - var client = new WebSocketClient(); - client.SubProtocols.Add("alpha"); - client.SubProtocols.Add("bravo"); - client.SubProtocols.Add("charlie"); - using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) - { - Assert.Equal("Bravo", clientSocket.SubProtocol); - } - } - } - - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - public async Task SendEmptyData_Success() - { - using (var server = KestrelWebSocketHelpers.CreateServer(async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - var serverBuffer = new byte[0]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - })) - { - var client = new WebSocketClient(); - using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) - { - var orriginalData = new byte[0]; - await clientSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - } - } - } - - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - public async Task SendShortData_Success() - { - var orriginalData = Encoding.UTF8.GetBytes("Hello World"); - using (var server = KestrelWebSocketHelpers.CreateServer(async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - var serverBuffer = new byte[orriginalData.Length]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(orriginalData.Length, result.Count); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - Assert.Equal(orriginalData, serverBuffer); - })) - { - var client = new WebSocketClient(); - using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) - { - await clientSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - } - } - } - - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - public async Task SendMediumData_Success() - { - var orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); - using (var server = KestrelWebSocketHelpers.CreateServer(async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - var serverBuffer = new byte[orriginalData.Length]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(orriginalData.Length, result.Count); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - Assert.Equal(orriginalData, serverBuffer); - })) - { - var client = new WebSocketClient(); - using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) - { - await clientSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - } - } - } - - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - public async Task SendLongData_Success() - { - var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); - using (var server = KestrelWebSocketHelpers.CreateServer(async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - var serverBuffer = new byte[orriginalData.Length]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - int intermediateCount = result.Count; - Assert.False(result.EndOfMessage); - Assert.Equal(WebSocketMessageType.Text, result.MessageType); - - result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer, intermediateCount, orriginalData.Length - intermediateCount), CancellationToken.None); - intermediateCount += result.Count; - Assert.False(result.EndOfMessage); - Assert.Equal(WebSocketMessageType.Text, result.MessageType); - - result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer, intermediateCount, orriginalData.Length - intermediateCount), CancellationToken.None); - intermediateCount += result.Count; - Assert.True(result.EndOfMessage); - Assert.Equal(orriginalData.Length, intermediateCount); - Assert.Equal(WebSocketMessageType.Text, result.MessageType); - - Assert.Equal(orriginalData, serverBuffer); - })) - { - var client = new WebSocketClient(); - using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) - { - await clientSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - } - } - } - - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - public async Task SendFragmentedData_Success() - { - var orriginalData = Encoding.UTF8.GetBytes("Hello World"); - using (var server = KestrelWebSocketHelpers.CreateServer(async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - var serverBuffer = new byte[orriginalData.Length]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.False(result.EndOfMessage); - Assert.Equal(2, result.Count); - int totalReceived = result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - - result = await webSocket.ReceiveAsync( - new ArraySegment(serverBuffer, totalReceived, serverBuffer.Length - totalReceived), CancellationToken.None); - Assert.False(result.EndOfMessage); - Assert.Equal(2, result.Count); - totalReceived += result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - - result = await webSocket.ReceiveAsync( - new ArraySegment(serverBuffer, totalReceived, serverBuffer.Length - totalReceived), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(7, result.Count); - totalReceived += result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - - Assert.Equal(orriginalData, serverBuffer); - })) - { - var client = new WebSocketClient(); - using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) - { - await clientSocket.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); - await clientSocket.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); - await clientSocket.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); - } - } - } - - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - public async Task ReceiveEmptyData_Success() - { - var orriginalData = Encoding.UTF8.GetBytes("Hello World"); - using (var server = KestrelWebSocketHelpers.CreateServer(async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - })) - { - var client = new WebSocketClient(); - using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) - { - var clientBuffer = new byte[0]; - var result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); - Assert.False(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - } - } - } - - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - public async Task ReceiveShortData_Success() - { - var orriginalData = Encoding.UTF8.GetBytes("Hello World"); - using (var server = KestrelWebSocketHelpers.CreateServer(async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - })) - { - var client = new WebSocketClient(); - using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) - { - var clientBuffer = new byte[orriginalData.Length]; - var result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(orriginalData.Length, result.Count); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - Assert.Equal(orriginalData, clientBuffer); - } - } - } - - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - public async Task ReceiveMediumData_Success() - { - var orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); - using (var server = KestrelWebSocketHelpers.CreateServer(async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - })) - { - var client = new WebSocketClient(); - using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) - { - var clientBuffer = new byte[orriginalData.Length]; - var result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(orriginalData.Length, result.Count); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - Assert.Equal(orriginalData, clientBuffer); - } - } - } - - [ConditionalTheory] - [InlineData(1024 * 16)] - [InlineData(0xFFFFFF)] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - public async Task ReceiveLongData(int receiveBufferSize) - { - var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); - using (var server = KestrelWebSocketHelpers.CreateServer(async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - })) - { - var client = new WebSocketClient() { ReceiveBufferSize = receiveBufferSize }; - using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) - { - var clientBuffer = new byte[orriginalData.Length]; - WebSocketReceiveResult result; - int receivedCount = 0; - do - { - result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer, receivedCount, clientBuffer.Length - receivedCount), CancellationToken.None); - receivedCount += result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - } - while (!result.EndOfMessage); - - Assert.Equal(orriginalData.Length, receivedCount); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - Assert.Equal(orriginalData, clientBuffer); - } - } - } - - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - public async Task ReceiveFragmentedData_Success() - { - var orriginalData = Encoding.UTF8.GetBytes("Hello World"); - using (var server = KestrelWebSocketHelpers.CreateServer(async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - await webSocket.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); - await webSocket.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); - await webSocket.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); - })) - { - var client = new WebSocketClient(); - using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) - { - var clientBuffer = new byte[orriginalData.Length]; - var result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); - Assert.False(result.EndOfMessage); - Assert.Equal(2, result.Count); - int totalReceived = result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - - result = await clientSocket.ReceiveAsync( - new ArraySegment(clientBuffer, totalReceived, clientBuffer.Length - totalReceived), CancellationToken.None); - Assert.False(result.EndOfMessage); - Assert.Equal(2, result.Count); - totalReceived += result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - - result = await clientSocket.ReceiveAsync( - new ArraySegment(clientBuffer, totalReceived, clientBuffer.Length - totalReceived), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(7, result.Count); - totalReceived += result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - - Assert.Equal(orriginalData, clientBuffer); - } - } - } - - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - public async Task SendClose_Success() - { - string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - var serverBuffer = new byte[1024]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Close, result.MessageType); - Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); - Assert.Equal(closeDescription, result.CloseStatusDescription); - })) - { - var client = new WebSocketClient(); - using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) - { - await clientSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - - Assert.Equal(WebSocketState.CloseSent, clientSocket.State); - } - } - } - - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - public async Task ReceiveClose_Success() - { - string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - })) - { - var client = new WebSocketClient(); - using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) - { - var clientBuffer = new byte[1024]; - var result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Close, result.MessageType); - Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); - Assert.Equal(closeDescription, result.CloseStatusDescription); - - Assert.Equal(WebSocketState.CloseReceived, clientSocket.State); - } - } - } - - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - public async Task CloseFromOpen_Success() - { - string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - var serverBuffer = new byte[1024]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Close, result.MessageType); - Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); - Assert.Equal(closeDescription, result.CloseStatusDescription); - - await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); - })) - { - var client = new WebSocketClient(); - using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) - { - await clientSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - - Assert.Equal(WebSocketState.Closed, clientSocket.State); - } - } - } - - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - public async Task CloseFromCloseSent_Success() - { - string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - var serverBuffer = new byte[1024]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Close, result.MessageType); - Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); - Assert.Equal(closeDescription, result.CloseStatusDescription); - - await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); - })) - { - var client = new WebSocketClient(); - using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) - { - await clientSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - Assert.Equal(WebSocketState.CloseSent, clientSocket.State); - - await clientSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - Assert.Equal(WebSocketState.Closed, clientSocket.State); - } - } - } - - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - public async Task CloseFromCloseReceived_Success() - { - string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - - var serverBuffer = new byte[1024]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Close, result.MessageType); - Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); - Assert.Equal(closeDescription, result.CloseStatusDescription); - })) - { - var client = new WebSocketClient(); - using (var clientSocket = await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None)) - { - var clientBuffer = new byte[1024]; - var result = await clientSocket.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Close, result.MessageType); - Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); - Assert.Equal(closeDescription, result.CloseStatusDescription); - - Assert.Equal(WebSocketState.CloseReceived, clientSocket.State); - - await clientSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); - - Assert.Equal(WebSocketState.Closed, clientSocket.State); - } - } - } - } -} diff --git a/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json deleted file mode 100644 index 9a5cc63182..0000000000 --- a/test/Microsoft.AspNetCore.WebSockets.Client.Test/project.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "dependencies": { - "dotnet-test-xunit": "2.2.0-*", - "Microsoft.AspNetCore.WebSockets.Client": "0.2.0-*", - "Microsoft.AspNetCore.WebSockets.Server": "0.2.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", - "Microsoft.AspNetCore.Testing": "1.1.0-*", - "xunit": "2.2.0-*" - }, - "testRunner": "xunit", - "frameworks": { - "net451": {} - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnCaseResult.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnCaseResult.cs similarity index 92% rename from test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnCaseResult.cs rename to test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnCaseResult.cs index 017d178880..2cba13cf25 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnCaseResult.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnCaseResult.cs @@ -2,7 +2,7 @@ using System.Linq; using Newtonsoft.Json.Linq; -namespace Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn +namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { public class AutobahnCaseResult { diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnExpectations.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnExpectations.cs similarity index 98% rename from test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnExpectations.cs rename to test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnExpectations.cs index dfcf9a4c25..a8e7425461 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnExpectations.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnExpectations.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Text; using Microsoft.AspNetCore.Server.Testing; -namespace Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn +namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { public class AutobahnExpectations { diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnResult.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnResult.cs similarity index 89% rename from test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnResult.cs rename to test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnResult.cs index c23164a13c..0e88a07917 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnResult.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnResult.cs @@ -4,7 +4,7 @@ using System.Linq; using Microsoft.AspNetCore.Server.Testing; using Newtonsoft.Json.Linq; -namespace Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn +namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { public class AutobahnResult { diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnServerResult.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnServerResult.cs similarity index 94% rename from test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnServerResult.cs rename to test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnServerResult.cs index 4986bbdfc6..a92892d111 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnServerResult.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnServerResult.cs @@ -4,7 +4,7 @@ using System.Linq; using Microsoft.AspNetCore.Server.Testing; using Newtonsoft.Json.Linq; -namespace Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn +namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { public class AutobahnServerResult { diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnSpec.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnSpec.cs similarity index 96% rename from test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnSpec.cs rename to test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnSpec.cs index 0c97999136..18218f3a61 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnSpec.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnSpec.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -namespace Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn +namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { public class AutobahnSpec { diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs similarity index 98% rename from test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnTester.cs rename to test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index ed74e67b5a..13ecaee858 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -11,7 +11,7 @@ using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; using Xunit; -namespace Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn +namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { public class AutobahnTester : IDisposable { diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/Executable.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs similarity index 95% rename from test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/Executable.cs rename to test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs index eb9a46a889..28fd671bb3 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/Executable.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs @@ -5,7 +5,7 @@ using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; -namespace Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn +namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { public class Executable { diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/Expectation.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Expectation.cs similarity index 64% rename from test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/Expectation.cs rename to test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Expectation.cs index a3a8040f9d..0661b0d02f 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/Expectation.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Expectation.cs @@ -1,4 +1,4 @@ -namespace Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn +namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { public enum Expectation { diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/ServerSpec.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/ServerSpec.cs similarity index 88% rename from test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/ServerSpec.cs rename to test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/ServerSpec.cs index 265d1f7971..e100794a91 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/ServerSpec.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/ServerSpec.cs @@ -1,7 +1,7 @@ using System; using Newtonsoft.Json.Linq; -namespace Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn +namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { public class ServerSpec { diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/Wstest.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs similarity index 88% rename from test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/Wstest.cs rename to test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs index 07d09d34f5..bfa2c18af9 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Autobahn/Wstest.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs @@ -1,6 +1,6 @@ using System; -namespace Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn +namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { /// /// Wrapper around the Autobahn Test Suite's "wstest" app. diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs similarity index 97% rename from test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/AutobahnTests.cs rename to test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs index 0a55c8b0d1..89cbfd5bbd 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs @@ -6,11 +6,11 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; using Microsoft.AspNetCore.Server.Testing; using Microsoft.AspNetCore.Testing.xunit; -using Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn; +using Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn; using Microsoft.Extensions.Logging; using Microsoft.Extensions.PlatformAbstractions; -namespace Microsoft.AspNetCore.WebSockets.Server.Test +namespace Microsoft.AspNetCore.WebSockets.ConformanceTest { public class AutobahnTests { diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Helpers.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Helpers.cs similarity index 94% rename from test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Helpers.cs rename to test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Helpers.cs index a22eb25bf3..ad0f500837 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Helpers.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Helpers.cs @@ -2,7 +2,7 @@ using System.IO; using Microsoft.Extensions.PlatformAbstractions; -namespace Microsoft.AspNetCore.WebSockets.Server.Test +namespace Microsoft.AspNetCore.WebSockets.ConformanceTest { public class Helpers { diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest.xproj b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.xproj similarity index 86% rename from test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest.xproj rename to test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.xproj index 10e9e7c82d..4be31bf78c 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest.xproj +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.xproj @@ -6,8 +6,8 @@ - a722bb6c-9114-4f25-9bb0-2191d4405f3a - Microsoft.AspNetCore.WebSockets.Server.ConformanceTest + 74f45408-1959-4fee-9511-25d40f4913fd + Microsoft.AspNetCore.WebSockets.ConformanceTest .\obj .\bin\ diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Properties/AssemblyInfo.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Properties/AssemblyInfo.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/Properties/AssemblyInfo.cs rename to test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Properties/AssemblyInfo.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs similarity index 75% rename from test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs rename to test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs index b37fd95868..ea6b1cc824 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs @@ -1,8 +1,8 @@ using System; using Microsoft.AspNetCore.Testing.xunit; -using Microsoft.AspNetCore.WebSockets.Server.Test.Autobahn; +using Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn; -namespace Microsoft.AspNetCore.WebSockets.Server.Test +namespace Microsoft.AspNetCore.WebSockets.ConformanceTest { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public class SkipIfWsTestNotPresentAttribute : Attribute, ITestCondition diff --git a/test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/project.json b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Server.ConformanceTest/project.json rename to test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/BufferStream.cs b/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs similarity index 99% rename from test/Microsoft.AspNetCore.WebSockets.Protocol.Test/BufferStream.cs rename to test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs index 0d8454162f..61a6699034 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/BufferStream.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs @@ -8,7 +8,7 @@ using System.IO; using System.Threading; using System.Threading.Tasks; -namespace Microsoft.AspNetCore.WebSockets.Protocol.Test +namespace Microsoft.AspNetCore.WebSockets.Test { // This steam accepts writes from one side, buffers them internally, and returns the data via Reads // when requested on the other side. diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexStream.cs b/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs similarity index 98% rename from test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexStream.cs rename to test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs index 9d0c40bfc2..528b20466e 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/DuplexStream.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs @@ -5,7 +5,7 @@ using System.IO; using System.Threading; using System.Threading.Tasks; -namespace Microsoft.AspNetCore.WebSockets.Protocol.Test +namespace Microsoft.AspNetCore.WebSockets.Test { // A duplex wrapper around a read and write stream. public class DuplexStream : Stream diff --git a/test/Microsoft.AspNetCore.WebSockets.Client.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs similarity index 97% rename from test/Microsoft.AspNetCore.WebSockets.Client.Test/KestrelWebSocketHelpers.cs rename to test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs index b6bc9250d8..646286183a 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Client.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs @@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; -namespace Microsoft.AspNetCore.WebSockets.Client.Test +namespace Microsoft.AspNetCore.WebSockets.Test { public class KestrelWebSocketHelpers { diff --git a/test/Microsoft.AspNetCore.WebSockets.Client.Test/Microsoft.AspNetCore.WebSockets.Client.Test.xproj b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.xproj similarity index 54% rename from test/Microsoft.AspNetCore.WebSockets.Client.Test/Microsoft.AspNetCore.WebSockets.Client.Test.xproj rename to test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.xproj index e54463273b..7ad8fa523a 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Client.Test/Microsoft.AspNetCore.WebSockets.Client.Test.xproj +++ b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.xproj @@ -1,20 +1,19 @@  - + - 14.0 + 14.0.25420 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + - 6604d154-817f-4bc5-be95-ff7e851179d9 + 5afa74f5-9b1d-4fc5-815f-ef471f5ac1ef + Microsoft.AspNetCore.WebSockets.Test .\obj .\bin\ + 2.0 - - - - + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Properties/AssemblyInfo.cs b/test/Microsoft.AspNetCore.WebSockets.Test/Properties/AssemblyInfo.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Protocol.Test/Properties/AssemblyInfo.cs rename to test/Microsoft.AspNetCore.WebSockets.Test/Properties/AssemblyInfo.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/SendReceiveTests.cs b/test/Microsoft.AspNetCore.WebSockets.Test/SendReceiveTests.cs similarity index 98% rename from test/Microsoft.AspNetCore.WebSockets.Protocol.Test/SendReceiveTests.cs rename to test/Microsoft.AspNetCore.WebSockets.Test/SendReceiveTests.cs index 109c4b821a..9580b7faad 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/SendReceiveTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/SendReceiveTests.cs @@ -6,7 +6,7 @@ using System.Threading; using System.Threading.Tasks; using Xunit; -namespace Microsoft.AspNetCore.WebSockets.Protocol.Test +namespace Microsoft.AspNetCore.WebSockets.Test { public class SendReceiveTests { diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs new file mode 100644 index 0000000000..4034af10a4 --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs @@ -0,0 +1,541 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Net.WebSockets; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Testing.xunit; +using Xunit; + +namespace Microsoft.AspNetCore.WebSockets.Test +{ + public class WebSocketMiddlewareTests + { + private static string ClientAddress = "ws://localhost:54321/"; + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] + public async Task Connect_Success() + { + using (var server = KestrelWebSocketHelpers.CreateServer(async context => + { + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + } + } + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] + public async Task NegotiateSubProtocol_Success() + { + using (var server = KestrelWebSocketHelpers.CreateServer(async context => + { + Assert.True(context.WebSockets.IsWebSocketRequest); + Assert.Equal("alpha, bravo, charlie", context.Request.Headers["Sec-WebSocket-Protocol"]); + var webSocket = await context.WebSockets.AcceptWebSocketAsync("Bravo"); + })) + { + using (var client = new ClientWebSocket()) + { + client.Options.AddSubProtocol("alpha"); + client.Options.AddSubProtocol("bravo"); + client.Options.AddSubProtocol("charlie"); + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + Assert.Equal("Bravo", client.SubProtocol); + } + } + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] + public async Task SendEmptyData_Success() + { + using (var server = KestrelWebSocketHelpers.CreateServer(async context => + { + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + var serverBuffer = new byte[0]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var orriginalData = new byte[0]; + await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + } + } + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] + public async Task SendShortData_Success() + { + var orriginalData = Encoding.UTF8.GetBytes("Hello World"); + using (var server = KestrelWebSocketHelpers.CreateServer(async context => + { + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + var serverBuffer = new byte[orriginalData.Length]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, serverBuffer); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + } + } + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] + public async Task SendMediumData_Success() + { + var orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); + using (var server = KestrelWebSocketHelpers.CreateServer(async context => + { + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + var serverBuffer = new byte[orriginalData.Length]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, serverBuffer); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + } + } + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] + public async Task SendLongData_Success() + { + var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); + using (var server = KestrelWebSocketHelpers.CreateServer(async context => + { + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + var serverBuffer = new byte[orriginalData.Length]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + int intermediateCount = result.Count; + Assert.False(result.EndOfMessage); + Assert.Equal(WebSocketMessageType.Text, result.MessageType); + + result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer, intermediateCount, orriginalData.Length - intermediateCount), CancellationToken.None); + intermediateCount += result.Count; + Assert.False(result.EndOfMessage); + Assert.Equal(WebSocketMessageType.Text, result.MessageType); + + result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer, intermediateCount, orriginalData.Length - intermediateCount), CancellationToken.None); + intermediateCount += result.Count; + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, intermediateCount); + Assert.Equal(WebSocketMessageType.Text, result.MessageType); + + Assert.Equal(orriginalData, serverBuffer); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + } + } + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] + public async Task SendFragmentedData_Success() + { + var orriginalData = Encoding.UTF8.GetBytes("Hello World"); + using (var server = KestrelWebSocketHelpers.CreateServer(async context => + { + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + var serverBuffer = new byte[orriginalData.Length]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.False(result.EndOfMessage); + Assert.Equal(2, result.Count); + int totalReceived = result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + result = await webSocket.ReceiveAsync( + new ArraySegment(serverBuffer, totalReceived, serverBuffer.Length - totalReceived), CancellationToken.None); + Assert.False(result.EndOfMessage); + Assert.Equal(2, result.Count); + totalReceived += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + result = await webSocket.ReceiveAsync( + new ArraySegment(serverBuffer, totalReceived, serverBuffer.Length - totalReceived), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(7, result.Count); + totalReceived += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + Assert.Equal(orriginalData, serverBuffer); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); + await client.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); + await client.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); + } + } + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] + public async Task ReceiveShortData_Success() + { + var orriginalData = Encoding.UTF8.GetBytes("Hello World"); + using (var server = KestrelWebSocketHelpers.CreateServer(async context => + { + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var clientBuffer = new byte[orriginalData.Length]; + var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, clientBuffer); + } + } + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] + public async Task ReceiveMediumData_Success() + { + var orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); + using (var server = KestrelWebSocketHelpers.CreateServer(async context => + { + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var clientBuffer = new byte[orriginalData.Length]; + var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, clientBuffer); + } + } + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] + public async Task ReceiveLongData() + { + var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); + using (var server = KestrelWebSocketHelpers.CreateServer(async context => + { + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var clientBuffer = new byte[orriginalData.Length]; + WebSocketReceiveResult result; + int receivedCount = 0; + do + { + result = await client.ReceiveAsync(new ArraySegment(clientBuffer, receivedCount, clientBuffer.Length - receivedCount), CancellationToken.None); + receivedCount += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + } + while (!result.EndOfMessage); + + Assert.Equal(orriginalData.Length, receivedCount); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, clientBuffer); + } + } + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] + public async Task ReceiveFragmentedData_Success() + { + var orriginalData = Encoding.UTF8.GetBytes("Hello World"); + using (var server = KestrelWebSocketHelpers.CreateServer(async context => + { + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + await webSocket.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); + await webSocket.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); + await webSocket.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var clientBuffer = new byte[orriginalData.Length]; + var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.False(result.EndOfMessage); + Assert.Equal(2, result.Count); + int totalReceived = result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + result = await client.ReceiveAsync( + new ArraySegment(clientBuffer, totalReceived, clientBuffer.Length - totalReceived), CancellationToken.None); + Assert.False(result.EndOfMessage); + Assert.Equal(2, result.Count); + totalReceived += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + result = await client.ReceiveAsync( + new ArraySegment(clientBuffer, totalReceived, clientBuffer.Length - totalReceived), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(7, result.Count); + totalReceived += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + Assert.Equal(orriginalData, clientBuffer); + } + } + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] + public async Task SendClose_Success() + { + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(async context => + { + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + var serverBuffer = new byte[1024]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + + Assert.Equal(WebSocketState.CloseSent, client.State); + } + } + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] + public async Task ReceiveClose_Success() + { + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(async context => + { + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var clientBuffer = new byte[1024]; + var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + + Assert.Equal(WebSocketState.CloseReceived, client.State); + } + } + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] + public async Task CloseFromOpen_Success() + { + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(async context => + { + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + var serverBuffer = new byte[1024]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + + await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + + Assert.Equal(WebSocketState.Closed, client.State); + } + } + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] + public async Task CloseFromCloseSent_Success() + { + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(async context => + { + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + var serverBuffer = new byte[1024]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + + await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + Assert.Equal(WebSocketState.CloseSent, client.State); + + await client.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + Assert.Equal(WebSocketState.Closed, client.State); + } + } + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] + public async Task CloseFromCloseReceived_Success() + { + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(async context => + { + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + + var serverBuffer = new byte[1024]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var clientBuffer = new byte[1024]; + var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + + Assert.Equal(WebSocketState.CloseReceived, client.State); + + await client.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + + Assert.Equal(WebSocketState.Closed, client.State); + } + } + } +} +} diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/WebSocketPair.cs b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketPair.cs similarity index 64% rename from test/Microsoft.AspNetCore.WebSockets.Protocol.Test/WebSocketPair.cs rename to test/Microsoft.AspNetCore.WebSockets.Test/WebSocketPair.cs index 1bf3512468..936371acdd 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/WebSocketPair.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketPair.cs @@ -1,7 +1,8 @@ using System; using System.Net.WebSockets; +using Microsoft.AspNetCore.WebSockets.Internal; -namespace Microsoft.AspNetCore.WebSockets.Protocol.Test +namespace Microsoft.AspNetCore.WebSockets.Test { internal class WebSocketPair { @@ -21,8 +22,8 @@ namespace Microsoft.AspNetCore.WebSockets.Protocol.Test var clientStream = serverStream.CreateReverseDuplexStream(); return new WebSocketPair( - clientSocket: CommonWebSocket.CreateClientWebSocket(clientStream, null, TimeSpan.FromMinutes(2), 1024), - serverSocket: CommonWebSocket.CreateServerWebSocket(serverStream, null, TimeSpan.FromMinutes(2), 1024)); + clientSocket: WebSocketFactory.CreateClientWebSocket(clientStream, null, TimeSpan.FromMinutes(2), 1024), + serverSocket: WebSocketFactory.CreateServerWebSocket(serverStream, null, TimeSpan.FromMinutes(2), 1024)); } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Test/project.json similarity index 57% rename from test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json rename to test/Microsoft.AspNetCore.WebSockets.Test/project.json index 9eb586b89b..ee1dcaccef 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Test/project.json @@ -1,13 +1,17 @@ -{ +{ "dependencies": { "dotnet-test-xunit": "2.2.0-*", - "Microsoft.AspNetCore.WebSockets.Protocol": "0.2.0-*", + "Microsoft.AspNetCore.Testing": "1.1.0-*", + "Microsoft.AspNetCore.WebSockets": "0.2.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", "xunit": "2.2.0-*" }, "testRunner": "xunit", "frameworks": { + "net451": {}, "netcoreapp1.0": { "dependencies": { + "System.Net.WebSockets.Client": "4.0.0", "Microsoft.NETCore.App": { "version": "1.0.0-*", "type": "platform" From 78b5f53a6f036b3c66ab83e8f4295ef9b77c042c Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 4 Aug 2016 11:41:10 -0700 Subject: [PATCH 229/453] fix NuGetPackageVerifier.json --- NuGetPackageVerifier.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json index f3fff6acbd..a92d13f00a 100644 --- a/NuGetPackageVerifier.json +++ b/NuGetPackageVerifier.json @@ -4,9 +4,7 @@ "AdxVerificationCompositeRule" ], "packages": { - "Microsoft.AspNetCore.WebSockets.Client": { }, - "Microsoft.AspNetCore.WebSockets.Protocol": { }, - "Microsoft.AspNetCore.WebSockets.Server": { } + "Microsoft.AspNetCore.WebSockets": { } } }, "Default": { // Rules to run for packages not listed in any other set. @@ -14,4 +12,4 @@ "DefaultCompositeRule" ] } -} \ No newline at end of file +} From 396ff561a1c4b34fedf5a49494c839e5ec35a556 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 4 Aug 2016 16:02:28 -0700 Subject: [PATCH 230/453] Remove TestClient --- samples/TestClient/App.config | 6 --- samples/TestClient/Program.cs | 51 ------------------- samples/TestClient/Properties/AssemblyInfo.cs | 36 ------------- samples/TestClient/TestClient.xproj | 17 ------- samples/TestClient/project.json | 9 ---- 5 files changed, 119 deletions(-) delete mode 100644 samples/TestClient/App.config delete mode 100644 samples/TestClient/Program.cs delete mode 100644 samples/TestClient/Properties/AssemblyInfo.cs delete mode 100644 samples/TestClient/TestClient.xproj delete mode 100644 samples/TestClient/project.json diff --git a/samples/TestClient/App.config b/samples/TestClient/App.config deleted file mode 100644 index d0feca6f79..0000000000 --- a/samples/TestClient/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/samples/TestClient/Program.cs b/samples/TestClient/Program.cs deleted file mode 100644 index da50641682..0000000000 --- a/samples/TestClient/Program.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Net.WebSockets; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.AspNetCore.WebSockets.Client; - -namespace TestClient -{ - class Program - { - static void Main(string[] args) - { - try - { - Console.WriteLine("Waiting to start"); - Console.ReadKey(); - RunTestAsync().Wait(); - } - catch (Exception ex) - { - Console.WriteLine(ex); - } - } - - private static async Task RunTestAsync() - { - WebSocketClient client = new WebSocketClient(); - WebSocket socket = await client.ConnectAsync(new Uri("ws://localhost:12345/"), CancellationToken.None); - byte[] data = new byte[100]; // Encoding.UTF8.GetBytes( - // TODO: Hangs after 10 seconds - // "Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World" - // "Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, " - // "Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, " - // "Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, " - // ); - while (true) - { - // await socket.SendAsync(new ArraySegment(data), WebSocketMessageType.Text, true, CancellationToken.None); - WebSocketReceiveResult result; - do - { - result = await socket.ReceiveAsync(new ArraySegment(data), CancellationToken.None); - Console.WriteLine("Received: " + result.MessageType + ", " + result.Count + ", " + result.EndOfMessage); - } while (!result.EndOfMessage); - Console.WriteLine(Encoding.UTF8.GetString(data, 0, result.Count)); - } - // await socket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Closing", CancellationToken.None); - } - } -} diff --git a/samples/TestClient/Properties/AssemblyInfo.cs b/samples/TestClient/Properties/AssemblyInfo.cs deleted file mode 100644 index 1ef2184108..0000000000 --- a/samples/TestClient/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("TestClient")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("TestClient")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("0a30acb8-eb32-43ad-ab6c-36c070d6ba51")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/samples/TestClient/TestClient.xproj b/samples/TestClient/TestClient.xproj deleted file mode 100644 index ed24e19aa4..0000000000 --- a/samples/TestClient/TestClient.xproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 8c8eac01-dc49-4c5e-b348-e4e46fe675f9 - .\obj - .\bin\ - - - 2.0 - - - \ No newline at end of file diff --git a/samples/TestClient/project.json b/samples/TestClient/project.json deleted file mode 100644 index cf854beb28..0000000000 --- a/samples/TestClient/project.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "dependencies": { - "Microsoft.AspNetCore.WebSockets.Protocol": "0.2.0-*", - "Microsoft.AspNetCore.WebSockets.Client": "0.2.0-*" - }, - "frameworks": { - "net451": {} - } -} \ No newline at end of file From 00939fcac924266cf365f1b99e0737698ba03fde Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 9 Aug 2016 15:17:47 -0700 Subject: [PATCH 231/453] Migrate to dotnet.myget.org feed --- NuGet.config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.config b/NuGet.config index 8de7d930c6..e8b2884654 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + - + \ No newline at end of file From 131594667d82955d8c52f40cf6329eade980b2db Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 15 Aug 2016 16:24:28 -0700 Subject: [PATCH 232/453] Reacting to Microsoft.AspNetCore.Server.Testing rename --- .../Autobahn/AutobahnExpectations.cs | 2 +- .../Autobahn/AutobahnResult.cs | 4 +- .../Autobahn/AutobahnServerResult.cs | 2 +- .../Autobahn/AutobahnSpec.cs | 4 +- .../Autobahn/AutobahnTester.cs | 2 +- .../Autobahn/Executable.cs | 1 - .../Autobahn/ServerSpec.cs | 3 +- .../AutobahnTests.cs | 2 +- .../Properties/AssemblyInfo.cs | 1 - .../project.json | 38 +++++++++---------- 10 files changed, 26 insertions(+), 33 deletions(-) diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnExpectations.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnExpectations.cs index a8e7425461..a616d6f489 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnExpectations.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnExpectations.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.Text; -using Microsoft.AspNetCore.Server.Testing; +using Microsoft.AspNetCore.Server.IntegrationTesting; namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnResult.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnResult.cs index 0e88a07917..df3c025741 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnResult.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnResult.cs @@ -1,7 +1,5 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; -using Microsoft.AspNetCore.Server.Testing; using Newtonsoft.Json.Linq; namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnServerResult.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnServerResult.cs index a92892d111..8e53f8091d 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnServerResult.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnServerResult.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using Microsoft.AspNetCore.Server.Testing; +using Microsoft.AspNetCore.Server.IntegrationTesting; using Newtonsoft.Json.Linq; namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnSpec.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnSpec.cs index 18218f3a61..0d48db4eab 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnSpec.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnSpec.cs @@ -1,8 +1,6 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Linq; -using System.Threading.Tasks; using Newtonsoft.Json; using Newtonsoft.Json.Linq; diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index 13ecaee858..dce4083ff7 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -6,7 +6,7 @@ using System.Net.Http; using System.Text; using System.Threading; using System.Threading.Tasks; -using Microsoft.AspNetCore.Server.Testing; +using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; using Xunit; diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs index 28fd671bb3..f404a79a0e 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs @@ -2,7 +2,6 @@ using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; -using System.Text; using System.Threading.Tasks; namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/ServerSpec.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/ServerSpec.cs index e100794a91..6b149d14d2 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/ServerSpec.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/ServerSpec.cs @@ -1,5 +1,4 @@ -using System; -using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Linq; namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs index 89cbfd5bbd..58a38afc68 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs @@ -4,7 +4,7 @@ using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Threading.Tasks; -using Microsoft.AspNetCore.Server.Testing; +using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.AspNetCore.Testing.xunit; using Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn; using Microsoft.Extensions.Logging; diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Properties/AssemblyInfo.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Properties/AssemblyInfo.cs index 6e03af7061..72534b1587 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Properties/AssemblyInfo.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json index 9054cd9eb8..8f3b299b5c 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json @@ -1,23 +1,23 @@ { - "dependencies": { - "dotnet-test-xunit": "2.2.0-*", - "Microsoft.AspNetCore.Server.Testing": "0.2.0-*", - "Microsoft.AspNetCore.Testing": "1.1.0-*", - "Microsoft.Extensions.Logging": "1.1.0-*", - "Microsoft.Extensions.Logging.Console": "1.1.0-*", - "Microsoft.Extensions.PlatformAbstractions": "1.1.0-*", - "System.Diagnostics.FileVersionInfo": "4.0.0", - "xunit": "2.2.0-*" - }, - "testRunner": "xunit", - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.0.0-*", - "type": "platform" - } - } + "dependencies": { + "dotnet-test-xunit": "2.2.0-*", + "Microsoft.AspNetCore.Server.IntegrationTesting": "0.2.0-*", + "Microsoft.AspNetCore.Testing": "1.1.0-*", + "Microsoft.Extensions.Logging": "1.1.0-*", + "Microsoft.Extensions.Logging.Console": "1.1.0-*", + "Microsoft.Extensions.PlatformAbstractions": "1.1.0-*", + "System.Diagnostics.FileVersionInfo": "4.0.0", + "xunit": "2.2.0-*" + }, + "testRunner": "xunit", + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0-*", + "type": "platform" } + } } + } } From c51aec52926240097be00977c88dd20b0c55c4e7 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Fri, 19 Aug 2016 15:22:20 -0700 Subject: [PATCH 233/453] port dotnet/corefx#10792 (#111) * port dotnet/corefx#10792 * add EchoApp sample --- WebSockets.sln | 24 ++- samples/EchoApp/EchoApp.xproj | 25 +++ samples/EchoApp/Program.cs | 24 +++ .../EchoApp/Properties/launchSettings.json | 27 ++++ samples/EchoApp/Startup.cs | 75 +++++++++ samples/EchoApp/project.json | 49 ++++++ samples/EchoApp/web.config | 14 ++ samples/EchoApp/wwwroot/index.html | 151 ++++++++++++++++++ scripts/UpdateCoreFxCode.ps1 | 8 - .../Net/WebSockets/WebSocketValidate.cs | 2 - .../System/Net/WebSockets/ManagedWebSocket.cs | 11 +- 11 files changed, 387 insertions(+), 23 deletions(-) create mode 100644 samples/EchoApp/EchoApp.xproj create mode 100644 samples/EchoApp/Program.cs create mode 100644 samples/EchoApp/Properties/launchSettings.json create mode 100644 samples/EchoApp/Startup.cs create mode 100644 samples/EchoApp/project.json create mode 100644 samples/EchoApp/web.config create mode 100644 samples/EchoApp/wwwroot/index.html diff --git a/WebSockets.sln b/WebSockets.sln index b755faab40..95d00d84a4 100644 --- a/WebSockets.sln +++ b/WebSockets.sln @@ -32,7 +32,11 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSoc EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.ConformanceTest", "test\Microsoft.AspNetCore.WebSockets.ConformanceTest\Microsoft.AspNetCore.WebSockets.ConformanceTest.xproj", "{74F45408-1959-4FEE-9511-25D40F4913FD}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestClient", "samples\TestClient\TestClient.xproj", "{8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Server.Kestrel", "..\KestrelHttpServer\src\Microsoft.AspNetCore.Server.Kestrel\Microsoft.AspNetCore.Server.Kestrel.xproj", "{F510611A-3BEE-4B88-A613-5F4A74ED82A1}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Server.Kestrel.Https", "..\KestrelHttpServer\src\Microsoft.AspNetCore.Server.Kestrel.Https\Microsoft.AspNetCore.Server.Kestrel.Https.xproj", "{5F64B3C3-0C2E-431A-B820-A81BBFC863DA}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "EchoApp", "samples\EchoApp\EchoApp.xproj", "{421954B0-5C6B-4092-8D4D-EACA4CE60AFB}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -68,10 +72,18 @@ Global {74F45408-1959-4FEE-9511-25D40F4913FD}.Debug|Any CPU.Build.0 = Debug|Any CPU {74F45408-1959-4FEE-9511-25D40F4913FD}.Release|Any CPU.ActiveCfg = Release|Any CPU {74F45408-1959-4FEE-9511-25D40F4913FD}.Release|Any CPU.Build.0 = Release|Any CPU - {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9}.Release|Any CPU.Build.0 = Release|Any CPU + {F510611A-3BEE-4B88-A613-5F4A74ED82A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F510611A-3BEE-4B88-A613-5F4A74ED82A1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F510611A-3BEE-4B88-A613-5F4A74ED82A1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F510611A-3BEE-4B88-A613-5F4A74ED82A1}.Release|Any CPU.Build.0 = Release|Any CPU + {5F64B3C3-0C2E-431A-B820-A81BBFC863DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5F64B3C3-0C2E-431A-B820-A81BBFC863DA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5F64B3C3-0C2E-431A-B820-A81BBFC863DA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5F64B3C3-0C2E-431A-B820-A81BBFC863DA}.Release|Any CPU.Build.0 = Release|Any CPU + {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -84,6 +96,6 @@ Global {CDE16880-0374-46FA-8896-99F1B90B4B6F} = {2C7947A5-9FBD-4267-97C1-2D726D7B3BAF} {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF} = {C45106D0-76C8-4776-A140-F7DD83CA2958} {74F45408-1959-4FEE-9511-25D40F4913FD} = {C45106D0-76C8-4776-A140-F7DD83CA2958} - {8C8EAC01-DC49-4C5E-B348-E4E46FE675F9} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} + {421954B0-5C6B-4092-8D4D-EACA4CE60AFB} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} EndGlobalSection EndGlobal diff --git a/samples/EchoApp/EchoApp.xproj b/samples/EchoApp/EchoApp.xproj new file mode 100644 index 0000000000..687dae372a --- /dev/null +++ b/samples/EchoApp/EchoApp.xproj @@ -0,0 +1,25 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + 421954b0-5c6b-4092-8d4d-eaca4ce60afb + EchoApp + .\obj + .\bin\ + v4.6.1 + + + + 2.0 + + + + + + + diff --git a/samples/EchoApp/Program.cs b/samples/EchoApp/Program.cs new file mode 100644 index 0000000000..2775a095ce --- /dev/null +++ b/samples/EchoApp/Program.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; + +namespace EchoApp +{ + public class Program + { + public static void Main(string[] args) + { + var host = new WebHostBuilder() + .UseKestrel() + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup() + .Build(); + + host.Run(); + } + } +} diff --git a/samples/EchoApp/Properties/launchSettings.json b/samples/EchoApp/Properties/launchSettings.json new file mode 100644 index 0000000000..a9b371ff56 --- /dev/null +++ b/samples/EchoApp/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:3159/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "EchoApp": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/samples/EchoApp/Startup.cs b/samples/EchoApp/Startup.cs new file mode 100644 index 0000000000..ee3fb0ee91 --- /dev/null +++ b/samples/EchoApp/Startup.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.WebSockets; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace EchoApp +{ + public class Startup + { + // This method gets called by the runtime. Use this method to add services to the container. + // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 + public void ConfigureServices(IServiceCollection services) + { + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + { + loggerFactory.AddConsole(); + + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseWebSockets(); + + app.Use(async (context, next) => + { + if (context.WebSockets.IsWebSocketRequest) + { + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + await Echo(webSocket); + } + else + { + await next(); + } + }); + + app.UseFileServer(); + } + + private async Task Echo(WebSocket webSocket) + { + var buffer = new byte[1024 * 4]; + var result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); + while (!result.CloseStatus.HasValue) + { + // If the client send "ServerClose", then they want a server-originated close to occur + if(result.MessageType == WebSocketMessageType.Text) + { + var str = Encoding.UTF8.GetString(buffer, 0, result.Count); + if(str.Equals("ServerClose")) + { + await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Closing from Server", CancellationToken.None); + return; + } + } + + await webSocket.SendAsync(new ArraySegment(buffer, 0, result.Count), result.MessageType, result.EndOfMessage, CancellationToken.None); + result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); + } + await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + } + } +} diff --git a/samples/EchoApp/project.json b/samples/EchoApp/project.json new file mode 100644 index 0000000000..5e7ef03dc7 --- /dev/null +++ b/samples/EchoApp/project.json @@ -0,0 +1,49 @@ +{ + "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0", + "type": "platform" + }, + "Microsoft.AspNetCore.Diagnostics": "1.1.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", + "Microsoft.Extensions.Logging.Console": "1.1.0-*", + "Microsoft.AspNetCore.StaticFiles": "1.1.0-*", + "Microsoft.AspNetCore.WebSockets": "0.2.0-*" + }, + + "tools": { + "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" + }, + + "frameworks": { + "netcoreapp1.0": { + "imports": [ + "dotnet5.6", + "portable-net45+win8" + ] + } + }, + + "buildOptions": { + "emitEntryPoint": true, + "preserveCompilationContext": true + }, + + "runtimeOptions": { + "configProperties": { + "System.GC.Server": true + } + }, + + "publishOptions": { + "include": [ + "wwwroot", + "web.config" + ] + }, + + "scripts": { + "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] + } +} diff --git a/samples/EchoApp/web.config b/samples/EchoApp/web.config new file mode 100644 index 0000000000..dc0514fca5 --- /dev/null +++ b/samples/EchoApp/web.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/samples/EchoApp/wwwroot/index.html b/samples/EchoApp/wwwroot/index.html new file mode 100644 index 0000000000..d80fd3b907 --- /dev/null +++ b/samples/EchoApp/wwwroot/index.html @@ -0,0 +1,151 @@ + + + + + + + + +

WebSocket Test Page

+

Ready to connect...

+
+ + + +
+
+ + + + +
+ +

Note: When connected to the default server (i.e. the server in the address bar ;)), the message "ServerClose" will cause the server to close the connection

+ +

Communication Log

+ + + + + + + + + + +
FromToData
+ + + + \ No newline at end of file diff --git a/scripts/UpdateCoreFxCode.ps1 b/scripts/UpdateCoreFxCode.ps1 index c6e2be846a..d94e04a161 100644 --- a/scripts/UpdateCoreFxCode.ps1 +++ b/scripts/UpdateCoreFxCode.ps1 @@ -34,15 +34,7 @@ $FilesToCopy | foreach { } Write-Host "Copying $_" - # The trailing blank line is important! - $Pragmas = @" -#pragma warning disable 1572 -#pragma warning disable 1573 - -"@; - $SourceCode = [IO.File]::ReadAllText($Source) - $SourceCode = $Pragmas + $SourceCode $SourceCode = $SourceCode.Replace("Task.FromException", "CompatHelpers.FromException") $SourceCode = $SourceCode.Replace("Task.CompletedTask", "CompatHelpers.CompletedTask") $SourceCode = $SourceCode.Replace("Array.Empty", "CompatHelpers.Empty") diff --git a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs index 284b9ee0b4..06e07f29dd 100644 --- a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs +++ b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs @@ -1,5 +1,3 @@ -#pragma warning disable 1572 -#pragma warning disable 1573 // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. diff --git a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ManagedWebSocket.cs b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ManagedWebSocket.cs index 5b6f1e94da..322997f1d1 100644 --- a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ManagedWebSocket.cs +++ b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ManagedWebSocket.cs @@ -1,5 +1,3 @@ -#pragma warning disable 1572 -#pragma warning disable 1573 // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. @@ -32,7 +30,6 @@ namespace System.Net.WebSockets /// The connected Stream. /// true if this is the server-side of the connection; false if this is the client-side of the connection. /// The agreed upon subprotocol for the connection. - /// The current state of the websocket connection. /// The interval to use for keep-alive pings. /// The buffer size to use for received data. /// The created instance. @@ -879,7 +876,7 @@ namespace System.Net.WebSockets } /// Parses a message header from the buffer. This assumes the header is in the buffer. - /// The read header. + /// The read header. /// true if a header was read; false if the header was invalid. private bool TryParseMessageHeaderFromReceiveBuffer(out MessageHeader resultHeader) { @@ -1037,7 +1034,7 @@ namespace System.Net.WebSockets /// Sends a close message to the server. /// The close status to send. - /// The close status description to send. + /// The close status description to send. /// The CancellationToken to use to cancel the websocket. private async Task SendCloseFrameAsync(WebSocketCloseStatus closeStatus, string closeStatusDescription, CancellationToken cancellationToken) { @@ -1153,9 +1150,9 @@ namespace System.Net.WebSockets /// The buffer to which the mask should be applied. /// The offset into at which the mask should start to be applied. /// The four-byte mask, stored as an Int32. - /// The index into the mas + /// The index into the mask. /// The number of bytes to mask. - /// + /// The next index into the mask to be used for future applications of the mask. private static unsafe int ApplyMask(byte[] toMask, int toMaskOffset, int mask, int maskIndex, long count) { Debug.Assert(toMaskOffset <= toMask.Length - count, $"Unexpected inputs: {toMaskOffset}, {toMask.Length}, {count}"); From b996ee39a429479e0bc301d198007cd85cc2acbd Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Fri, 2 Sep 2016 14:02:06 -0700 Subject: [PATCH 234/453] port dotnet/corefx#11348 (#114) also adds some tests and extra features to the EchoApp test sample --- samples/EchoApp/Startup.cs | 42 ++++++++++++-- samples/EchoApp/wwwroot/index.html | 2 +- .../System/Net/WebSockets/ManagedWebSocket.cs | 7 +-- .../BufferStream.cs | 19 +++++++ .../DuplexStream.cs | 57 ++++++++++--------- .../SendReceiveTests.cs | 30 ++++++++++ .../WebSocketPair.cs | 8 ++- 7 files changed, 123 insertions(+), 42 deletions(-) diff --git a/samples/EchoApp/Startup.cs b/samples/EchoApp/Startup.cs index ee3fb0ee91..729716693c 100644 --- a/samples/EchoApp/Startup.cs +++ b/samples/EchoApp/Startup.cs @@ -24,7 +24,7 @@ namespace EchoApp // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { - loggerFactory.AddConsole(); + loggerFactory.AddConsole(LogLevel.Debug); if (env.IsDevelopment()) { @@ -38,7 +38,7 @@ namespace EchoApp if (context.WebSockets.IsWebSocketRequest) { var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - await Echo(webSocket); + await Echo(context, webSocket, loggerFactory.CreateLogger("Echo")); } else { @@ -49,27 +49,57 @@ namespace EchoApp app.UseFileServer(); } - private async Task Echo(WebSocket webSocket) + private async Task Echo(HttpContext context, WebSocket webSocket, ILogger logger) { var buffer = new byte[1024 * 4]; var result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); + LogFrame(logger, result, buffer); while (!result.CloseStatus.HasValue) { // If the client send "ServerClose", then they want a server-originated close to occur - if(result.MessageType == WebSocketMessageType.Text) + string content = "<>"; + if (result.MessageType == WebSocketMessageType.Text) { - var str = Encoding.UTF8.GetString(buffer, 0, result.Count); - if(str.Equals("ServerClose")) + content = Encoding.UTF8.GetString(buffer, 0, result.Count); + if (content.Equals("ServerClose")) { await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Closing from Server", CancellationToken.None); + logger.LogDebug($"Sent Frame Close: {WebSocketCloseStatus.NormalClosure} Closing from Server"); return; } + else if (content.Equals("ServerAbort")) + { + context.Abort(); + } } await webSocket.SendAsync(new ArraySegment(buffer, 0, result.Count), result.MessageType, result.EndOfMessage, CancellationToken.None); + logger.LogDebug($"Sent Frame {result.MessageType}: Len={result.Count}, Fin={result.EndOfMessage}: {content}"); + result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); + LogFrame(logger, result, buffer); } await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); } + + private void LogFrame(ILogger logger, WebSocketReceiveResult frame, byte[] buffer) + { + var close = frame.CloseStatus != null; + string message; + if (close) + { + message = $"Close: {frame.CloseStatus.Value} {frame.CloseStatusDescription}"; + } + else + { + string content = "<>"; + if (frame.MessageType == WebSocketMessageType.Text) + { + content = Encoding.UTF8.GetString(buffer, 0, frame.Count); + } + message = $"{frame.MessageType}: Len={frame.Count}, Fin={frame.EndOfMessage}: {content}"; + } + logger.LogDebug("Received Frame " + message); + } } } diff --git a/samples/EchoApp/wwwroot/index.html b/samples/EchoApp/wwwroot/index.html index d80fd3b907..1663600a5e 100644 --- a/samples/EchoApp/wwwroot/index.html +++ b/samples/EchoApp/wwwroot/index.html @@ -25,7 +25,7 @@ -

Note: When connected to the default server (i.e. the server in the address bar ;)), the message "ServerClose" will cause the server to close the connection

+

Note: When connected to the default server (i.e. the server in the address bar ;)), the message "ServerClose" will cause the server to close the connection. Similarly, the message "ServerAbort" will cause the server to forcibly terminate the connection without a closing handshake

Communication Log

diff --git a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ManagedWebSocket.cs b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ManagedWebSocket.cs index 322997f1d1..8253aebde5 100644 --- a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ManagedWebSocket.cs +++ b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ManagedWebSocket.cs @@ -615,12 +615,7 @@ namespace System.Net.WebSockets // Make sure we have the first two bytes, which includes the start of the payload length. if (_receiveBufferCount < 2) { - await EnsureBufferContainsAsync(2, cancellationToken, throwOnPrematureClosure: false).ConfigureAwait(false); - if (_receiveBufferCount < 2) - { - // The connection closed; nothing more to read. - return new WebSocketReceiveResult(0, WebSocketMessageType.Text, true); - } + await EnsureBufferContainsAsync(2, cancellationToken, throwOnPrematureClosure: true).ConfigureAwait(false); } // Then make sure we have the full header based on the payload length. diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs b/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs index 61a6699034..acbaa723cc 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs @@ -16,6 +16,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test { private bool _disposed; private bool _aborted; + private bool _terminated; private Exception _abortException; private ConcurrentQueue _bufferedData; private ArraySegment _topBuffer; @@ -71,6 +72,14 @@ namespace Microsoft.AspNetCore.WebSockets.Test #endregion NotSupported + /// + /// Ends the stream, meaning all future reads will return '0'. + /// + public void End() + { + _terminated = true; + } + public override void Flush() { CheckDisposed(); @@ -95,6 +104,11 @@ namespace Microsoft.AspNetCore.WebSockets.Test public override int Read(byte[] buffer, int offset, int count) { + if(_terminated) + { + return 0; + } + VerifyBuffer(buffer, offset, count, allowEmpty: false); _readLock.Wait(); try @@ -154,6 +168,11 @@ namespace Microsoft.AspNetCore.WebSockets.Test public async override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { + if(_terminated) + { + return 0; + } + VerifyBuffer(buffer, offset, count, allowEmpty: false); CancellationTokenRegistration registration = cancellationToken.Register(Abort); await _readLock.WaitAsync(cancellationToken); diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs b/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs index 528b20466e..0c3c4e0877 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs @@ -10,30 +10,31 @@ namespace Microsoft.AspNetCore.WebSockets.Test // A duplex wrapper around a read and write stream. public class DuplexStream : Stream { - private readonly Stream _readStream; - private readonly Stream _writeStream; + public BufferStream ReadStream { get; } + public BufferStream WriteStream { get; } public DuplexStream() : this (new BufferStream(), new BufferStream()) { } - public DuplexStream(Stream readStream, Stream writeStream) + public DuplexStream(BufferStream readStream, BufferStream writeStream) { - _readStream = readStream; - _writeStream = writeStream; + ReadStream = readStream; + WriteStream = writeStream; } public DuplexStream CreateReverseDuplexStream() { - return new DuplexStream(_writeStream, _readStream); + return new DuplexStream(WriteStream, ReadStream); } + #region Properties public override bool CanRead { - get { return _readStream.CanRead; } + get { return ReadStream.CanRead; } } public override bool CanSeek @@ -43,12 +44,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test public override bool CanTimeout { - get { return _readStream.CanTimeout || _writeStream.CanTimeout; } + get { return ReadStream.CanTimeout || WriteStream.CanTimeout; } } public override bool CanWrite { - get { return _writeStream.CanWrite; } + get { return WriteStream.CanWrite; } } public override long Length @@ -64,14 +65,14 @@ namespace Microsoft.AspNetCore.WebSockets.Test public override int ReadTimeout { - get { return _readStream.ReadTimeout; } - set { _readStream.ReadTimeout = value; } + get { return ReadStream.ReadTimeout; } + set { ReadStream.ReadTimeout = value; } } public override int WriteTimeout { - get { return _writeStream.WriteTimeout; } - set { _writeStream.WriteTimeout = value; } + get { return WriteStream.WriteTimeout; } + set { WriteStream.WriteTimeout = value; } } #endregion Properties @@ -90,33 +91,33 @@ namespace Microsoft.AspNetCore.WebSockets.Test public override int Read(byte[] buffer, int offset, int count) { - return _readStream.Read(buffer, offset, count); + return ReadStream.Read(buffer, offset, count); } #if !NETCOREAPP1_0 public override int ReadByte() { - return _readStream.ReadByte(); + return ReadStream.ReadByte(); } public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { - return _readStream.BeginRead(buffer, offset, count, callback, state); + return ReadStream.BeginRead(buffer, offset, count, callback, state); } public override int EndRead(IAsyncResult asyncResult) { - return _readStream.EndRead(asyncResult); + return ReadStream.EndRead(asyncResult); } public override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { - return _readStream.ReadAsync(buffer, offset, count, cancellationToken); + return ReadStream.ReadAsync(buffer, offset, count, cancellationToken); } public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken) { - return _readStream.CopyToAsync(destination, bufferSize, cancellationToken); + return ReadStream.CopyToAsync(destination, bufferSize, cancellationToken); } #endif @@ -126,39 +127,39 @@ namespace Microsoft.AspNetCore.WebSockets.Test public override void Write(byte[] buffer, int offset, int count) { - _writeStream.Write(buffer, offset, count); + WriteStream.Write(buffer, offset, count); } #if !NETCOREAPP1_0 public override void WriteByte(byte value) { - _writeStream.WriteByte(value); + WriteStream.WriteByte(value); } public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { - return _writeStream.BeginWrite(buffer, offset, count, callback, state); + return WriteStream.BeginWrite(buffer, offset, count, callback, state); } public override void EndWrite(IAsyncResult asyncResult) { - _writeStream.EndWrite(asyncResult); + WriteStream.EndWrite(asyncResult); } public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { - return _writeStream.WriteAsync(buffer, offset, count, cancellationToken); + return WriteStream.WriteAsync(buffer, offset, count, cancellationToken); } public override Task FlushAsync(CancellationToken cancellationToken) { - return _writeStream.FlushAsync(cancellationToken); + return WriteStream.FlushAsync(cancellationToken); } #endif public override void Flush() { - _writeStream.Flush(); + WriteStream.Flush(); } #endregion Write @@ -167,8 +168,8 @@ namespace Microsoft.AspNetCore.WebSockets.Test { if (disposing) { - _readStream.Dispose(); - _writeStream.Dispose(); + ReadStream.Dispose(); + WriteStream.Dispose(); } base.Dispose(disposing); } diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/SendReceiveTests.cs b/test/Microsoft.AspNetCore.WebSockets.Test/SendReceiveTests.cs index 9580b7faad..afa9f70741 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/SendReceiveTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/SendReceiveTests.cs @@ -73,5 +73,35 @@ namespace Microsoft.AspNetCore.WebSockets.Test Assert.Equal(WebSocketMessageType.Binary, result.MessageType); Assert.Equal(sendBuffer, receiveBuffer.Take(result.Count).ToArray()); } + + [Fact] + public async Task ThrowsWhenUnderlyingStreamClosed() + { + var pair = WebSocketPair.Create(); + var sendBuffer = new byte[] { 0xde, 0xad, 0xbe, 0xef }; + + await pair.ServerSocket.SendAsync(new ArraySegment(sendBuffer), WebSocketMessageType.Binary, endOfMessage: true, cancellationToken: CancellationToken.None); + + var receiveBuffer = new byte[32]; + var result = await pair.ClientSocket.ReceiveAsync(new ArraySegment(receiveBuffer), CancellationToken.None); + + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + // Close the client socket's read end + pair.ClientStream.ReadStream.End(); + + // Assert.Throws doesn't support async :( + try + { + await pair.ClientSocket.ReceiveAsync(new ArraySegment(receiveBuffer), CancellationToken.None); + + // The exception should prevent this line from running + Assert.False(true, "Expected an exception to be thrown!"); + } + catch (WebSocketException ex) + { + Assert.Equal(WebSocketError.ConnectionClosedPrematurely, ex.WebSocketErrorCode); + } + } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketPair.cs b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketPair.cs index 936371acdd..aded688e42 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketPair.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketPair.cs @@ -8,9 +8,13 @@ namespace Microsoft.AspNetCore.WebSockets.Test { public WebSocket ClientSocket { get; } public WebSocket ServerSocket { get; } + public DuplexStream ServerStream { get; } + public DuplexStream ClientStream { get; } - public WebSocketPair(WebSocket clientSocket, WebSocket serverSocket) + public WebSocketPair(DuplexStream serverStream, DuplexStream clientStream, WebSocket clientSocket, WebSocket serverSocket) { + ClientStream = clientStream; + ServerStream = serverStream; ClientSocket = clientSocket; ServerSocket = serverSocket; } @@ -22,6 +26,8 @@ namespace Microsoft.AspNetCore.WebSockets.Test var clientStream = serverStream.CreateReverseDuplexStream(); return new WebSocketPair( + serverStream, + clientStream, clientSocket: WebSocketFactory.CreateClientWebSocket(clientStream, null, TimeSpan.FromMinutes(2), 1024), serverSocket: WebSocketFactory.CreateServerWebSocket(serverStream, null, TimeSpan.FromMinutes(2), 1024)); } From 4e2ecf8a63b9fc78175d1ef62bf2b1918b8b3986 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Sun, 4 Sep 2016 19:15:00 -0700 Subject: [PATCH 235/453] Increase .travis.yml consistency between repos - aspnet/Universe#349 - minimize `dotnet` setup time; no need for caching - `KOREBUILD_DNU_RESTORE_CORECLR` env variable isn't used anymore - no need for libuv v1.4.2 w/ current Kestrel packages --- .travis.yml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3b4056f4a2..3439636a23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,16 +11,9 @@ addons: - libunwind8 - zlib1g env: - - KOREBUILD_DNU_RESTORE_CORECLR=true -install: - - curl -sSL https://github.com/libuv/libuv/archive/v1.4.2.tar.gz | tar zxfv - -C /tmp && cd /tmp/libuv-1.4.2/ - - sh autogen.sh - - ./configure --prefix=$HOME/libuvinstall - - make - - make install - - export LD_LIBRARY_PATH="$HOME/libuvinstall/lib" - - cd $OLDPWD - - sudo pip install autobahntestsuite "six>=1.9.0" + global: + - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + - DOTNET_CLI_TELEMETRY_OPTOUT: 1 mono: - 4.0.5 python: @@ -37,5 +30,7 @@ branches: - /^(.*\/)?ci-.*$/ before_install: - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl python; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi +install: + - sudo pip install autobahntestsuite "six>=1.9.0" script: - ./build.sh --quiet verify From 60ab3bcaf3f2234b25223aa7978e522d31befeae Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 19 Sep 2016 13:36:38 -0700 Subject: [PATCH 236/453] React to WebListener version change --- test/AutobahnTestApp/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/AutobahnTestApp/project.json b/test/AutobahnTestApp/project.json index 2269497e8a..502c30ec77 100644 --- a/test/AutobahnTestApp/project.json +++ b/test/AutobahnTestApp/project.json @@ -9,7 +9,7 @@ "Microsoft.AspNetCore.Diagnostics": "1.1.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", - "Microsoft.AspNetCore.Server.WebListener": "0.2.0-*", + "Microsoft.AspNetCore.Server.WebListener": "1.1.0-*", "Microsoft.AspNetCore.Server.Kestrel.Https": "1.1.0-*", "Microsoft.Extensions.Configuration.CommandLine": "1.1.0-*", "Microsoft.Extensions.Logging.Console": "1.1.0-*" From b8471455a746a935d9009284a773eb2567a71b4c Mon Sep 17 00:00:00 2001 From: Martin Andreas Ullrich Date: Mon, 3 Oct 2016 18:56:14 +0200 Subject: [PATCH 237/453] Fix NuGet project description ASP.NET 5 > Core (#120) changed leftover "ASP.NET 5" in project.json description to "ASP.NET Core" --- src/Microsoft.AspNetCore.WebSockets/project.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.WebSockets/project.json b/src/Microsoft.AspNetCore.WebSockets/project.json index 5364d0e805..beba589e2d 100644 --- a/src/Microsoft.AspNetCore.WebSockets/project.json +++ b/src/Microsoft.AspNetCore.WebSockets/project.json @@ -9,7 +9,7 @@ "xmlDoc": true, "allowUnsafe": true }, - "description": "ASP.NET 5 web socket middleware for use on top of opaque servers.", + "description": "ASP.NET Core web socket middleware for use on top of opaque servers.", "packOptions": { "repository": { "type": "git", @@ -29,4 +29,4 @@ } } } -} \ No newline at end of file +} From 35cae5da7d5de784b1e99cf95b6716ee12bdf831 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 28 Sep 2016 11:53:03 -0700 Subject: [PATCH 238/453] Updating partner package versions --- samples/EchoApp/project.json | 24 +++++------ .../project.json | 12 ++---- test/AutobahnTestApp/project.json | 43 ++++++++----------- .../project.json | 6 +-- .../project.json | 10 ++--- 5 files changed, 41 insertions(+), 54 deletions(-) diff --git a/samples/EchoApp/project.json b/samples/EchoApp/project.json index 5e7ef03dc7..990775d3f8 100644 --- a/samples/EchoApp/project.json +++ b/samples/EchoApp/project.json @@ -1,21 +1,19 @@ { "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.0.0", - "type": "platform" - }, "Microsoft.AspNetCore.Diagnostics": "1.1.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", - "Microsoft.Extensions.Logging.Console": "1.1.0-*", "Microsoft.AspNetCore.StaticFiles": "1.1.0-*", - "Microsoft.AspNetCore.WebSockets": "0.2.0-*" + "Microsoft.AspNetCore.WebSockets": "0.2.0-*", + "Microsoft.Extensions.Logging.Console": "1.1.0-*", + "Microsoft.NETCore.App": { + "version": "1.1.0-*", + "type": "platform" + } }, - "tools": { "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" }, - "frameworks": { "netcoreapp1.0": { "imports": [ @@ -24,26 +22,24 @@ ] } }, - "buildOptions": { "emitEntryPoint": true, "preserveCompilationContext": true }, - "runtimeOptions": { "configProperties": { "System.GC.Server": true } }, - "publishOptions": { "include": [ "wwwroot", "web.config" ] }, - "scripts": { - "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] + "postpublish": [ + "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" + ] } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets/project.json b/src/Microsoft.AspNetCore.WebSockets/project.json index beba589e2d..07dd58da57 100644 --- a/src/Microsoft.AspNetCore.WebSockets/project.json +++ b/src/Microsoft.AspNetCore.WebSockets/project.json @@ -18,15 +18,11 @@ }, "dependencies": { "Microsoft.AspNetCore.Http.Extensions": "1.1.0-*", - "Microsoft.Extensions.Options": "1.1.0-*" + "Microsoft.Extensions.Options": "1.1.0-*", + "NETStandard.Library": "1.6.1-*" }, "frameworks": { "net451": {}, - "netstandard1.3": { - "dependencies": { - "System.Text.Encoding.Extensions": "4.0.11", - "System.Threading.Timer": "4.0.1" - } - } + "netstandard1.3": {} } -} +} \ No newline at end of file diff --git a/test/AutobahnTestApp/project.json b/test/AutobahnTestApp/project.json index 502c30ec77..b79080e5df 100644 --- a/test/AutobahnTestApp/project.json +++ b/test/AutobahnTestApp/project.json @@ -1,24 +1,21 @@ -{ - "dependencies": { - "Microsoft.AspNetCore.WebSockets": "0.2.0-*", - "Microsoft.NETCore.App": { - "version": "1.0.0", - "type": "platform" - }, - - "Microsoft.AspNetCore.Diagnostics": "1.1.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", - "Microsoft.AspNetCore.Server.WebListener": "1.1.0-*", - "Microsoft.AspNetCore.Server.Kestrel.Https": "1.1.0-*", - "Microsoft.Extensions.Configuration.CommandLine": "1.1.0-*", - "Microsoft.Extensions.Logging.Console": "1.1.0-*" - }, - +{ + "dependencies": { + "Microsoft.AspNetCore.Diagnostics": "1.1.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", + "Microsoft.AspNetCore.Server.Kestrel.Https": "1.1.0-*", + "Microsoft.AspNetCore.Server.WebListener": "1.1.0-*", + "Microsoft.AspNetCore.WebSockets": "0.2.0-*", + "Microsoft.Extensions.Configuration.CommandLine": "1.1.0-*", + "Microsoft.Extensions.Logging.Console": "1.1.0-*", + "Microsoft.NETCore.App": { + "version": "1.1.0-*", + "type": "platform" + } + }, "tools": { "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" }, - "frameworks": { "netcoreapp1.0": { "imports": [ @@ -27,20 +24,17 @@ ] } }, - "buildOptions": { "emitEntryPoint": true, "copyToOutput": [ "TestResources/testCert.pfx" ] }, - "runtimeOptions": { "configProperties": { "System.GC.Server": true } }, - "publishOptions": { "include": [ "wwwroot", @@ -48,8 +42,9 @@ "TestResources/testCert.pfx" ] }, - "scripts": { - "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] + "postpublish": [ + "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" + ] } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json index 8f3b299b5c..25933baef1 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json @@ -6,7 +6,7 @@ "Microsoft.Extensions.Logging": "1.1.0-*", "Microsoft.Extensions.Logging.Console": "1.1.0-*", "Microsoft.Extensions.PlatformAbstractions": "1.1.0-*", - "System.Diagnostics.FileVersionInfo": "4.0.0", + "System.Diagnostics.FileVersionInfo": "4.3.0-*", "xunit": "2.2.0-*" }, "testRunner": "xunit", @@ -14,10 +14,10 @@ "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.0.0-*", + "version": "1.1.0-*", "type": "platform" } } } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Test/project.json index ee1dcaccef..ea4b86b9a8 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Test/project.json @@ -1,9 +1,9 @@ { "dependencies": { "dotnet-test-xunit": "2.2.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", "Microsoft.AspNetCore.Testing": "1.1.0-*", "Microsoft.AspNetCore.WebSockets": "0.2.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", "xunit": "2.2.0-*" }, "testRunner": "xunit", @@ -11,12 +11,12 @@ "net451": {}, "netcoreapp1.0": { "dependencies": { - "System.Net.WebSockets.Client": "4.0.0", "Microsoft.NETCore.App": { - "version": "1.0.0-*", + "version": "1.1.0-*", "type": "platform" - } + }, + "System.Net.WebSockets.Client": "4.3.0-*" } } } -} +} \ No newline at end of file From 09802d1ded17fd3717a7eabe4b20e9fc97ff3a81 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 12 Oct 2016 13:46:55 -0700 Subject: [PATCH 239/453] Updating to netcoreapp1.1 --- samples/EchoApp/project.json | 2 +- test/AutobahnTestApp/project.json | 2 +- .../project.json | 2 +- test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs | 6 +++--- test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs | 6 +++--- test/Microsoft.AspNetCore.WebSockets.Test/project.json | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/samples/EchoApp/project.json b/samples/EchoApp/project.json index 990775d3f8..25ffd7b862 100644 --- a/samples/EchoApp/project.json +++ b/samples/EchoApp/project.json @@ -15,7 +15,7 @@ "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" }, "frameworks": { - "netcoreapp1.0": { + "netcoreapp1.1": { "imports": [ "dotnet5.6", "portable-net45+win8" diff --git a/test/AutobahnTestApp/project.json b/test/AutobahnTestApp/project.json index b79080e5df..5dbc7b22f5 100644 --- a/test/AutobahnTestApp/project.json +++ b/test/AutobahnTestApp/project.json @@ -17,7 +17,7 @@ "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" }, "frameworks": { - "netcoreapp1.0": { + "netcoreapp1.1": { "imports": [ "dotnet5.6", "portable-net45+win8" diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json index 25933baef1..526a646659 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json @@ -11,7 +11,7 @@ }, "testRunner": "xunit", "frameworks": { - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs b/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs index acbaa723cc..9b9a82f250 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. +// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. using System; using System.Collections.Concurrent; @@ -152,7 +152,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test } } -#if !NETCOREAPP1_0 +#if !NETCOREAPP1_1 public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { // TODO: This option doesn't preserve the state object. @@ -245,7 +245,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test } } -#if !NETCOREAPP1_0 +#if !NETCOREAPP1_1 public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { Write(buffer, offset, count); diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs b/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs index 0c3c4e0877..11f65759cc 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. +// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. using System; using System.IO; @@ -94,7 +94,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test return ReadStream.Read(buffer, offset, count); } -#if !NETCOREAPP1_0 +#if !NETCOREAPP1_1 public override int ReadByte() { return ReadStream.ReadByte(); @@ -130,7 +130,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test WriteStream.Write(buffer, offset, count); } -#if !NETCOREAPP1_0 +#if !NETCOREAPP1_1 public override void WriteByte(byte value) { WriteStream.WriteByte(value); diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Test/project.json index ea4b86b9a8..900cfd618d 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Test/project.json @@ -9,7 +9,7 @@ "testRunner": "xunit", "frameworks": { "net451": {}, - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", From cf75df802d3144c500108723a05acfcf5ed206a8 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 12 Oct 2016 16:10:08 -0700 Subject: [PATCH 240/453] Revert "Updating to netcoreapp1.1" This reverts commit 09802d1ded17fd3717a7eabe4b20e9fc97ff3a81. --- samples/EchoApp/project.json | 2 +- test/AutobahnTestApp/project.json | 2 +- .../project.json | 2 +- test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs | 6 +++--- test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs | 6 +++--- test/Microsoft.AspNetCore.WebSockets.Test/project.json | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/samples/EchoApp/project.json b/samples/EchoApp/project.json index 25ffd7b862..990775d3f8 100644 --- a/samples/EchoApp/project.json +++ b/samples/EchoApp/project.json @@ -15,7 +15,7 @@ "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" }, "frameworks": { - "netcoreapp1.1": { + "netcoreapp1.0": { "imports": [ "dotnet5.6", "portable-net45+win8" diff --git a/test/AutobahnTestApp/project.json b/test/AutobahnTestApp/project.json index 5dbc7b22f5..b79080e5df 100644 --- a/test/AutobahnTestApp/project.json +++ b/test/AutobahnTestApp/project.json @@ -17,7 +17,7 @@ "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" }, "frameworks": { - "netcoreapp1.1": { + "netcoreapp1.0": { "imports": [ "dotnet5.6", "portable-net45+win8" diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json index 526a646659..25933baef1 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json @@ -11,7 +11,7 @@ }, "testRunner": "xunit", "frameworks": { - "netcoreapp1.1": { + "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs b/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs index 9b9a82f250..acbaa723cc 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. +// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. using System; using System.Collections.Concurrent; @@ -152,7 +152,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test } } -#if !NETCOREAPP1_1 +#if !NETCOREAPP1_0 public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { // TODO: This option doesn't preserve the state object. @@ -245,7 +245,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test } } -#if !NETCOREAPP1_1 +#if !NETCOREAPP1_0 public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { Write(buffer, offset, count); diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs b/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs index 11f65759cc..0c3c4e0877 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. +// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. using System; using System.IO; @@ -94,7 +94,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test return ReadStream.Read(buffer, offset, count); } -#if !NETCOREAPP1_1 +#if !NETCOREAPP1_0 public override int ReadByte() { return ReadStream.ReadByte(); @@ -130,7 +130,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test WriteStream.Write(buffer, offset, count); } -#if !NETCOREAPP1_1 +#if !NETCOREAPP1_0 public override void WriteByte(byte value) { WriteStream.WriteByte(value); diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Test/project.json index 900cfd618d..ea4b86b9a8 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Test/project.json @@ -9,7 +9,7 @@ "testRunner": "xunit", "frameworks": { "net451": {}, - "netcoreapp1.1": { + "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", From 49300ac5f7d130780c52e0d9005a16a383bc2fae Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 13 Oct 2016 11:26:43 -0700 Subject: [PATCH 241/453] Updating to netcoreapp1.1 --- samples/EchoApp/project.json | 2 +- test/AutobahnTestApp/project.json | 2 +- .../Autobahn/AutobahnTester.cs | 4 ++-- .../project.json | 2 +- test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs | 6 +++--- test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs | 6 +++--- test/Microsoft.AspNetCore.WebSockets.Test/project.json | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/samples/EchoApp/project.json b/samples/EchoApp/project.json index 990775d3f8..25ffd7b862 100644 --- a/samples/EchoApp/project.json +++ b/samples/EchoApp/project.json @@ -15,7 +15,7 @@ "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" }, "frameworks": { - "netcoreapp1.0": { + "netcoreapp1.1": { "imports": [ "dotnet5.6", "portable-net45+win8" diff --git a/test/AutobahnTestApp/project.json b/test/AutobahnTestApp/project.json index b79080e5df..5dbc7b22f5 100644 --- a/test/AutobahnTestApp/project.json +++ b/test/AutobahnTestApp/project.json @@ -17,7 +17,7 @@ "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" }, "frameworks": { - "netcoreapp1.0": { + "netcoreapp1.1": { "imports": [ "dotnet5.6", "portable-net45+win8" diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index dce4083ff7..19c305d091 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -97,7 +97,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { ApplicationBaseUriHint = baseUrl, ApplicationType = ApplicationType.Portable, - TargetFramework = "netcoreapp1.0", + TargetFramework = "netcoreapp1.1", EnvironmentName = environment }; diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json index 25933baef1..526a646659 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json @@ -11,7 +11,7 @@ }, "testRunner": "xunit", "frameworks": { - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs b/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs index acbaa723cc..9b9a82f250 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. +// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. using System; using System.Collections.Concurrent; @@ -152,7 +152,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test } } -#if !NETCOREAPP1_0 +#if !NETCOREAPP1_1 public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { // TODO: This option doesn't preserve the state object. @@ -245,7 +245,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test } } -#if !NETCOREAPP1_0 +#if !NETCOREAPP1_1 public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { Write(buffer, offset, count); diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs b/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs index 0c3c4e0877..11f65759cc 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. +// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. using System; using System.IO; @@ -94,7 +94,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test return ReadStream.Read(buffer, offset, count); } -#if !NETCOREAPP1_0 +#if !NETCOREAPP1_1 public override int ReadByte() { return ReadStream.ReadByte(); @@ -130,7 +130,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test WriteStream.Write(buffer, offset, count); } -#if !NETCOREAPP1_0 +#if !NETCOREAPP1_1 public override void WriteByte(byte value) { WriteStream.WriteByte(value); diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Test/project.json index ea4b86b9a8..900cfd618d 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Test/project.json @@ -9,7 +9,7 @@ "testRunner": "xunit", "frameworks": { "net451": {}, - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", From f8f38b94edc2a3d9bc848d69abd991f923a4af19 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 17 Oct 2016 09:50:00 -0700 Subject: [PATCH 242/453] Branching for 1.1.0-preview1 --- NuGet.config | 4 ++-- build.ps1 | 2 +- build.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/NuGet.config b/NuGet.config index e8b2884654..56387a5b6d 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + - + \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index 8f2f99691a..787f63ac02 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/1.1.0-preview1.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index f4208100eb..355c682856 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/1.1.0-preview1.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From 18de340981284fc198539cff65a65a4ef8c3b1a9 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 27 Oct 2016 15:49:58 -0700 Subject: [PATCH 243/453] fix disposal of Deployers during autobahn suites --- .gitignore | 2 ++ .../Autobahn/AutobahnTester.cs | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index d510684e27..3d89b9fce4 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,5 @@ project.lock.json .testPublish/ .build/ autobahnreports/ +*.nuget.props +*.nuget.targets \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index 19c305d091..4f5c0afbb5 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -103,6 +103,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn var deployer = ApplicationDeployerFactory.Create(parameters, logger); var result = deployer.Deploy(); + _deployers.Add(deployer); #if NET451 System.Net.ServicePointManager.ServerCertificateValidationCallback = (_, __, ___, ____) => true; @@ -130,8 +131,6 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn var wsUrl = result.ApplicationBaseUri.Replace("https://", "wss://").Replace("http://", "ws://"); Spec.WithServer(name, wsUrl); - _deployers.Add(deployer); - var expectations = new AutobahnExpectations(server, ssl, environment); expectationConfig?.Invoke(expectations); _expectations.Add(expectations); From 303f9ea2de3abdb880803e2ac0e8fa2fb488b3dc Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Sat, 29 Oct 2016 12:45:38 -0700 Subject: [PATCH 244/453] update version to prepare for 1.1 release (#125) * update version to prepare for 1.1 release * update projects that reference WebSockets --- WebSockets.sln | 12 ------------ samples/EchoApp/project.json | 2 +- src/Microsoft.AspNetCore.WebSockets/project.json | 2 +- test/AutobahnTestApp/project.json | 2 +- .../project.json | 2 +- 5 files changed, 4 insertions(+), 16 deletions(-) diff --git a/WebSockets.sln b/WebSockets.sln index 95d00d84a4..94f0f8e042 100644 --- a/WebSockets.sln +++ b/WebSockets.sln @@ -32,10 +32,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSoc EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.ConformanceTest", "test\Microsoft.AspNetCore.WebSockets.ConformanceTest\Microsoft.AspNetCore.WebSockets.ConformanceTest.xproj", "{74F45408-1959-4FEE-9511-25D40F4913FD}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Server.Kestrel", "..\KestrelHttpServer\src\Microsoft.AspNetCore.Server.Kestrel\Microsoft.AspNetCore.Server.Kestrel.xproj", "{F510611A-3BEE-4B88-A613-5F4A74ED82A1}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Server.Kestrel.Https", "..\KestrelHttpServer\src\Microsoft.AspNetCore.Server.Kestrel.Https\Microsoft.AspNetCore.Server.Kestrel.Https.xproj", "{5F64B3C3-0C2E-431A-B820-A81BBFC863DA}" -EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "EchoApp", "samples\EchoApp\EchoApp.xproj", "{421954B0-5C6B-4092-8D4D-EACA4CE60AFB}" EndProject Global @@ -72,14 +68,6 @@ Global {74F45408-1959-4FEE-9511-25D40F4913FD}.Debug|Any CPU.Build.0 = Debug|Any CPU {74F45408-1959-4FEE-9511-25D40F4913FD}.Release|Any CPU.ActiveCfg = Release|Any CPU {74F45408-1959-4FEE-9511-25D40F4913FD}.Release|Any CPU.Build.0 = Release|Any CPU - {F510611A-3BEE-4B88-A613-5F4A74ED82A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F510611A-3BEE-4B88-A613-5F4A74ED82A1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F510611A-3BEE-4B88-A613-5F4A74ED82A1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F510611A-3BEE-4B88-A613-5F4A74ED82A1}.Release|Any CPU.Build.0 = Release|Any CPU - {5F64B3C3-0C2E-431A-B820-A81BBFC863DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5F64B3C3-0C2E-431A-B820-A81BBFC863DA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5F64B3C3-0C2E-431A-B820-A81BBFC863DA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5F64B3C3-0C2E-431A-B820-A81BBFC863DA}.Release|Any CPU.Build.0 = Release|Any CPU {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Debug|Any CPU.Build.0 = Debug|Any CPU {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/samples/EchoApp/project.json b/samples/EchoApp/project.json index 25ffd7b862..c0acf84815 100644 --- a/samples/EchoApp/project.json +++ b/samples/EchoApp/project.json @@ -4,7 +4,7 @@ "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", "Microsoft.AspNetCore.StaticFiles": "1.1.0-*", - "Microsoft.AspNetCore.WebSockets": "0.2.0-*", + "Microsoft.AspNetCore.WebSockets": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.1.0-*", "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/src/Microsoft.AspNetCore.WebSockets/project.json b/src/Microsoft.AspNetCore.WebSockets/project.json index 07dd58da57..c1226b147f 100644 --- a/src/Microsoft.AspNetCore.WebSockets/project.json +++ b/src/Microsoft.AspNetCore.WebSockets/project.json @@ -1,5 +1,5 @@ { - "version": "0.2.0-*", + "version": "1.0.0-*", "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", diff --git a/test/AutobahnTestApp/project.json b/test/AutobahnTestApp/project.json index 5dbc7b22f5..250062275e 100644 --- a/test/AutobahnTestApp/project.json +++ b/test/AutobahnTestApp/project.json @@ -5,7 +5,7 @@ "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", "Microsoft.AspNetCore.Server.Kestrel.Https": "1.1.0-*", "Microsoft.AspNetCore.Server.WebListener": "1.1.0-*", - "Microsoft.AspNetCore.WebSockets": "0.2.0-*", + "Microsoft.AspNetCore.WebSockets": "1.0.0-*", "Microsoft.Extensions.Configuration.CommandLine": "1.1.0-*", "Microsoft.Extensions.Logging.Console": "1.1.0-*", "Microsoft.NETCore.App": { diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Test/project.json index 900cfd618d..3215ce5c62 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Test/project.json @@ -3,7 +3,7 @@ "dotnet-test-xunit": "2.2.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", "Microsoft.AspNetCore.Testing": "1.1.0-*", - "Microsoft.AspNetCore.WebSockets": "0.2.0-*", + "Microsoft.AspNetCore.WebSockets": "1.0.0-*", "xunit": "2.2.0-*" }, "testRunner": "xunit", From 68839d76e3283699e50aafd470f2eb6190195bfb Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Mon, 31 Oct 2016 14:04:20 -0700 Subject: [PATCH 245/453] allow 4.2.4 to have non-strict behavior (#128) --- .../AutobahnTests.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs index 58a38afc68..88ae8f0055 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs @@ -65,7 +65,8 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest .OkOrNonStrict("3.2", "3.3", "3.4", "4.1.3", "4.1.4", "4.1.5", "4.2.3", "4.2.4", "4.2.5", "5.15")); // These occasionally get non-strict results } - await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "ManagedSockets"); + await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "ManagedSockets", expectationConfig: expect => expect + .OkOrNonStrict("4.2.4")); } } From b3f755dff3f9b811311254b2b9effaed66c71699 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Wed, 2 Nov 2016 14:02:48 -0700 Subject: [PATCH 246/453] add test timeout to autobahn conformance tests (#129) --- .../Autobahn/AutobahnTester.cs | 16 ++++++++++---- .../Autobahn/Executable.cs | 21 +++++++++++++++---- .../AutobahnTests.cs | 19 +++++++++++------ 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index 4f5c0afbb5..3217f4029b 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn Spec = baseSpec; } - public async Task Run() + public async Task Run(CancellationToken cancellationToken) { var specFile = Path.GetTempFileName(); try @@ -43,7 +43,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn // Run the test (write something to the console so people know this will take a while...) _logger.LogInformation("Now launching Autobahn Test Suite. This will take a while."); - var exitCode = await Wstest.Default.ExecAsync("-m fuzzingclient -s " + specFile); + var exitCode = await Wstest.Default.ExecAsync("-m fuzzingclient -s " + specFile, cancellationToken); if (exitCode != 0) { throw new Exception("wstest failed"); @@ -57,6 +57,8 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn } } + cancellationToken.ThrowIfCancellationRequested(); + // Parse the output. var outputFile = Path.Combine(Directory.GetCurrentDirectory(), Spec.OutputDirectory, "index.json"); using (var reader = new StreamReader(File.OpenRead(outputFile))) @@ -84,7 +86,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn Assert.True(failures.Length == 0, "Autobahn results did not meet expectations:" + Environment.NewLine + failures.ToString()); } - public async Task DeployTestAndAddToSpec(ServerType server, bool ssl, string environment, Action expectationConfig = null) + public async Task DeployTestAndAddToSpec(ServerType server, bool ssl, string environment, CancellationToken cancellationToken, Action expectationConfig = null) { var port = Interlocked.Increment(ref _nextPort); var baseUrl = ssl ? $"https://localhost:{port}" : $"http://localhost:{port}"; @@ -104,6 +106,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn var deployer = ApplicationDeployerFactory.Create(parameters, logger); var result = deployer.Deploy(); _deployers.Add(deployer); + cancellationToken.ThrowIfCancellationRequested(); #if NET451 System.Net.ServicePointManager.ServerCertificateValidationCallback = (_, __, ___, ____) => true; @@ -123,10 +126,13 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn // Make sure the server works var resp = await RetryHelper.RetryRequest(() => { + cancellationToken.ThrowIfCancellationRequested(); return client.GetAsync(result.ApplicationBaseUri); - }, logger, result.HostShutdownToken, retryCount: 5); + }, logger, CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, result.HostShutdownToken).Token, retryCount: 5); resp.EnsureSuccessStatusCode(); + cancellationToken.ThrowIfCancellationRequested(); + // Add to the current spec var wsUrl = result.ApplicationBaseUri.Replace("https://", "wss://").Replace("http://", "ws://"); Spec.WithServer(name, wsUrl); @@ -134,6 +140,8 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn var expectations = new AutobahnExpectations(server, ssl, environment); expectationConfig?.Invoke(expectations); _expectations.Add(expectations); + + cancellationToken.ThrowIfCancellationRequested(); } public void Dispose() diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs index f404a79a0e..41b798303e 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs @@ -2,6 +2,7 @@ using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; +using System.Threading; using System.Threading.Tasks; namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn @@ -30,7 +31,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn return null; } - public Task ExecAsync(string args) + public async Task ExecAsync(string args, CancellationToken cancellationToken) { var process = new Process() { @@ -44,11 +45,23 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn }; var tcs = new TaskCompletionSource(); - process.Exited += (_, __) => tcs.TrySetResult(process.ExitCode); + using (cancellationToken.Register(() => Cancel(process, tcs))) + { + process.Exited += (_, __) => tcs.TrySetResult(process.ExitCode); - process.Start(); + process.Start(); - return tcs.Task; + return await tcs.Task; + } + } + + private static void Cancel(Process process, TaskCompletionSource tcs) + { + if (process != null && !process.HasExited) + { + process.Kill(); + } + tcs.TrySetCanceled(); } } } diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs index 88ae8f0055..4f5b53a29a 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Runtime.InteropServices; +using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.AspNetCore.Testing.xunit; @@ -39,20 +40,23 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest var loggerFactory = new LoggerFactory(); // No logging by default! It's very loud... - if(string.Equals(Environment.GetEnvironmentVariable("AUTOBAHN_SUITES_LOG"), "1", StringComparison.Ordinal)) + if (string.Equals(Environment.GetEnvironmentVariable("AUTOBAHN_SUITES_LOG"), "1", StringComparison.Ordinal)) { loggerFactory.AddConsole(); } + var cts = new CancellationTokenSource(); + cts.CancelAfter(TimeSpan.FromMinutes(5)); // These tests generally complete in just over 1 minute. + AutobahnResult result; using (var tester = new AutobahnTester(loggerFactory, spec)) { - await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: false, environment: "ManagedSockets"); + await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token); // Windows-only IIS tests, and Kestrel SSL tests (due to: https://github.com/aspnet/WebSockets/issues/102) if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: true, environment: "ManagedSockets"); + await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: true, environment: "ManagedSockets", cancellationToken: cts.Token); if (IsWindows8OrHigher()) { @@ -60,12 +64,12 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest { // IIS Express tests are a bit flaky, some tests fail occasionally or get non-strict passes // https://github.com/aspnet/WebSockets/issues/100 - await tester.DeployTestAndAddToSpec(ServerType.IISExpress, ssl: false, environment: "ManagedSockets", expectationConfig: expect => expect + await tester.DeployTestAndAddToSpec(ServerType.IISExpress, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token, expectationConfig: expect => expect .OkOrFail(Enumerable.Range(1, 20).Select(i => $"5.{i}").ToArray()) // 5.* occasionally fail on IIS express .OkOrNonStrict("3.2", "3.3", "3.4", "4.1.3", "4.1.4", "4.1.5", "4.2.3", "4.2.4", "4.2.5", "5.15")); // These occasionally get non-strict results } - await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "ManagedSockets", expectationConfig: expect => expect + await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token, expectationConfig: expect => expect .OkOrNonStrict("4.2.4")); } } @@ -73,9 +77,12 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest // REQUIRES a build of WebListener that supports native WebSockets, which we don't have right now //await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "NativeSockets"); - result = await tester.Run(); + result = await tester.Run(cts.Token); tester.Verify(result); } + + // If it hasn't been cancelled yet, cancel the token just to be sure + cts.Cancel(); } private bool IsWindows8OrHigher() From f58a373704a175663738f6e920741fd8a68c439d Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Wed, 2 Nov 2016 15:46:22 -0700 Subject: [PATCH 247/453] fix #106 by removing ReplaceFeature --- .../WebSocketMiddleware.cs | 7 ++----- src/Microsoft.AspNetCore.WebSockets/WebSocketOptions.cs | 7 ------- test/AutobahnTestApp/Startup.cs | 8 ++++++-- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs b/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs index 006912b29c..cc61b1414d 100644 --- a/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs +++ b/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs @@ -40,12 +40,9 @@ namespace Microsoft.AspNetCore.WebSockets { // Detect if an opaque upgrade is available. If so, add a websocket upgrade. var upgradeFeature = context.Features.Get(); - if (upgradeFeature != null) + if (upgradeFeature != null && context.Features.Get() == null) { - if (_options.ReplaceFeature || context.Features.Get() == null) - { - context.Features.Set(new UpgradeHandshake(context, upgradeFeature, _options)); - } + context.Features.Set(new UpgradeHandshake(context, upgradeFeature, _options)); } return _next(context); diff --git a/src/Microsoft.AspNetCore.WebSockets/WebSocketOptions.cs b/src/Microsoft.AspNetCore.WebSockets/WebSocketOptions.cs index d6603adf8a..808cc86251 100644 --- a/src/Microsoft.AspNetCore.WebSockets/WebSocketOptions.cs +++ b/src/Microsoft.AspNetCore.WebSockets/WebSocketOptions.cs @@ -14,7 +14,6 @@ namespace Microsoft.AspNetCore.Builder { KeepAliveInterval = TimeSpan.FromMinutes(2); ReceiveBufferSize = 4 * 1024; - ReplaceFeature = false; } /// @@ -28,11 +27,5 @@ namespace Microsoft.AspNetCore.Builder /// The default is 4kb. /// public int ReceiveBufferSize { get; set; } - - /// - /// Gets or sets if the middleware should replace the WebSocket implementation provided by - /// a component earlier in the stack. This is false by default. - /// - public bool ReplaceFeature { get; set; } } } \ No newline at end of file diff --git a/test/AutobahnTestApp/Startup.cs b/test/AutobahnTestApp/Startup.cs index 67562d9ce0..97ac3d09f7 100644 --- a/test/AutobahnTestApp/Startup.cs +++ b/test/AutobahnTestApp/Startup.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Features; using Microsoft.Extensions.Logging; namespace AutobahnTestApp @@ -16,11 +17,14 @@ namespace AutobahnTestApp { if (!env.IsEnvironment("NativeSockets")) { - app.UseWebSockets(new WebSocketOptions + // Register a middleware that disables the server-provided WebSockets feature + app.Use((context, next) => { - ReplaceFeature = true + context.Features.Set(null); + return next(); }); } + app.UseWebSockets(); app.Use(async (context, next) => { From 5858c0a64a72e933c27e32ce054ab45f43c5736b Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Wed, 2 Nov 2016 15:57:25 -0700 Subject: [PATCH 248/453] fix #85 by making HandshakeHelpers internal and tidying doc comments we don't need to share it with anything in the current implementation --- .../Internal/HandshakeHelpers.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.AspNetCore.WebSockets/Internal/HandshakeHelpers.cs b/src/Microsoft.AspNetCore.WebSockets/Internal/HandshakeHelpers.cs index 019f84a08c..a4bb0721ab 100644 --- a/src/Microsoft.AspNetCore.WebSockets/Internal/HandshakeHelpers.cs +++ b/src/Microsoft.AspNetCore.WebSockets/Internal/HandshakeHelpers.cs @@ -8,7 +8,7 @@ using System.Text; namespace Microsoft.AspNetCore.WebSockets.Internal { - public static class HandshakeHelpers + internal static class HandshakeHelpers { /// /// Gets request headers needed process the handshake on the server. @@ -76,7 +76,6 @@ namespace Microsoft.AspNetCore.WebSockets.Internal /// /// Validates the Sec-WebSocket-Key request header - /// "The value of this header field MUST be a nonce consisting of a randomly selected 16-byte value that has been base64-encoded." /// /// /// @@ -97,14 +96,13 @@ namespace Microsoft.AspNetCore.WebSockets.Internal } } - /// - /// "...the base64-encoded SHA-1 of the concatenation of the |Sec-WebSocket-Key| (as a string, not base64-decoded) with the string - /// '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'" - /// - /// - /// public static string CreateResponseKey(string requestKey) { + // "The value of this header field is constructed by concatenating /key/, defined above in step 4 + // in Section 4.2.2, with the string "258EAFA5- E914-47DA-95CA-C5AB0DC85B11", taking the SHA-1 hash of + // this concatenated value to obtain a 20-byte value and base64-encoding" + // https://tools.ietf.org/html/rfc6455#section-4.2.2 + if (requestKey == null) { throw new ArgumentNullException(nameof(requestKey)); From 34f419f4467723175ac61bccf0fa8fb0864279ee Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Sat, 5 Nov 2016 00:09:47 -0700 Subject: [PATCH 249/453] Added tags to project.json --- src/Microsoft.AspNetCore.WebSockets/project.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.WebSockets/project.json b/src/Microsoft.AspNetCore.WebSockets/project.json index c1226b147f..c3432dc8f7 100644 --- a/src/Microsoft.AspNetCore.WebSockets/project.json +++ b/src/Microsoft.AspNetCore.WebSockets/project.json @@ -14,7 +14,10 @@ "repository": { "type": "git", "url": "git://github.com/aspnet/websockets" - } + }, + "tags": [ + "aspnetcore" + ] }, "dependencies": { "Microsoft.AspNetCore.Http.Extensions": "1.1.0-*", From eb94340ea9b5ac65756cbeb5141a240c6507fe29 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Mon, 7 Nov 2016 10:09:35 -0800 Subject: [PATCH 250/453] pin publish-iis version --- samples/EchoApp/project.json | 2 +- test/AutobahnTestApp/project.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/EchoApp/project.json b/samples/EchoApp/project.json index c0acf84815..927c93b2fb 100644 --- a/samples/EchoApp/project.json +++ b/samples/EchoApp/project.json @@ -12,7 +12,7 @@ } }, "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" + "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final" }, "frameworks": { "netcoreapp1.1": { diff --git a/test/AutobahnTestApp/project.json b/test/AutobahnTestApp/project.json index 250062275e..ea43dfa99e 100644 --- a/test/AutobahnTestApp/project.json +++ b/test/AutobahnTestApp/project.json @@ -14,7 +14,7 @@ } }, "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" + "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final" }, "frameworks": { "netcoreapp1.1": { From fb8824ad434eeaedb7cc8813f71349f9df9fb3de Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 9 Nov 2016 11:34:23 -0800 Subject: [PATCH 251/453] Branching for 1.1.0 --- NuGet.config | 4 ++-- build.ps1 | 2 +- build.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/NuGet.config b/NuGet.config index e8b2884654..56387a5b6d 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + - + \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index 8f2f99691a..24ca167cf6 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/1.1.0.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index f4208100eb..fea9ac64ad 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/1.1.0.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From 7f6410bc557314325dd3c865f46bb9d1f275c0b6 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 9 Nov 2016 14:20:20 -0800 Subject: [PATCH 252/453] Updating versions to 1.2.0-* --- samples/EchoApp/project.json | 10 +++++----- src/Microsoft.AspNetCore.WebSockets/project.json | 6 +++--- test/AutobahnTestApp/project.json | 14 +++++++------- .../project.json | 8 ++++---- .../project.json | 4 ++-- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/samples/EchoApp/project.json b/samples/EchoApp/project.json index 927c93b2fb..74183febe8 100644 --- a/samples/EchoApp/project.json +++ b/samples/EchoApp/project.json @@ -1,11 +1,11 @@ { "dependencies": { - "Microsoft.AspNetCore.Diagnostics": "1.1.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", - "Microsoft.AspNetCore.StaticFiles": "1.1.0-*", + "Microsoft.AspNetCore.Diagnostics": "1.2.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", + "Microsoft.AspNetCore.StaticFiles": "1.2.0-*", "Microsoft.AspNetCore.WebSockets": "1.0.0-*", - "Microsoft.Extensions.Logging.Console": "1.1.0-*", + "Microsoft.Extensions.Logging.Console": "1.2.0-*", "Microsoft.NETCore.App": { "version": "1.1.0-*", "type": "platform" diff --git a/src/Microsoft.AspNetCore.WebSockets/project.json b/src/Microsoft.AspNetCore.WebSockets/project.json index c3432dc8f7..9304d41f40 100644 --- a/src/Microsoft.AspNetCore.WebSockets/project.json +++ b/src/Microsoft.AspNetCore.WebSockets/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-*", + "version": "1.1.0-*", "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", @@ -20,8 +20,8 @@ ] }, "dependencies": { - "Microsoft.AspNetCore.Http.Extensions": "1.1.0-*", - "Microsoft.Extensions.Options": "1.1.0-*", + "Microsoft.AspNetCore.Http.Extensions": "1.2.0-*", + "Microsoft.Extensions.Options": "1.2.0-*", "NETStandard.Library": "1.6.1-*" }, "frameworks": { diff --git a/test/AutobahnTestApp/project.json b/test/AutobahnTestApp/project.json index ea43dfa99e..e10822c90a 100644 --- a/test/AutobahnTestApp/project.json +++ b/test/AutobahnTestApp/project.json @@ -1,13 +1,13 @@ { "dependencies": { - "Microsoft.AspNetCore.Diagnostics": "1.1.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", - "Microsoft.AspNetCore.Server.Kestrel.Https": "1.1.0-*", - "Microsoft.AspNetCore.Server.WebListener": "1.1.0-*", + "Microsoft.AspNetCore.Diagnostics": "1.2.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", + "Microsoft.AspNetCore.Server.Kestrel.Https": "1.2.0-*", + "Microsoft.AspNetCore.Server.WebListener": "1.2.0-*", "Microsoft.AspNetCore.WebSockets": "1.0.0-*", - "Microsoft.Extensions.Configuration.CommandLine": "1.1.0-*", - "Microsoft.Extensions.Logging.Console": "1.1.0-*", + "Microsoft.Extensions.Configuration.CommandLine": "1.2.0-*", + "Microsoft.Extensions.Logging.Console": "1.2.0-*", "Microsoft.NETCore.App": { "version": "1.1.0-*", "type": "platform" diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json index 526a646659..91c30bb791 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json @@ -2,10 +2,10 @@ "dependencies": { "dotnet-test-xunit": "2.2.0-*", "Microsoft.AspNetCore.Server.IntegrationTesting": "0.2.0-*", - "Microsoft.AspNetCore.Testing": "1.1.0-*", - "Microsoft.Extensions.Logging": "1.1.0-*", - "Microsoft.Extensions.Logging.Console": "1.1.0-*", - "Microsoft.Extensions.PlatformAbstractions": "1.1.0-*", + "Microsoft.AspNetCore.Testing": "1.2.0-*", + "Microsoft.Extensions.Logging": "1.2.0-*", + "Microsoft.Extensions.Logging.Console": "1.2.0-*", + "Microsoft.Extensions.PlatformAbstractions": "1.2.0-*", "System.Diagnostics.FileVersionInfo": "4.3.0-*", "xunit": "2.2.0-*" }, diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Test/project.json index 3215ce5c62..11cfef4a28 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Test/project.json @@ -1,8 +1,8 @@ { "dependencies": { "dotnet-test-xunit": "2.2.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", - "Microsoft.AspNetCore.Testing": "1.1.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", + "Microsoft.AspNetCore.Testing": "1.2.0-*", "Microsoft.AspNetCore.WebSockets": "1.0.0-*", "xunit": "2.2.0-*" }, From 35f4f2211738e4596211f9c49652290c2a6df397 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 10 Nov 2016 09:00:52 -0800 Subject: [PATCH 253/453] Fixing downgrade warnings --- test/AutobahnTestApp/project.json | 2 +- test/Microsoft.AspNetCore.WebSockets.Test/project.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/AutobahnTestApp/project.json b/test/AutobahnTestApp/project.json index e10822c90a..5d4a550d9c 100644 --- a/test/AutobahnTestApp/project.json +++ b/test/AutobahnTestApp/project.json @@ -5,7 +5,7 @@ "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", "Microsoft.AspNetCore.Server.Kestrel.Https": "1.2.0-*", "Microsoft.AspNetCore.Server.WebListener": "1.2.0-*", - "Microsoft.AspNetCore.WebSockets": "1.0.0-*", + "Microsoft.AspNetCore.WebSockets": "1.1.0-*", "Microsoft.Extensions.Configuration.CommandLine": "1.2.0-*", "Microsoft.Extensions.Logging.Console": "1.2.0-*", "Microsoft.NETCore.App": { diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Test/project.json index 11cfef4a28..3e98c2c6ea 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Test/project.json @@ -3,7 +3,7 @@ "dotnet-test-xunit": "2.2.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", "Microsoft.AspNetCore.Testing": "1.2.0-*", - "Microsoft.AspNetCore.WebSockets": "1.0.0-*", + "Microsoft.AspNetCore.WebSockets": "1.1.0-*", "xunit": "2.2.0-*" }, "testRunner": "xunit", From 0d54ee5fcc6bc238e3d101cfeb4a7a5b99ecc848 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Fri, 18 Nov 2016 10:56:54 -0800 Subject: [PATCH 254/453] Clean tmp folder after unzipping KoreBuild --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index f4208100eb..4fd7ede788 100755 --- a/build.sh +++ b/build.sh @@ -38,7 +38,7 @@ if test ! -d $buildFolder; then chmod +x $buildFile # Cleanup - if test ! -d $tempFolder; then + if test -d $tempFolder; then rm -rf $tempFolder fi fi From 4a5d8f2960b43e17295d83997b4ed715013577bc Mon Sep 17 00:00:00 2001 From: Chris R Date: Tue, 22 Nov 2016 16:05:42 -0800 Subject: [PATCH 255/453] #126 Test the bin deployed aspnetcore.dll --- WebSockets.sln | 1 + test/AutobahnTestApp/project.json | 1 + .../Autobahn/AutobahnTester.cs | 4 +- .../Http.config | 1029 +++++++++++++++++ .../project.json | 2 +- 5 files changed, 1035 insertions(+), 2 deletions(-) create mode 100644 test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Http.config diff --git a/WebSockets.sln b/WebSockets.sln index 94f0f8e042..9b752188e5 100644 --- a/WebSockets.sln +++ b/WebSockets.sln @@ -11,6 +11,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{86E1ADA2-631C-484F-906C-2D0BCF628E65}" ProjectSection(SolutionItems) = preProject global.json = global.json + NuGet.config = NuGet.config EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestServer", "samples\TestServer\TestServer.csproj", "{4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}" diff --git a/test/AutobahnTestApp/project.json b/test/AutobahnTestApp/project.json index 5d4a550d9c..85f87150cd 100644 --- a/test/AutobahnTestApp/project.json +++ b/test/AutobahnTestApp/project.json @@ -1,5 +1,6 @@ { "dependencies": { + "Microsoft.AspNetCore.AspNetCoreModule": "1.0.0-*", "Microsoft.AspNetCore.Diagnostics": "1.2.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index 3217f4029b..045e86428c 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -100,7 +100,9 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn ApplicationBaseUriHint = baseUrl, ApplicationType = ApplicationType.Portable, TargetFramework = "netcoreapp1.1", - EnvironmentName = environment + EnvironmentName = environment, + SiteName = "HttpTestSite", // This is configured in the Http.config + ServerConfigTemplateContent = (server == ServerType.IISExpress) ? File.ReadAllText("Http.config") : null, }; var deployer = ApplicationDeployerFactory.Create(parameters, logger); diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Http.config b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Http.config new file mode 100644 index 0000000000..3668f762c8 --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Http.config @@ -0,0 +1,1029 @@ + + + + + + + + +
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json index 91c30bb791..f3f62c16dd 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json @@ -1,7 +1,7 @@ { "dependencies": { "dotnet-test-xunit": "2.2.0-*", - "Microsoft.AspNetCore.Server.IntegrationTesting": "0.2.0-*", + "Microsoft.AspNetCore.Server.IntegrationTesting": "0.3.0-*", "Microsoft.AspNetCore.Testing": "1.2.0-*", "Microsoft.Extensions.Logging": "1.2.0-*", "Microsoft.Extensions.Logging.Console": "1.2.0-*", From 5da505dfb0eba94dec31544b525f1ade5b45cb50 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Wed, 23 Nov 2016 16:00:34 -0800 Subject: [PATCH 256/453] Pin global.json SDK to 1.0.0-preview2-1-003177. --- global.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/global.json b/global.json index 983ba0401e..f45e8cc925 100644 --- a/global.json +++ b/global.json @@ -1,3 +1,8 @@ { - "projects": ["src"] -} + "projects": [ + "src" + ], + "sdk": { + "version": "1.0.0-preview2-1-003177" + } +} \ No newline at end of file From f66374d27489b584231680738f5ee59888322c00 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Thu, 8 Dec 2016 10:04:24 -0800 Subject: [PATCH 257/453] Update .travis.yml osx image to xcode7.3. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3439636a23..0a218b46bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ python: os: - linux - osx -osx_image: xcode7.1 +osx_image: xcode7.3 branches: only: - master From 12ab74493d77ca511251643d00c42761e8aab772 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Mon, 12 Dec 2016 00:40:42 -0800 Subject: [PATCH 258/453] Removed packages list in NuGetPackageVerifier.json --- NuGetPackageVerifier.json | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json index a92d13f00a..b153ab1515 100644 --- a/NuGetPackageVerifier.json +++ b/NuGetPackageVerifier.json @@ -1,15 +1,7 @@ { - "adx": { // Packages written by the ADX team and that ship on NuGet.org - "rules": [ - "AdxVerificationCompositeRule" - ], - "packages": { - "Microsoft.AspNetCore.WebSockets": { } - } - }, - "Default": { // Rules to run for packages not listed in any other set. + "Default": { "rules": [ "DefaultCompositeRule" ] } -} +} \ No newline at end of file From 4b9276bac2ab60e48498b016048ae53c0a259d65 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 5 Dec 2016 09:04:12 -0800 Subject: [PATCH 259/453] Updating to 4.4 CoreFx packages --- global.json | 2 +- samples/EchoApp/project.json | 2 +- src/Microsoft.AspNetCore.WebSockets/project.json | 2 +- test/AutobahnTestApp/project.json | 2 +- .../project.json | 4 ++-- test/Microsoft.AspNetCore.WebSockets.Test/project.json | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/global.json b/global.json index f45e8cc925..0ad1995dd2 100644 --- a/global.json +++ b/global.json @@ -3,6 +3,6 @@ "src" ], "sdk": { - "version": "1.0.0-preview2-1-003177" + "version": "1.0.0-preview2-1-003180" } } \ No newline at end of file diff --git a/samples/EchoApp/project.json b/samples/EchoApp/project.json index 74183febe8..b8b7b3c1dd 100644 --- a/samples/EchoApp/project.json +++ b/samples/EchoApp/project.json @@ -7,7 +7,7 @@ "Microsoft.AspNetCore.WebSockets": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.2.0-*", "Microsoft.NETCore.App": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "platform" } }, diff --git a/src/Microsoft.AspNetCore.WebSockets/project.json b/src/Microsoft.AspNetCore.WebSockets/project.json index 9304d41f40..5a60019eef 100644 --- a/src/Microsoft.AspNetCore.WebSockets/project.json +++ b/src/Microsoft.AspNetCore.WebSockets/project.json @@ -22,7 +22,7 @@ "dependencies": { "Microsoft.AspNetCore.Http.Extensions": "1.2.0-*", "Microsoft.Extensions.Options": "1.2.0-*", - "NETStandard.Library": "1.6.1-*" + "NETStandard.Library": "1.6.2-*" }, "frameworks": { "net451": {}, diff --git a/test/AutobahnTestApp/project.json b/test/AutobahnTestApp/project.json index 85f87150cd..9bee581ada 100644 --- a/test/AutobahnTestApp/project.json +++ b/test/AutobahnTestApp/project.json @@ -10,7 +10,7 @@ "Microsoft.Extensions.Configuration.CommandLine": "1.2.0-*", "Microsoft.Extensions.Logging.Console": "1.2.0-*", "Microsoft.NETCore.App": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "platform" } }, diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json index f3f62c16dd..95f9f0c2bb 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json @@ -6,7 +6,7 @@ "Microsoft.Extensions.Logging": "1.2.0-*", "Microsoft.Extensions.Logging.Console": "1.2.0-*", "Microsoft.Extensions.PlatformAbstractions": "1.2.0-*", - "System.Diagnostics.FileVersionInfo": "4.3.0-*", + "System.Diagnostics.FileVersionInfo": "4.4.0-*", "xunit": "2.2.0-*" }, "testRunner": "xunit", @@ -14,7 +14,7 @@ "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "platform" } } diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Test/project.json index 3e98c2c6ea..757bf1e2e0 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/project.json +++ b/test/Microsoft.AspNetCore.WebSockets.Test/project.json @@ -12,10 +12,10 @@ "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "platform" }, - "System.Net.WebSockets.Client": "4.3.0-*" + "System.Net.WebSockets.Client": "4.4.0-*" } } } From 9e729bec9da89c41ba520d283f2ad2052a7c3232 Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Thu, 29 Dec 2016 11:19:46 -0800 Subject: [PATCH 260/453] Disable tests on SSL due to SslStream issue. --- .../AutobahnTests.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs index 4f5b53a29a..6f33cf5e27 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs @@ -56,7 +56,8 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest // Windows-only IIS tests, and Kestrel SSL tests (due to: https://github.com/aspnet/WebSockets/issues/102) if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: true, environment: "ManagedSockets", cancellationToken: cts.Token); + // Disabled due to https://github.com/dotnet/corefx/issues/14698 + //await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: true, environment: "ManagedSockets", cancellationToken: cts.Token); if (IsWindows8OrHigher()) { From 3d62de4fe6064b5eecb59db5264b70c895bb4123 Mon Sep 17 00:00:00 2001 From: Chris R Date: Tue, 3 Jan 2017 18:58:44 -0800 Subject: [PATCH 261/453] React to WebListener rename --- test/AutobahnTestApp/Program.cs | 4 ++-- test/AutobahnTestApp/Properties/launchSettings.json | 2 +- test/AutobahnTestApp/project.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/AutobahnTestApp/Program.cs b/test/AutobahnTestApp/Program.cs index 04098c88ab..65d165166d 100644 --- a/test/AutobahnTestApp/Program.cs +++ b/test/AutobahnTestApp/Program.cs @@ -19,9 +19,9 @@ namespace AutobahnTestApp .UseIISIntegration() .UseStartup(); - if (string.Equals(builder.GetSetting("server"), "Microsoft.AspNetCore.Server.WebListener", System.StringComparison.Ordinal)) + if (string.Equals(builder.GetSetting("server"), "Microsoft.AspNetCore.Server.HttpSys", System.StringComparison.Ordinal)) { - builder.UseWebListener(); + builder.UseHttpSys(); } else { diff --git a/test/AutobahnTestApp/Properties/launchSettings.json b/test/AutobahnTestApp/Properties/launchSettings.json index c96436ad2a..85a2609ccc 100644 --- a/test/AutobahnTestApp/Properties/launchSettings.json +++ b/test/AutobahnTestApp/Properties/launchSettings.json @@ -33,7 +33,7 @@ }, "WebListener": { "commandName": "Project", - "commandLineArgs": "--server Microsoft.AspNetCore.Server.WebListener", + "commandLineArgs": "--server Microsoft.AspNetCore.Server.HttpSys", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "ManagedSockets" } diff --git a/test/AutobahnTestApp/project.json b/test/AutobahnTestApp/project.json index 9bee581ada..2b51644993 100644 --- a/test/AutobahnTestApp/project.json +++ b/test/AutobahnTestApp/project.json @@ -2,10 +2,10 @@ "dependencies": { "Microsoft.AspNetCore.AspNetCoreModule": "1.0.0-*", "Microsoft.AspNetCore.Diagnostics": "1.2.0-*", + "Microsoft.AspNetCore.Server.HttpSys": "1.2.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", "Microsoft.AspNetCore.Server.Kestrel.Https": "1.2.0-*", - "Microsoft.AspNetCore.Server.WebListener": "1.2.0-*", "Microsoft.AspNetCore.WebSockets": "1.1.0-*", "Microsoft.Extensions.Configuration.CommandLine": "1.2.0-*", "Microsoft.Extensions.Logging.Console": "1.2.0-*", From 7eabf5cf3a899c6394028d7fcb9c2bdfca9cfe60 Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 5 Jan 2017 12:34:35 -0800 Subject: [PATCH 262/453] Remove obsolete WebListener test scenario --- test/AutobahnTestApp/Startup.cs | 9 --------- .../AutobahnTests.cs | 3 --- 2 files changed, 12 deletions(-) diff --git a/test/AutobahnTestApp/Startup.cs b/test/AutobahnTestApp/Startup.cs index 97ac3d09f7..a7005b2247 100644 --- a/test/AutobahnTestApp/Startup.cs +++ b/test/AutobahnTestApp/Startup.cs @@ -15,15 +15,6 @@ namespace AutobahnTestApp // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { - if (!env.IsEnvironment("NativeSockets")) - { - // Register a middleware that disables the server-provided WebSockets feature - app.Use((context, next) => - { - context.Features.Set(null); - return next(); - }); - } app.UseWebSockets(); app.Use(async (context, next) => diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs index 6f33cf5e27..28a111d5c2 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs @@ -75,9 +75,6 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest } } - // REQUIRES a build of WebListener that supports native WebSockets, which we don't have right now - //await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "NativeSockets"); - result = await tester.Run(cts.Token); tester.Verify(result); } From eb24a9761a3d926593f2886127d883c6a1a49883 Mon Sep 17 00:00:00 2001 From: Stephen Halter Date: Mon, 9 Jan 2017 16:42:24 -0800 Subject: [PATCH 263/453] React to UseHttps change --- test/AutobahnTestApp/Program.cs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/test/AutobahnTestApp/Program.cs b/test/AutobahnTestApp/Program.cs index 65d165166d..d056f14262 100644 --- a/test/AutobahnTestApp/Program.cs +++ b/test/AutobahnTestApp/Program.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Net; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; @@ -23,12 +24,35 @@ namespace AutobahnTestApp { builder.UseHttpSys(); } + else if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) + { + // ANCM is hosting the process. + // The port will not yet be configure at this point, but will also not require HTTPS. + builder.UseKestrel(); + } else { + // Also check "server.urls" for back-compat. + var urls = builder.GetSetting(WebHostDefaults.ServerUrlsKey) ?? builder.GetSetting("server.urls"); + builder.UseSetting(WebHostDefaults.ServerUrlsKey, string.Empty); + + if (urls.Contains(";")) + { + throw new NotSupportedException("This test app does not support multiple endpoints."); + } + + var uri = new Uri(urls); + builder.UseKestrel(options => { - var certPath = Path.Combine(AppContext.BaseDirectory, "TestResources", "testCert.pfx"); - options.UseHttps(certPath, "testPassword"); + options.Listen(IPAddress.Loopback, uri.Port, listenOptions => + { + if (uri.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase)) + { + var certPath = Path.Combine(AppContext.BaseDirectory, "TestResources", "testCert.pfx"); + listenOptions.UseHttps(certPath, "testPassword"); + } + }); }); } From e075ae9b13a83dd4c05c554e341166f23156e5f9 Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Tue, 10 Jan 2017 10:26:15 -0800 Subject: [PATCH 264/453] Revert "Disable tests on SSL due to SslStream issue." This reverts commit 9e729bec9da89c41ba520d283f2ad2052a7c3232. --- .../AutobahnTests.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs index 28a111d5c2..0562b81c2d 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs @@ -56,8 +56,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest // Windows-only IIS tests, and Kestrel SSL tests (due to: https://github.com/aspnet/WebSockets/issues/102) if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - // Disabled due to https://github.com/dotnet/corefx/issues/14698 - //await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: true, environment: "ManagedSockets", cancellationToken: cts.Token); + await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: true, environment: "ManagedSockets", cancellationToken: cts.Token); if (IsWindows8OrHigher()) { From 86490e309fbe31f12a166a01ce4efdfefc628b53 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Fri, 13 Jan 2017 10:41:42 -0800 Subject: [PATCH 265/453] stablize Autobahn 3.2 on WebListener --- .../AutobahnTests.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs index 0562b81c2d..76c5080286 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs @@ -69,8 +69,10 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest .OkOrNonStrict("3.2", "3.3", "3.4", "4.1.3", "4.1.4", "4.1.5", "4.2.3", "4.2.4", "4.2.5", "5.15")); // These occasionally get non-strict results } + // WebListener occasionally gives a non-strict response on 3.2. IIS Express seems to have the same behavior. Wonder if it's related to HttpSys? + // For now, just allow the non-strict response, it's not a failure. await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token, expectationConfig: expect => expect - .OkOrNonStrict("4.2.4")); + .OkOrNonStrict("3.2", "4.2.4")); } } From 0e1dd78771f113db5451505bcfce02f27a97d48c Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 1 Feb 2017 20:26:00 -0800 Subject: [PATCH 266/453] Upgrade to VS 2017 --- NuGet.config | 7 +- WebSockets.sln | 99 +++++++++++++----- appveyor.yml | 1 + build.ps1 | 2 +- build.sh | 2 +- {tools => build}/Key.snk | Bin build/common.props | 24 +++++ global.json | 8 -- ... => AutobahnTestAppAspNet4.csproj.aspnet4} | 0 samples/EchoApp/EchoApp.csproj | 21 ++++ samples/EchoApp/EchoApp.xproj | 25 ----- samples/EchoApp/project.json | 45 -------- samples/EchoApp/runtimeconfig.template.json | 5 + .../Microsoft.AspNetCore.WebSockets.csproj | 19 ++++ .../Microsoft.AspNetCore.WebSockets.xproj | 19 ---- .../Properties/AssemblyInfo.cs | 11 -- .../project.json | 31 ------ test/AutobahnTestApp/.notest | 0 test/AutobahnTestApp/AutobahnTestApp.csproj | 24 +++++ test/AutobahnTestApp/AutobahnTestApp.xproj | 25 ----- test/AutobahnTestApp/project.json | 51 --------- .../runtimeconfig.template.json | 5 + ...pNetCore.WebSockets.ConformanceTest.csproj | 21 ++++ ...spNetCore.WebSockets.ConformanceTest.xproj | 21 ---- .../Properties/AssemblyInfo.cs | 18 ---- .../project.json | 23 ---- ...icrosoft.AspNetCore.WebSockets.Test.csproj | 27 +++++ ...Microsoft.AspNetCore.WebSockets.Test.xproj | 19 ---- .../Properties/AssemblyInfo.cs | 19 ---- .../project.json | 22 ---- version.props | 7 ++ 31 files changed, 233 insertions(+), 368 deletions(-) rename {tools => build}/Key.snk (100%) create mode 100644 build/common.props delete mode 100644 global.json rename samples/AutobahnTestAppAspNet4/{AutobahnTestAppAspNet4.csproj => AutobahnTestAppAspNet4.csproj.aspnet4} (100%) create mode 100644 samples/EchoApp/EchoApp.csproj delete mode 100644 samples/EchoApp/EchoApp.xproj delete mode 100644 samples/EchoApp/project.json create mode 100644 samples/EchoApp/runtimeconfig.template.json create mode 100644 src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj delete mode 100644 src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.xproj delete mode 100644 src/Microsoft.AspNetCore.WebSockets/Properties/AssemblyInfo.cs delete mode 100644 src/Microsoft.AspNetCore.WebSockets/project.json create mode 100644 test/AutobahnTestApp/.notest create mode 100644 test/AutobahnTestApp/AutobahnTestApp.csproj delete mode 100644 test/AutobahnTestApp/AutobahnTestApp.xproj delete mode 100644 test/AutobahnTestApp/project.json create mode 100644 test/AutobahnTestApp/runtimeconfig.template.json create mode 100644 test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj delete mode 100644 test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.xproj delete mode 100644 test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Properties/AssemblyInfo.cs delete mode 100644 test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json create mode 100644 test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj delete mode 100644 test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.xproj delete mode 100644 test/Microsoft.AspNetCore.WebSockets.Test/Properties/AssemblyInfo.cs delete mode 100644 test/Microsoft.AspNetCore.WebSockets.Test/project.json create mode 100644 version.props diff --git a/NuGet.config b/NuGet.config index e8b2884654..8e65695611 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,8 @@ - + - + + - \ No newline at end of file + diff --git a/WebSockets.sln b/WebSockets.sln index 9b752188e5..fbe3ca6412 100644 --- a/WebSockets.sln +++ b/WebSockets.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.26123.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2C7947A5-9FBD-4267-97C1-2D726D7B3BAF}" EndProject @@ -8,18 +8,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{C45106D0-7 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{86E1ADA2-631C-484F-906C-2D0BCF628E65}" - ProjectSection(SolutionItems) = preProject - global.json = global.json - NuGet.config = NuGet.config - EndProjectSection -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestServer", "samples\TestServer\TestServer.csproj", "{4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AutobahnTestApp", "test\AutobahnTestApp\AutobahnTestApp.xproj", "{9755F612-A155-4BDD-9E20-37ADE0B4B3BA}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutobahnTestAppAspNet4", "samples\AutobahnTestAppAspNet4\AutobahnTestAppAspNet4.csproj", "{72E3AB32-682F-42AF-B7C7-0B777244FF11}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutobahnTestAppHttpListener", "samples\AutobahnTestAppHttpListener\AutobahnTestAppHttpListener.csproj", "{B7246F23-6A4B-492F-AB61-292AA1A9E9D5}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{19595D64-E42E-46FD-AB2E-BDC870724EE7}" @@ -27,64 +17,121 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{1959 scripts\UpdateCoreFxCode.ps1 = scripts\UpdateCoreFxCode.ps1 EndProjectSection EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets", "src\Microsoft.AspNetCore.WebSockets\Microsoft.AspNetCore.WebSockets.xproj", "{CDE16880-0374-46FA-8896-99F1B90B4B6F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.WebSockets", "src\Microsoft.AspNetCore.WebSockets\Microsoft.AspNetCore.WebSockets.csproj", "{CDE16880-0374-46FA-8896-99F1B90B4B6F}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.Test", "test\Microsoft.AspNetCore.WebSockets.Test\Microsoft.AspNetCore.WebSockets.Test.xproj", "{5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.WebSockets.Test", "test\Microsoft.AspNetCore.WebSockets.Test\Microsoft.AspNetCore.WebSockets.Test.csproj", "{5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.WebSockets.ConformanceTest", "test\Microsoft.AspNetCore.WebSockets.ConformanceTest\Microsoft.AspNetCore.WebSockets.ConformanceTest.xproj", "{74F45408-1959-4FEE-9511-25D40F4913FD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.WebSockets.ConformanceTest", "test\Microsoft.AspNetCore.WebSockets.ConformanceTest\Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj", "{74F45408-1959-4FEE-9511-25D40F4913FD}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "EchoApp", "samples\EchoApp\EchoApp.xproj", "{421954B0-5C6B-4092-8D4D-EACA4CE60AFB}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EchoApp", "samples\EchoApp\EchoApp.csproj", "{421954B0-5C6B-4092-8D4D-EACA4CE60AFB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutobahnTestApp", "test\AutobahnTestApp\AutobahnTestApp.csproj", "{150DF5A8-87C6-42F7-8886-CE07BFD02FD2}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Debug|x64.ActiveCfg = Debug|Any CPU + {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Debug|x64.Build.0 = Debug|Any CPU + {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Debug|x86.ActiveCfg = Debug|Any CPU + {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Debug|x86.Build.0 = Debug|Any CPU {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Release|Any CPU.ActiveCfg = Release|Any CPU {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Release|Any CPU.Build.0 = Release|Any CPU - {9755F612-A155-4BDD-9E20-37ADE0B4B3BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9755F612-A155-4BDD-9E20-37ADE0B4B3BA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9755F612-A155-4BDD-9E20-37ADE0B4B3BA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9755F612-A155-4BDD-9E20-37ADE0B4B3BA}.Release|Any CPU.Build.0 = Release|Any CPU - {72E3AB32-682F-42AF-B7C7-0B777244FF11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {72E3AB32-682F-42AF-B7C7-0B777244FF11}.Debug|Any CPU.Build.0 = Debug|Any CPU - {72E3AB32-682F-42AF-B7C7-0B777244FF11}.Release|Any CPU.ActiveCfg = Release|Any CPU - {72E3AB32-682F-42AF-B7C7-0B777244FF11}.Release|Any CPU.Build.0 = Release|Any CPU + {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Release|x64.ActiveCfg = Release|Any CPU + {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Release|x64.Build.0 = Release|Any CPU + {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Release|x86.ActiveCfg = Release|Any CPU + {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Release|x86.Build.0 = Release|Any CPU {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Debug|x64.ActiveCfg = Debug|Any CPU + {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Debug|x64.Build.0 = Debug|Any CPU + {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Debug|x86.ActiveCfg = Debug|Any CPU + {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Debug|x86.Build.0 = Debug|Any CPU {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Release|Any CPU.ActiveCfg = Release|Any CPU {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Release|Any CPU.Build.0 = Release|Any CPU + {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Release|x64.ActiveCfg = Release|Any CPU + {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Release|x64.Build.0 = Release|Any CPU + {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Release|x86.ActiveCfg = Release|Any CPU + {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Release|x86.Build.0 = Release|Any CPU {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Debug|x64.ActiveCfg = Debug|x64 + {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Debug|x64.Build.0 = Debug|x64 + {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Debug|x86.ActiveCfg = Debug|x86 + {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Debug|x86.Build.0 = Debug|x86 {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Release|Any CPU.ActiveCfg = Release|Any CPU {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Release|Any CPU.Build.0 = Release|Any CPU + {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Release|x64.ActiveCfg = Release|x64 + {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Release|x64.Build.0 = Release|x64 + {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Release|x86.ActiveCfg = Release|x86 + {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Release|x86.Build.0 = Release|x86 {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Debug|x64.ActiveCfg = Debug|x64 + {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Debug|x64.Build.0 = Debug|x64 + {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Debug|x86.ActiveCfg = Debug|x86 + {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Debug|x86.Build.0 = Debug|x86 {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Release|Any CPU.ActiveCfg = Release|Any CPU {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Release|Any CPU.Build.0 = Release|Any CPU + {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Release|x64.ActiveCfg = Release|x64 + {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Release|x64.Build.0 = Release|x64 + {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Release|x86.ActiveCfg = Release|x86 + {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Release|x86.Build.0 = Release|x86 {74F45408-1959-4FEE-9511-25D40F4913FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {74F45408-1959-4FEE-9511-25D40F4913FD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {74F45408-1959-4FEE-9511-25D40F4913FD}.Debug|x64.ActiveCfg = Debug|x64 + {74F45408-1959-4FEE-9511-25D40F4913FD}.Debug|x64.Build.0 = Debug|x64 + {74F45408-1959-4FEE-9511-25D40F4913FD}.Debug|x86.ActiveCfg = Debug|x86 + {74F45408-1959-4FEE-9511-25D40F4913FD}.Debug|x86.Build.0 = Debug|x86 {74F45408-1959-4FEE-9511-25D40F4913FD}.Release|Any CPU.ActiveCfg = Release|Any CPU {74F45408-1959-4FEE-9511-25D40F4913FD}.Release|Any CPU.Build.0 = Release|Any CPU + {74F45408-1959-4FEE-9511-25D40F4913FD}.Release|x64.ActiveCfg = Release|x64 + {74F45408-1959-4FEE-9511-25D40F4913FD}.Release|x64.Build.0 = Release|x64 + {74F45408-1959-4FEE-9511-25D40F4913FD}.Release|x86.ActiveCfg = Release|x86 + {74F45408-1959-4FEE-9511-25D40F4913FD}.Release|x86.Build.0 = Release|x86 {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Debug|x64.ActiveCfg = Debug|x64 + {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Debug|x64.Build.0 = Debug|x64 + {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Debug|x86.ActiveCfg = Debug|x86 + {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Debug|x86.Build.0 = Debug|x86 {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Release|Any CPU.ActiveCfg = Release|Any CPU {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Release|Any CPU.Build.0 = Release|Any CPU + {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Release|x64.ActiveCfg = Release|x64 + {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Release|x64.Build.0 = Release|x64 + {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Release|x86.ActiveCfg = Release|x86 + {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Release|x86.Build.0 = Release|x86 + {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Debug|x64.ActiveCfg = Debug|x64 + {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Debug|x64.Build.0 = Debug|x64 + {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Debug|x86.ActiveCfg = Debug|x86 + {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Debug|x86.Build.0 = Debug|x86 + {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Release|Any CPU.Build.0 = Release|Any CPU + {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Release|x64.ActiveCfg = Release|x64 + {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Release|x64.Build.0 = Release|x64 + {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Release|x86.ActiveCfg = Release|x86 + {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} - {9755F612-A155-4BDD-9E20-37ADE0B4B3BA} = {C45106D0-76C8-4776-A140-F7DD83CA2958} - {72E3AB32-682F-42AF-B7C7-0B777244FF11} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} {B7246F23-6A4B-492F-AB61-292AA1A9E9D5} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} {CDE16880-0374-46FA-8896-99F1B90B4B6F} = {2C7947A5-9FBD-4267-97C1-2D726D7B3BAF} {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF} = {C45106D0-76C8-4776-A140-F7DD83CA2958} {74F45408-1959-4FEE-9511-25D40F4913FD} = {C45106D0-76C8-4776-A140-F7DD83CA2958} {421954B0-5C6B-4092-8D4D-EACA4CE60AFB} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} + {150DF5A8-87C6-42F7-8886-CE07BFD02FD2} = {C45106D0-76C8-4776-A140-F7DD83CA2958} EndGlobalSection EndGlobal diff --git a/appveyor.yml b/appveyor.yml index 5086ce1532..0e6f4dfa84 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,3 +14,4 @@ install: clone_depth: 1 test: off deploy: off +os: Visual Studio 2017 RC diff --git a/build.ps1 b/build.ps1 index 8f2f99691a..0605b59c01 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/feature/msbuild.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index 4fd7ede788..07997d6c83 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/feature/msbuild.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi diff --git a/tools/Key.snk b/build/Key.snk similarity index 100% rename from tools/Key.snk rename to build/Key.snk diff --git a/build/common.props b/build/common.props new file mode 100644 index 0000000000..e4307101fb --- /dev/null +++ b/build/common.props @@ -0,0 +1,24 @@ + + + + + Microsoft ASP.NET Core + https://github.com/aspnet/WebSockets + git + $(MSBuildThisFileDirectory)Key.snk + true + true + 1.2.0-* + 1.6.2-* + $(VersionSuffix)-$(BuildNumber) + + + + + + + + + + + diff --git a/global.json b/global.json deleted file mode 100644 index 0ad1995dd2..0000000000 --- a/global.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "projects": [ - "src" - ], - "sdk": { - "version": "1.0.0-preview2-1-003180" - } -} \ No newline at end of file diff --git a/samples/AutobahnTestAppAspNet4/AutobahnTestAppAspNet4.csproj b/samples/AutobahnTestAppAspNet4/AutobahnTestAppAspNet4.csproj.aspnet4 similarity index 100% rename from samples/AutobahnTestAppAspNet4/AutobahnTestAppAspNet4.csproj rename to samples/AutobahnTestAppAspNet4/AutobahnTestAppAspNet4.csproj.aspnet4 diff --git a/samples/EchoApp/EchoApp.csproj b/samples/EchoApp/EchoApp.csproj new file mode 100644 index 0000000000..d28ce5eabb --- /dev/null +++ b/samples/EchoApp/EchoApp.csproj @@ -0,0 +1,21 @@ + + + + netcoreapp1.1 + true + Exe + + + + + + + + + + + + + + + diff --git a/samples/EchoApp/EchoApp.xproj b/samples/EchoApp/EchoApp.xproj deleted file mode 100644 index 687dae372a..0000000000 --- a/samples/EchoApp/EchoApp.xproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - 421954b0-5c6b-4092-8d4d-eaca4ce60afb - EchoApp - .\obj - .\bin\ - v4.6.1 - - - - 2.0 - - - - - - - diff --git a/samples/EchoApp/project.json b/samples/EchoApp/project.json deleted file mode 100644 index b8b7b3c1dd..0000000000 --- a/samples/EchoApp/project.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "dependencies": { - "Microsoft.AspNetCore.Diagnostics": "1.2.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", - "Microsoft.AspNetCore.StaticFiles": "1.2.0-*", - "Microsoft.AspNetCore.WebSockets": "1.0.0-*", - "Microsoft.Extensions.Logging.Console": "1.2.0-*", - "Microsoft.NETCore.App": { - "version": "1.2.0-*", - "type": "platform" - } - }, - "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final" - }, - "frameworks": { - "netcoreapp1.1": { - "imports": [ - "dotnet5.6", - "portable-net45+win8" - ] - } - }, - "buildOptions": { - "emitEntryPoint": true, - "preserveCompilationContext": true - }, - "runtimeOptions": { - "configProperties": { - "System.GC.Server": true - } - }, - "publishOptions": { - "include": [ - "wwwroot", - "web.config" - ] - }, - "scripts": { - "postpublish": [ - "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" - ] - } -} \ No newline at end of file diff --git a/samples/EchoApp/runtimeconfig.template.json b/samples/EchoApp/runtimeconfig.template.json new file mode 100644 index 0000000000..7305508a37 --- /dev/null +++ b/samples/EchoApp/runtimeconfig.template.json @@ -0,0 +1,5 @@ +{ + "configProperties": { + "System.GC.Server": true + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj new file mode 100644 index 0000000000..ed0bcaab59 --- /dev/null +++ b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj @@ -0,0 +1,19 @@ + + + + + + ASP.NET Core web socket middleware for use on top of opaque servers. + net451;netstandard1.3 + $(NoWarn);CS1591 + true + true + aspnetcore + + + + + + + + diff --git a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.xproj b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.xproj deleted file mode 100644 index a0c37d1140..0000000000 --- a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0.25420 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - cde16880-0374-46fa-8896-99f1b90b4b6f - Microsoft.AspNetCore.WebSockets - .\obj - .\bin\ - - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.WebSockets/Properties/AssemblyInfo.cs deleted file mode 100644 index 76feceeff0..0000000000 --- a/src/Microsoft.AspNetCore.WebSockets/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Reflection; -using System.Resources; - -[assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] -[assembly: AssemblyCompany("Microsoft Corporation.")] -[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] -[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.WebSockets/project.json b/src/Microsoft.AspNetCore.WebSockets/project.json deleted file mode 100644 index 5a60019eef..0000000000 --- a/src/Microsoft.AspNetCore.WebSockets/project.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "version": "1.1.0-*", - "buildOptions": { - "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk", - "nowarn": [ - "CS1591" - ], - "xmlDoc": true, - "allowUnsafe": true - }, - "description": "ASP.NET Core web socket middleware for use on top of opaque servers.", - "packOptions": { - "repository": { - "type": "git", - "url": "git://github.com/aspnet/websockets" - }, - "tags": [ - "aspnetcore" - ] - }, - "dependencies": { - "Microsoft.AspNetCore.Http.Extensions": "1.2.0-*", - "Microsoft.Extensions.Options": "1.2.0-*", - "NETStandard.Library": "1.6.2-*" - }, - "frameworks": { - "net451": {}, - "netstandard1.3": {} - } -} \ No newline at end of file diff --git a/test/AutobahnTestApp/.notest b/test/AutobahnTestApp/.notest new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/AutobahnTestApp/AutobahnTestApp.csproj b/test/AutobahnTestApp/AutobahnTestApp.csproj new file mode 100644 index 0000000000..123ce068e5 --- /dev/null +++ b/test/AutobahnTestApp/AutobahnTestApp.csproj @@ -0,0 +1,24 @@ + + + + netcoreapp1.1 + Exe + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/AutobahnTestApp/AutobahnTestApp.xproj b/test/AutobahnTestApp/AutobahnTestApp.xproj deleted file mode 100644 index 1e23714cd5..0000000000 --- a/test/AutobahnTestApp/AutobahnTestApp.xproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - 9755f612-a155-4bdd-9e20-37ade0b4b3ba - AutobahnTestApp - .\obj - .\bin\ - v4.6.1 - - - - 2.0 - - - - - - - diff --git a/test/AutobahnTestApp/project.json b/test/AutobahnTestApp/project.json deleted file mode 100644 index 2b51644993..0000000000 --- a/test/AutobahnTestApp/project.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "dependencies": { - "Microsoft.AspNetCore.AspNetCoreModule": "1.0.0-*", - "Microsoft.AspNetCore.Diagnostics": "1.2.0-*", - "Microsoft.AspNetCore.Server.HttpSys": "1.2.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", - "Microsoft.AspNetCore.Server.Kestrel.Https": "1.2.0-*", - "Microsoft.AspNetCore.WebSockets": "1.1.0-*", - "Microsoft.Extensions.Configuration.CommandLine": "1.2.0-*", - "Microsoft.Extensions.Logging.Console": "1.2.0-*", - "Microsoft.NETCore.App": { - "version": "1.2.0-*", - "type": "platform" - } - }, - "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final" - }, - "frameworks": { - "netcoreapp1.1": { - "imports": [ - "dotnet5.6", - "portable-net45+win8" - ] - } - }, - "buildOptions": { - "emitEntryPoint": true, - "copyToOutput": [ - "TestResources/testCert.pfx" - ] - }, - "runtimeOptions": { - "configProperties": { - "System.GC.Server": true - } - }, - "publishOptions": { - "include": [ - "wwwroot", - "web.config", - "TestResources/testCert.pfx" - ] - }, - "scripts": { - "postpublish": [ - "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" - ] - } -} \ No newline at end of file diff --git a/test/AutobahnTestApp/runtimeconfig.template.json b/test/AutobahnTestApp/runtimeconfig.template.json new file mode 100644 index 0000000000..7305508a37 --- /dev/null +++ b/test/AutobahnTestApp/runtimeconfig.template.json @@ -0,0 +1,5 @@ +{ + "configProperties": { + "System.GC.Server": true + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj new file mode 100644 index 0000000000..f5a9792cd6 --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj @@ -0,0 +1,21 @@ + + + + + + netcoreapp1.1 + + + + + + + + + + + + + + + diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.xproj b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.xproj deleted file mode 100644 index 4be31bf78c..0000000000 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.xproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - 14.0.25420 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 74f45408-1959-4fee-9511-25d40f4913fd - Microsoft.AspNetCore.WebSockets.ConformanceTest - .\obj - .\bin\ - - - 2.0 - - - - - - \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Properties/AssemblyInfo.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Properties/AssemblyInfo.cs deleted file mode 100644 index 72534b1587..0000000000 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Microsoft.AspNetCore.WebSockets.Server.Test")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("e82d9f64-8afa-4dcb-a842-2283fda73be8")] diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json deleted file mode 100644 index 95f9f0c2bb..0000000000 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/project.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "dependencies": { - "dotnet-test-xunit": "2.2.0-*", - "Microsoft.AspNetCore.Server.IntegrationTesting": "0.3.0-*", - "Microsoft.AspNetCore.Testing": "1.2.0-*", - "Microsoft.Extensions.Logging": "1.2.0-*", - "Microsoft.Extensions.Logging.Console": "1.2.0-*", - "Microsoft.Extensions.PlatformAbstractions": "1.2.0-*", - "System.Diagnostics.FileVersionInfo": "4.4.0-*", - "xunit": "2.2.0-*" - }, - "testRunner": "xunit", - "frameworks": { - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.2.0-*", - "type": "platform" - } - } - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj new file mode 100644 index 0000000000..1ae595028c --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj @@ -0,0 +1,27 @@ + + + + + + net451;netcoreapp1.1 + + win7-x64 + + + + + + + + + + + + + + + + + + + diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.xproj b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.xproj deleted file mode 100644 index 7ad8fa523a..0000000000 --- a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0.25420 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 5afa74f5-9b1d-4fc5-815f-ef471f5ac1ef - Microsoft.AspNetCore.WebSockets.Test - .\obj - .\bin\ - - - - 2.0 - - - \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Properties/AssemblyInfo.cs b/test/Microsoft.AspNetCore.WebSockets.Test/Properties/AssemblyInfo.cs deleted file mode 100644 index e1fe33792e..0000000000 --- a/test/Microsoft.AspNetCore.WebSockets.Test/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Microsoft.AspNetCore.WebSockets.Protocol.Test")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("aaf2dfcf-845e-4410-bbf0-0683ad60dd6a")] diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/project.json b/test/Microsoft.AspNetCore.WebSockets.Test/project.json deleted file mode 100644 index 757bf1e2e0..0000000000 --- a/test/Microsoft.AspNetCore.WebSockets.Test/project.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "dependencies": { - "dotnet-test-xunit": "2.2.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", - "Microsoft.AspNetCore.Testing": "1.2.0-*", - "Microsoft.AspNetCore.WebSockets": "1.1.0-*", - "xunit": "2.2.0-*" - }, - "testRunner": "xunit", - "frameworks": { - "net451": {}, - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.2.0-*", - "type": "platform" - }, - "System.Net.WebSockets.Client": "4.4.0-*" - } - } - } -} \ No newline at end of file diff --git a/version.props b/version.props new file mode 100644 index 0000000000..cd53f064e5 --- /dev/null +++ b/version.props @@ -0,0 +1,7 @@ + + + + 1.1.0 + preview1 + + From 0f589a5b4cd9721275c99aed2607616405b92384 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 2 Feb 2017 14:25:36 -0800 Subject: [PATCH 267/453] Allow non-strict result for Autobahn case 4.1.3 (written by @anurse) --- .../AutobahnTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs index 76c5080286..3f0e8e0fec 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs @@ -72,7 +72,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest // WebListener occasionally gives a non-strict response on 3.2. IIS Express seems to have the same behavior. Wonder if it's related to HttpSys? // For now, just allow the non-strict response, it's not a failure. await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token, expectationConfig: expect => expect - .OkOrNonStrict("3.2", "4.2.4")); + .OkOrNonStrict("3.2", "4.1.3", "4.2.4")); } } From 450ee8927c83006c41740c1c6c843f4f455c06e4 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 2 Feb 2017 18:33:48 -0800 Subject: [PATCH 268/453] Workaround dotnet test pathing issues --- .../Autobahn/AutobahnTester.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index 045e86428c..0f84b5a7a1 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -60,7 +60,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn cancellationToken.ThrowIfCancellationRequested(); // Parse the output. - var outputFile = Path.Combine(Directory.GetCurrentDirectory(), Spec.OutputDirectory, "index.json"); + var outputFile = Path.Combine(Directory.GetCurrentDirectory(), "..", "..", "..", Spec.OutputDirectory, "index.json"); using (var reader = new StreamReader(File.OpenRead(outputFile))) { return AutobahnResult.FromReportJson(JObject.Parse(await reader.ReadToEndAsync())); @@ -95,6 +95,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn var logger = _loggerFactory.CreateLogger($"AutobahnTestApp:{server}:{sslNamePart}:{environment}"); var appPath = Helpers.GetApplicationPath("AutobahnTestApp"); + var configPath = Path.Combine(Directory.GetCurrentDirectory(), "..", "..", "..", "Http.config"); var parameters = new DeploymentParameters(appPath, server, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64) { ApplicationBaseUriHint = baseUrl, @@ -102,7 +103,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn TargetFramework = "netcoreapp1.1", EnvironmentName = environment, SiteName = "HttpTestSite", // This is configured in the Http.config - ServerConfigTemplateContent = (server == ServerType.IISExpress) ? File.ReadAllText("Http.config") : null, + ServerConfigTemplateContent = (server == ServerType.IISExpress) ? File.ReadAllText(configPath) : null, }; var deployer = ApplicationDeployerFactory.Create(parameters, logger); From d84de39721eeae28a5e8a1a293609ec2e54e7947 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Mon, 13 Feb 2017 14:25:20 -0800 Subject: [PATCH 269/453] Replace makefile.shade and update test TFM to net452 --- build/repo.targets | 9 +++++++++ makefile.shade | 15 --------------- test/AutobahnTestApp/AutobahnTestApp.csproj | 7 ++++++- .../Microsoft.AspNetCore.WebSockets.Test.csproj | 3 ++- 4 files changed, 17 insertions(+), 17 deletions(-) create mode 100644 build/repo.targets delete mode 100644 makefile.shade diff --git a/build/repo.targets b/build/repo.targets new file mode 100644 index 0000000000..ba1cb89555 --- /dev/null +++ b/build/repo.targets @@ -0,0 +1,9 @@ + + + $(ArtifactsDir)autobahnreports\ + + + + + + \ No newline at end of file diff --git a/makefile.shade b/makefile.shade deleted file mode 100644 index ecfd6668cc..0000000000 --- a/makefile.shade +++ /dev/null @@ -1,15 +0,0 @@ -use namespace="System.IO" - -var VERSION='0.1' -var FULL_VERSION='0.1' -var AUTHORS='Microsoft' - -use-standard-lifecycle -k-standard-goals - -var AUTOBAHN_REPORTS_DIR='${Path.Combine(Directory.GetCurrentDirectory(), "artifacts", "autobahnreports")}' - -#set-autobahn-report-dir target='initialize' - @{ - E("AUTOBAHN_SUITES_REPORT_DIR", AUTOBAHN_REPORTS_DIR); - } diff --git a/test/AutobahnTestApp/AutobahnTestApp.csproj b/test/AutobahnTestApp/AutobahnTestApp.csproj index 123ce068e5..869b258cd5 100644 --- a/test/AutobahnTestApp/AutobahnTestApp.csproj +++ b/test/AutobahnTestApp/AutobahnTestApp.csproj @@ -1,16 +1,20 @@  + + netcoreapp1.1 Exe + - + + @@ -21,4 +25,5 @@ + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj index 1ae595028c..ee981e14c3 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj @@ -3,7 +3,8 @@ - net451;netcoreapp1.1 + net452;netcoreapp1.1 + netcoreapp1.1 win7-x64 From df21a8251688c089e0d34f3769cc4eec24d27d04 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 14 Feb 2017 16:03:53 -0800 Subject: [PATCH 270/453] Downgrade to stable packages --- build/common.props | 3 +-- build/dependencies.props | 6 ++++++ .../Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj | 2 +- .../Microsoft.AspNetCore.WebSockets.Test.csproj | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 build/dependencies.props diff --git a/build/common.props b/build/common.props index e4307101fb..3afdffe756 100644 --- a/build/common.props +++ b/build/common.props @@ -1,4 +1,5 @@ + @@ -8,8 +9,6 @@ $(MSBuildThisFileDirectory)Key.snk true true - 1.2.0-* - 1.6.2-* $(VersionSuffix)-$(BuildNumber) diff --git a/build/dependencies.props b/build/dependencies.props new file mode 100644 index 0000000000..e704edaec0 --- /dev/null +++ b/build/dependencies.props @@ -0,0 +1,6 @@ + + + 1.6.1 + 4.3.0 + + diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj index f5a9792cd6..f68e21f60d 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj @@ -13,7 +13,7 @@ - + diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj index ee981e14c3..b1163a5c30 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj @@ -22,7 +22,7 @@ - + From 1d67db92c25d1b33a41b0daf69d31d25e9c079d1 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 16 Feb 2017 10:05:34 -0800 Subject: [PATCH 271/453] React to aspnet/Korebuild#160 --- build/repo.props | 5 +++++ build/repo.targets | 2 +- test/AutobahnTestApp/.notest | 0 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 build/repo.props delete mode 100644 test/AutobahnTestApp/.notest diff --git a/build/repo.props b/build/repo.props new file mode 100644 index 0000000000..3aad2de9e6 --- /dev/null +++ b/build/repo.props @@ -0,0 +1,5 @@ + + + + + diff --git a/build/repo.targets b/build/repo.targets index ba1cb89555..1767331014 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -6,4 +6,4 @@ - \ No newline at end of file + diff --git a/test/AutobahnTestApp/.notest b/test/AutobahnTestApp/.notest deleted file mode 100644 index e69de29bb2..0000000000 From 7696a8e82de17f806c52650e8b553642348f4de4 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 1 Mar 2017 18:14:13 -0800 Subject: [PATCH 272/453] Change korebuild branch and fix argument forwarding in bootstrapper --- build.ps1 | 16 ++++++++-------- build.sh | 22 +++++++++++----------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/build.ps1 b/build.ps1 index 0605b59c01..5bf0e2c113 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,6 +1,6 @@ $ErrorActionPreference = "Stop" -function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries) +function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries) { while($true) { @@ -19,7 +19,7 @@ function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $ret Start-Sleep -Seconds 10 } - else + else { $exception = $_.Exception throw $exception @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/feature/msbuild.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP @@ -43,18 +43,18 @@ $buildFolder = ".build" $buildFile="$buildFolder\KoreBuild.ps1" if (!(Test-Path $buildFolder)) { - Write-Host "Downloading KoreBuild from $koreBuildZip" - + Write-Host "Downloading KoreBuild from $koreBuildZip" + $tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid() New-Item -Path "$tempFolder" -Type directory | Out-Null $localZipFile="$tempFolder\korebuild.zip" - + DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6 Add-Type -AssemblyName System.IO.Compression.FileSystem [System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder) - + New-Item -Path "$buildFolder" -Type directory | Out-Null copy-item "$tempFolder\**\build\*" $buildFolder -Recurse @@ -64,4 +64,4 @@ if (!(Test-Path $buildFolder)) { } } -&"$buildFile" $args \ No newline at end of file +&"$buildFile" @args diff --git a/build.sh b/build.sh index 07997d6c83..b0bcadb579 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/feature/msbuild.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi @@ -12,12 +12,12 @@ buildFile="$buildFolder/KoreBuild.sh" if test ! -d $buildFolder; then echo "Downloading KoreBuild from $koreBuildZip" - - tempFolder="/tmp/KoreBuild-$(uuidgen)" + + tempFolder="/tmp/KoreBuild-$(uuidgen)" mkdir $tempFolder - + localZipFile="$tempFolder/korebuild.zip" - + retries=6 until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null) do @@ -29,18 +29,18 @@ if test ! -d $buildFolder; then echo "Waiting 10 seconds before retrying. Retries left: $retries" sleep 10s done - + unzip -q -d $tempFolder $localZipFile - + mkdir $buildFolder cp -r $tempFolder/**/build/** $buildFolder - + chmod +x $buildFile - + # Cleanup if test -d $tempFolder; then - rm -rf $tempFolder + rm -rf $tempFolder fi fi -$buildFile -r $repoFolder "$@" \ No newline at end of file +$buildFile -r $repoFolder "$@" From c36fcbab2e2756d738cdf0c56523183dee8db950 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 1 Mar 2017 18:25:39 -0800 Subject: [PATCH 273/453] Update AppVeyor and Travis settings --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0a218b46bf..c5631b3af9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,4 +33,4 @@ before_install: install: - sudo pip install autobahntestsuite "six>=1.9.0" script: - - ./build.sh --quiet verify + - ./build.sh diff --git a/appveyor.yml b/appveyor.yml index 0e6f4dfa84..3a702b88c1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,7 +7,7 @@ branches: - dev - /^(.*\/)?ci-.*$/ build_script: - - build.cmd --quiet verify + - ps: .\build.ps1 install: - set PATH=C:\Python27\scripts;%PATH% - pip install autobahntestsuite From 4eb3a3573574c5e05240db3ac406d13eebab2eff Mon Sep 17 00:00:00 2001 From: David Fowler Date: Wed, 8 Mar 2017 20:51:02 -0800 Subject: [PATCH 274/453] Update .travis.yml --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c5631b3af9..b2cc122e1a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,7 @@ env: global: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_CLI_TELEMETRY_OPTOUT: 1 -mono: - - 4.0.5 +mono: none python: - "2.7" os: From 37b0df7406d8c19e076367a6cdfa8f904e7a524e Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 9 Mar 2017 10:14:42 -0800 Subject: [PATCH 275/453] port change from AutobahnTester in SignalR (#148) We increased the retry count (by just removing ours and using the default) because the app seems to be slow to start on macOS --- .../Autobahn/AutobahnTester.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index 0f84b5a7a1..66e1781241 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -131,7 +131,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { cancellationToken.ThrowIfCancellationRequested(); return client.GetAsync(result.ApplicationBaseUri); - }, logger, CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, result.HostShutdownToken).Token, retryCount: 5); + }, logger, CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, result.HostShutdownToken).Token); resp.EnsureSuccessStatusCode(); cancellationToken.ThrowIfCancellationRequested(); From 9b553ca1c06ab0b8b25ec89410bdca54e2186e5d Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Mon, 13 Mar 2017 15:40:55 -0700 Subject: [PATCH 276/453] make all tests allow 'non-strict' conformance (#149) --- .travis.yml | 2 +- WebSockets.sln | 82 +++++++++---------- .../Autobahn/AutobahnExpectations.cs | 11 +-- .../Autobahn/Expectation.cs | 3 +- .../AutobahnTests.cs | 6 +- 5 files changed, 47 insertions(+), 57 deletions(-) diff --git a/.travis.yml b/.travis.yml index b2cc122e1a..0dcc21dd07 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,6 @@ branches: before_install: - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl python; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi install: - - sudo pip install autobahntestsuite "six>=1.9.0" + - pip install autobahntestsuite "six>=1.9.0" script: - ./build.sh diff --git a/WebSockets.sln b/WebSockets.sln index fbe3ca6412..39500452f8 100644 --- a/WebSockets.sln +++ b/WebSockets.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26123.0 +VisualStudioVersion = 15.0.26228.4 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2C7947A5-9FBD-4267-97C1-2D726D7B3BAF}" EndProject @@ -63,64 +63,64 @@ Global {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Release|x86.Build.0 = Release|Any CPU {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Debug|x64.ActiveCfg = Debug|x64 - {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Debug|x64.Build.0 = Debug|x64 - {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Debug|x86.ActiveCfg = Debug|x86 - {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Debug|x86.Build.0 = Debug|x86 + {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Debug|x64.ActiveCfg = Debug|Any CPU + {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Debug|x64.Build.0 = Debug|Any CPU + {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Debug|x86.ActiveCfg = Debug|Any CPU + {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Debug|x86.Build.0 = Debug|Any CPU {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Release|Any CPU.ActiveCfg = Release|Any CPU {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Release|Any CPU.Build.0 = Release|Any CPU - {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Release|x64.ActiveCfg = Release|x64 - {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Release|x64.Build.0 = Release|x64 - {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Release|x86.ActiveCfg = Release|x86 - {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Release|x86.Build.0 = Release|x86 + {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Release|x64.ActiveCfg = Release|Any CPU + {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Release|x64.Build.0 = Release|Any CPU + {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Release|x86.ActiveCfg = Release|Any CPU + {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Release|x86.Build.0 = Release|Any CPU {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Debug|x64.ActiveCfg = Debug|x64 - {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Debug|x64.Build.0 = Debug|x64 - {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Debug|x86.ActiveCfg = Debug|x86 - {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Debug|x86.Build.0 = Debug|x86 + {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Debug|x64.ActiveCfg = Debug|Any CPU + {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Debug|x64.Build.0 = Debug|Any CPU + {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Debug|x86.ActiveCfg = Debug|Any CPU + {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Debug|x86.Build.0 = Debug|Any CPU {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Release|Any CPU.ActiveCfg = Release|Any CPU {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Release|Any CPU.Build.0 = Release|Any CPU - {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Release|x64.ActiveCfg = Release|x64 - {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Release|x64.Build.0 = Release|x64 - {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Release|x86.ActiveCfg = Release|x86 - {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Release|x86.Build.0 = Release|x86 + {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Release|x64.ActiveCfg = Release|Any CPU + {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Release|x64.Build.0 = Release|Any CPU + {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Release|x86.ActiveCfg = Release|Any CPU + {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF}.Release|x86.Build.0 = Release|Any CPU {74F45408-1959-4FEE-9511-25D40F4913FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {74F45408-1959-4FEE-9511-25D40F4913FD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {74F45408-1959-4FEE-9511-25D40F4913FD}.Debug|x64.ActiveCfg = Debug|x64 - {74F45408-1959-4FEE-9511-25D40F4913FD}.Debug|x64.Build.0 = Debug|x64 - {74F45408-1959-4FEE-9511-25D40F4913FD}.Debug|x86.ActiveCfg = Debug|x86 - {74F45408-1959-4FEE-9511-25D40F4913FD}.Debug|x86.Build.0 = Debug|x86 + {74F45408-1959-4FEE-9511-25D40F4913FD}.Debug|x64.ActiveCfg = Debug|Any CPU + {74F45408-1959-4FEE-9511-25D40F4913FD}.Debug|x64.Build.0 = Debug|Any CPU + {74F45408-1959-4FEE-9511-25D40F4913FD}.Debug|x86.ActiveCfg = Debug|Any CPU + {74F45408-1959-4FEE-9511-25D40F4913FD}.Debug|x86.Build.0 = Debug|Any CPU {74F45408-1959-4FEE-9511-25D40F4913FD}.Release|Any CPU.ActiveCfg = Release|Any CPU {74F45408-1959-4FEE-9511-25D40F4913FD}.Release|Any CPU.Build.0 = Release|Any CPU - {74F45408-1959-4FEE-9511-25D40F4913FD}.Release|x64.ActiveCfg = Release|x64 - {74F45408-1959-4FEE-9511-25D40F4913FD}.Release|x64.Build.0 = Release|x64 - {74F45408-1959-4FEE-9511-25D40F4913FD}.Release|x86.ActiveCfg = Release|x86 - {74F45408-1959-4FEE-9511-25D40F4913FD}.Release|x86.Build.0 = Release|x86 + {74F45408-1959-4FEE-9511-25D40F4913FD}.Release|x64.ActiveCfg = Release|Any CPU + {74F45408-1959-4FEE-9511-25D40F4913FD}.Release|x64.Build.0 = Release|Any CPU + {74F45408-1959-4FEE-9511-25D40F4913FD}.Release|x86.ActiveCfg = Release|Any CPU + {74F45408-1959-4FEE-9511-25D40F4913FD}.Release|x86.Build.0 = Release|Any CPU {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Debug|x64.ActiveCfg = Debug|x64 - {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Debug|x64.Build.0 = Debug|x64 - {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Debug|x86.ActiveCfg = Debug|x86 - {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Debug|x86.Build.0 = Debug|x86 + {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Debug|x64.ActiveCfg = Debug|Any CPU + {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Debug|x64.Build.0 = Debug|Any CPU + {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Debug|x86.ActiveCfg = Debug|Any CPU + {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Debug|x86.Build.0 = Debug|Any CPU {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Release|Any CPU.ActiveCfg = Release|Any CPU {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Release|Any CPU.Build.0 = Release|Any CPU - {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Release|x64.ActiveCfg = Release|x64 - {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Release|x64.Build.0 = Release|x64 - {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Release|x86.ActiveCfg = Release|x86 - {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Release|x86.Build.0 = Release|x86 + {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Release|x64.ActiveCfg = Release|Any CPU + {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Release|x64.Build.0 = Release|Any CPU + {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Release|x86.ActiveCfg = Release|Any CPU + {421954B0-5C6B-4092-8D4D-EACA4CE60AFB}.Release|x86.Build.0 = Release|Any CPU {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Debug|x64.ActiveCfg = Debug|x64 - {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Debug|x64.Build.0 = Debug|x64 - {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Debug|x86.ActiveCfg = Debug|x86 - {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Debug|x86.Build.0 = Debug|x86 + {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Debug|x64.ActiveCfg = Debug|Any CPU + {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Debug|x64.Build.0 = Debug|Any CPU + {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Debug|x86.ActiveCfg = Debug|Any CPU + {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Debug|x86.Build.0 = Debug|Any CPU {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Release|Any CPU.ActiveCfg = Release|Any CPU {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Release|Any CPU.Build.0 = Release|Any CPU - {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Release|x64.ActiveCfg = Release|x64 - {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Release|x64.Build.0 = Release|x64 - {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Release|x86.ActiveCfg = Release|x86 - {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Release|x86.Build.0 = Release|x86 + {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Release|x64.ActiveCfg = Release|Any CPU + {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Release|x64.Build.0 = Release|Any CPU + {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Release|x86.ActiveCfg = Release|Any CPU + {150DF5A8-87C6-42F7-8886-CE07BFD02FD2}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnExpectations.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnExpectations.cs index a616d6f489..ea0667cf77 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnExpectations.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnExpectations.cs @@ -21,7 +21,6 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn public AutobahnExpectations Fail(params string[] caseSpecs) => Expect(Expectation.Fail, caseSpecs); public AutobahnExpectations NonStrict(params string[] caseSpecs) => Expect(Expectation.NonStrict, caseSpecs); - public AutobahnExpectations OkOrNonStrict(params string[] caseSpecs) => Expect(Expectation.OkOrNonStrict, caseSpecs); public AutobahnExpectations OkOrFail(params string[] caseSpecs) => Expect(Expectation.OkOrFail, caseSpecs); public AutobahnExpectations Expect(Expectation expectation, params string[] caseSpecs) @@ -61,21 +60,15 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn } break; case Expectation.Ok: - if (!caseResult.BehaviorIs("OK")) - { - failures.AppendLine($"Case {serverResult.Name}:{caseResult.Name}. Expected 'OK', but got '{caseResult.ActualBehavior}'"); - } - break; - case Expectation.OkOrNonStrict: if (!caseResult.BehaviorIs("NON-STRICT") && !caseResult.BehaviorIs("OK")) { failures.AppendLine($"Case {serverResult.Name}:{caseResult.Name}. Expected 'NON-STRICT' or 'OK', but got '{caseResult.ActualBehavior}'"); } break; case Expectation.OkOrFail: - if (!caseResult.BehaviorIs("FAILED") && !caseResult.BehaviorIs("OK")) + if (!caseResult.BehaviorIs("NON-STRICT") && !caseResult.BehaviorIs("FAILED") && !caseResult.BehaviorIs("OK")) { - failures.AppendLine($"Case {serverResult.Name}:{caseResult.Name}. Expected 'FAILED' or 'OK', but got '{caseResult.ActualBehavior}'"); + failures.AppendLine($"Case {serverResult.Name}:{caseResult.Name}. Expected 'FAILED', 'NON-STRICT' or 'OK', but got '{caseResult.ActualBehavior}'"); } break; default: diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Expectation.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Expectation.cs index 0661b0d02f..28ba5005c1 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Expectation.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Expectation.cs @@ -5,7 +5,6 @@ Fail, NonStrict, OkOrFail, - Ok, - OkOrNonStrict + Ok } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs index 3f0e8e0fec..98757be0c6 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs @@ -65,14 +65,12 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest // IIS Express tests are a bit flaky, some tests fail occasionally or get non-strict passes // https://github.com/aspnet/WebSockets/issues/100 await tester.DeployTestAndAddToSpec(ServerType.IISExpress, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token, expectationConfig: expect => expect - .OkOrFail(Enumerable.Range(1, 20).Select(i => $"5.{i}").ToArray()) // 5.* occasionally fail on IIS express - .OkOrNonStrict("3.2", "3.3", "3.4", "4.1.3", "4.1.4", "4.1.5", "4.2.3", "4.2.4", "4.2.5", "5.15")); // These occasionally get non-strict results + .OkOrFail(Enumerable.Range(1, 20).Select(i => $"5.{i}").ToArray())); // 5.* occasionally fail on IIS express } // WebListener occasionally gives a non-strict response on 3.2. IIS Express seems to have the same behavior. Wonder if it's related to HttpSys? // For now, just allow the non-strict response, it's not a failure. - await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token, expectationConfig: expect => expect - .OkOrNonStrict("3.2", "4.1.3", "4.2.4")); + await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token); } } From 92b37f85c25a6d2a877584f8cf09e57599358f44 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Mon, 13 Mar 2017 15:40:04 -0700 Subject: [PATCH 277/453] disable AutobahnTestAppHttpListener from build --- WebSockets.sln | 15 --------------- ... => AutobahnTestAppHttpListener.csproj.net461} | 0 ...t.AspNetCore.WebSockets.ConformanceTest.csproj | 4 ++++ 3 files changed, 4 insertions(+), 15 deletions(-) rename samples/AutobahnTestAppHttpListener/{AutobahnTestAppHttpListener.csproj => AutobahnTestAppHttpListener.csproj.net461} (100%) diff --git a/WebSockets.sln b/WebSockets.sln index 39500452f8..30be8b4f80 100644 --- a/WebSockets.sln +++ b/WebSockets.sln @@ -10,8 +10,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{9E55 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestServer", "samples\TestServer\TestServer.csproj", "{4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutobahnTestAppHttpListener", "samples\AutobahnTestAppHttpListener\AutobahnTestAppHttpListener.csproj", "{B7246F23-6A4B-492F-AB61-292AA1A9E9D5}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{19595D64-E42E-46FD-AB2E-BDC870724EE7}" ProjectSection(SolutionItems) = preProject scripts\UpdateCoreFxCode.ps1 = scripts\UpdateCoreFxCode.ps1 @@ -49,18 +47,6 @@ Global {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Release|x64.Build.0 = Release|Any CPU {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Release|x86.ActiveCfg = Release|Any CPU {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B}.Release|x86.Build.0 = Release|Any CPU - {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Debug|x64.ActiveCfg = Debug|Any CPU - {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Debug|x64.Build.0 = Debug|Any CPU - {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Debug|x86.ActiveCfg = Debug|Any CPU - {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Debug|x86.Build.0 = Debug|Any CPU - {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Release|Any CPU.Build.0 = Release|Any CPU - {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Release|x64.ActiveCfg = Release|Any CPU - {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Release|x64.Build.0 = Release|Any CPU - {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Release|x86.ActiveCfg = Release|Any CPU - {B7246F23-6A4B-492F-AB61-292AA1A9E9D5}.Release|x86.Build.0 = Release|Any CPU {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Debug|Any CPU.Build.0 = Debug|Any CPU {CDE16880-0374-46FA-8896-99F1B90B4B6F}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -127,7 +113,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {4E5F5FCC-172C-44D9-BEA0-39098A79CD0B} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} - {B7246F23-6A4B-492F-AB61-292AA1A9E9D5} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} {CDE16880-0374-46FA-8896-99F1B90B4B6F} = {2C7947A5-9FBD-4267-97C1-2D726D7B3BAF} {5AFA74F5-9B1D-4FC5-815F-EF471F5AC1EF} = {C45106D0-76C8-4776-A140-F7DD83CA2958} {74F45408-1959-4FEE-9511-25D40F4913FD} = {C45106D0-76C8-4776-A140-F7DD83CA2958} diff --git a/samples/AutobahnTestAppHttpListener/AutobahnTestAppHttpListener.csproj b/samples/AutobahnTestAppHttpListener/AutobahnTestAppHttpListener.csproj.net461 similarity index 100% rename from samples/AutobahnTestAppHttpListener/AutobahnTestAppHttpListener.csproj rename to samples/AutobahnTestAppHttpListener/AutobahnTestAppHttpListener.csproj.net461 diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj index f68e21f60d..bf1315293c 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj @@ -18,4 +18,8 @@ + + + + From cb150de8084f6df0dcf9013a4562e6d782f37b3c Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Tue, 14 Mar 2017 12:04:59 -0700 Subject: [PATCH 278/453] port dotnet/corefx#17049 (#151) --- scripts/UpdateCoreFxCode.ps1 | 2 +- .../Internal/WebSocketFactory.cs | 6 +- .../System/Net/WebSockets/ManagedWebSocket.cs | 250 ++++++++++++------ .../Net/WebSockets/WebSocketValidate.cs | 64 +++-- .../Microsoft.AspNetCore.WebSockets.csproj | 1 + 5 files changed, 221 insertions(+), 102 deletions(-) rename src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/{System.Net.WebSockets.Client => Common}/src/System/Net/WebSockets/ManagedWebSocket.cs (86%) diff --git a/scripts/UpdateCoreFxCode.ps1 b/scripts/UpdateCoreFxCode.ps1 index d94e04a161..09cfc3e448 100644 --- a/scripts/UpdateCoreFxCode.ps1 +++ b/scripts/UpdateCoreFxCode.ps1 @@ -3,7 +3,7 @@ param([string]$CoreFxRepoRoot) $RepoRoot = Split-Path -Parent $PSScriptRoot $FilesToCopy = @( - "src\System.Net.WebSockets.Client\src\System\Net\WebSockets\ManagedWebSocket.cs", + "src\Common\src\System\Net\WebSockets\ManagedWebSocket.cs", "src\Common\src\System\Net\WebSockets\WebSocketValidate.cs" ) diff --git a/src/Microsoft.AspNetCore.WebSockets/Internal/WebSocketFactory.cs b/src/Microsoft.AspNetCore.WebSockets/Internal/WebSocketFactory.cs index 9946d5e9b2..d9f13b6d3d 100644 --- a/src/Microsoft.AspNetCore.WebSockets/Internal/WebSocketFactory.cs +++ b/src/Microsoft.AspNetCore.WebSockets/Internal/WebSocketFactory.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.WebSockets.Internal stream, isServer: false, subprotocol: subProtocol, - keepAliveIntervalSeconds: (int)keepAliveInterval.TotalSeconds, + keepAliveInterval: keepAliveInterval, receiveBufferSize: receiveBufferSize); } @@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.WebSockets.Internal stream, isServer: true, subprotocol: subProtocol, - keepAliveIntervalSeconds: (int)keepAliveInterval.TotalSeconds, + keepAliveInterval: keepAliveInterval, receiveBufferSize: receiveBufferSize); } } diff --git a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ManagedWebSocket.cs b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/ManagedWebSocket.cs similarity index 86% rename from src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ManagedWebSocket.cs rename to src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/ManagedWebSocket.cs index 8253aebde5..494b6a786d 100644 --- a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ManagedWebSocket.cs +++ b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/ManagedWebSocket.cs @@ -2,8 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Buffers; using System.Diagnostics; using System.IO; +using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security.Cryptography; @@ -30,14 +32,14 @@ namespace System.Net.WebSockets /// The connected Stream. /// true if this is the server-side of the connection; false if this is the client-side of the connection. /// The agreed upon subprotocol for the connection. - /// The interval to use for keep-alive pings. + /// The interval to use for keep-alive pings. /// The buffer size to use for received data. + /// Optional buffer to use for receives. /// The created instance. public static ManagedWebSocket CreateFromConnectedStream( - Stream stream, bool isServer, string subprotocol, - int keepAliveIntervalSeconds = 30, int receiveBufferSize = 0x1000) + Stream stream, bool isServer, string subprotocol, TimeSpan keepAliveInterval, int receiveBufferSize, ArraySegment? receiveBuffer = null) { - return new ManagedWebSocket(stream, isServer, subprotocol, TimeSpan.FromSeconds(keepAliveIntervalSeconds), receiveBufferSize); + return new ManagedWebSocket(stream, isServer, subprotocol, keepAliveInterval, receiveBufferSize, receiveBuffer); } /// Per-thread cached 4-byte mask byte array. @@ -81,7 +83,9 @@ namespace System.Net.WebSockets /// CancellationTokenSource used to abort all current and future operations when anything is canceled or any error occurs. private readonly CancellationTokenSource _abortSource = new CancellationTokenSource(); /// Buffer used for reading data from the network. - private readonly byte[] _receiveBuffer; + private byte[] _receiveBuffer; + /// Gets whether the receive buffer came from the ArrayPool. + private readonly bool _receiveBufferFromPool; /// /// Tracks the state of the validity of the UTF8 encoding of text payloads. Text may be split across fragments. /// @@ -132,9 +136,10 @@ namespace System.Net.WebSockets ///
private int _receivedMaskOffsetOffset = 0; /// - /// Buffer used to store the complete message to be sent to the stream. This is needed - /// rather than just sending a header and then the user's buffer, as we need to mutate the - /// buffered data with the mask, and we don't want to change the data in the user's buffer. + /// Temporary send buffer. This should be released back to the ArrayPool once it's + /// no longer needed for the current send operation. It is stored as an instance + /// field to minimize needing to pass it around and to avoid it becoming a field on + /// various async state machine objects. /// private byte[] _sendBuffer; /// @@ -168,7 +173,8 @@ namespace System.Net.WebSockets /// The agreed upon subprotocol for the connection. /// The interval to use for keep-alive pings. /// The buffer size to use for received data. - private ManagedWebSocket(Stream stream, bool isServer, string subprotocol, TimeSpan keepAliveInterval, int receiveBufferSize) + /// Optional buffer to use for receives + private ManagedWebSocket(Stream stream, bool isServer, string subprotocol, TimeSpan keepAliveInterval, int receiveBufferSize, ArraySegment? receiveBuffer) { Debug.Assert(StateUpdateLock != null, $"Expected {nameof(StateUpdateLock)} to be non-null"); Debug.Assert(ReceiveAsyncLock != null, $"Expected {nameof(ReceiveAsyncLock)} to be non-null"); @@ -183,7 +189,20 @@ namespace System.Net.WebSockets _stream = stream; _isServer = isServer; _subprotocol = subprotocol; - _receiveBuffer = new byte[Math.Max(receiveBufferSize, MaxMessageHeaderLength)]; + + // If we were provided with a buffer to use, use it, as long as it's big enough for our needs, and for simplicity + // as long as we're not supposed to use only a portion of it. If it doesn't meet our criteria, just create a new one. + if (receiveBuffer.HasValue && + receiveBuffer.Value.Offset == 0 && receiveBuffer.Value.Count == receiveBuffer.Value.Array.Length && + receiveBuffer.Value.Count >= MaxMessageHeaderLength) + { + _receiveBuffer = receiveBuffer.Value.Array; + } + else + { + _receiveBufferFromPool = true; + _receiveBuffer = ArrayPool.Shared.Rent(Math.Max(receiveBufferSize, MaxMessageHeaderLength)); + } // Set up the abort source so that if it's triggered, we transition the instance appropriately. _abortSource.Token.Register(s => @@ -225,6 +244,12 @@ namespace System.Net.WebSockets _disposed = true; _keepAliveTimer?.Dispose(); _stream?.Dispose(); + if (_receiveBufferFromPool) + { + byte[] old = _receiveBuffer; + _receiveBuffer = null; + ArrayPool.Shared.Return(old); + } if (_state < WebSocketState.Aborted) { _state = WebSocketState.Closed; @@ -253,7 +278,7 @@ namespace System.Net.WebSockets try { - WebSocketValidate.ThrowIfInvalidState(_state, _disposed, s_validSendStates); + WebSocketValidate.ThrowIfInvalidState(_state, _disposed, s_validSendStates); ThrowIfOperationInProgress(_lastSendAsync); } catch (Exception exc) @@ -369,7 +394,7 @@ namespace System.Net.WebSockets // If we get here, the cancellation token is not cancelable so we don't have to worry about it, // and we own the semaphore, so we don't need to asynchronously wait for it. Task writeTask = null; - bool releaseSemaphore = true; + bool releaseSemaphoreAndSendBuffer = true; try { // Write the payload synchronously to the buffer, then write that buffer out to the network. @@ -386,9 +411,9 @@ namespace System.Net.WebSockets } // Up until this point, if an exception occurred (such as when accessing _stream or when - // calling GetResult), we want to release the semaphore. After this point, the semaphore needs - // to remain held until writeTask completes. - releaseSemaphore = false; + // calling GetResult), we want to release the semaphore and the send buffer. After this point, + // both need to be held until writeTask completes. + releaseSemaphoreAndSendBuffer = false; } catch (Exception exc) { @@ -398,9 +423,10 @@ namespace System.Net.WebSockets } finally { - if (releaseSemaphore) + if (releaseSemaphoreAndSendBuffer) { _sendFrameAsyncLock.Release(); + ReleaseSendBuffer(); } } @@ -410,6 +436,7 @@ namespace System.Net.WebSockets { var thisRef = (ManagedWebSocket)s; thisRef._sendFrameAsyncLock.Release(); + thisRef.ReleaseSendBuffer(); try { t.GetAwaiter().GetResult(); } catch (Exception exc) @@ -441,14 +468,15 @@ namespace System.Net.WebSockets finally { _sendFrameAsyncLock.Release(); + ReleaseSendBuffer(); } } /// Writes a frame into the send buffer, which can then be sent over the network. private int WriteFrameToSendBuffer(MessageOpcode opcode, bool endOfMessage, ArraySegment payloadBuffer) { - // Grow our send buffer as needed. We reuse the buffer for all messages, with it protected by the send frame lock. - EnsureBufferLength(ref _sendBuffer, payloadBuffer.Count + MaxMessageHeaderLength); + // Ensure we have a _sendBuffer. + AllocateSendBuffer(payloadBuffer.Count + MaxMessageHeaderLength); // Write the message header data to the buffer. int headerLength; @@ -542,7 +570,7 @@ namespace System.Net.WebSockets { sendBuffer[1] = 126; sendBuffer[2] = (byte)(payload.Count / 256); - sendBuffer[3] = (byte)payload.Count; + sendBuffer[3] = unchecked((byte)payload.Count); maskOffset = 2 + sizeof(ushort); // additional 2 bytes for 16-bit length } else @@ -551,7 +579,7 @@ namespace System.Net.WebSockets int length = payload.Count; for (int i = 9; i >= 2; i--) { - sendBuffer[i] = (byte)length; + sendBuffer[i] = unchecked((byte)length); length = length / 256; } maskOffset = 2 + sizeof(ulong); // additional 8 bytes for 64-bit length @@ -983,37 +1011,44 @@ namespace System.Net.WebSockets $"Unexpected state {State}."); // Wait until we've received a close response - byte[] closeBuffer = new byte[MaxMessageHeaderLength + MaxControlPayloadLength]; - while (!_receivedCloseFrame) + byte[] closeBuffer = ArrayPool.Shared.Rent(MaxMessageHeaderLength + MaxControlPayloadLength); + try { - Debug.Assert(!Monitor.IsEntered(StateUpdateLock), $"{nameof(StateUpdateLock)} must never be held when acquiring {nameof(ReceiveAsyncLock)}"); - Task receiveTask; - lock (ReceiveAsyncLock) + while (!_receivedCloseFrame) { - // Now that we're holding the ReceiveAsyncLock, double-check that we've not yet received the close frame. - // It could have been received between our check above and now due to a concurrent receive completing. - if (_receivedCloseFrame) + Debug.Assert(!Monitor.IsEntered(StateUpdateLock), $"{nameof(StateUpdateLock)} must never be held when acquiring {nameof(ReceiveAsyncLock)}"); + Task receiveTask; + lock (ReceiveAsyncLock) { - break; + // Now that we're holding the ReceiveAsyncLock, double-check that we've not yet received the close frame. + // It could have been received between our check above and now due to a concurrent receive completing. + if (_receivedCloseFrame) + { + break; + } + + // We've not yet processed a received close frame, which means we need to wait for a received close to complete. + // There may already be one in flight, in which case we want to just wait for that one rather than kicking off + // another (we don't support concurrent receive operations). We need to kick off a new receive if either we've + // never issued a receive or if the last issued receive completed for reasons other than a close frame. There is + // a race condition here, e.g. if there's a in-flight receive that completes after we check, but that's fine: worst + // case is we then await it, find that it's not what we need, and try again. + receiveTask = _lastReceiveAsync; + if (receiveTask == null || + (receiveTask.Status == TaskStatus.RanToCompletion && receiveTask.Result.MessageType != WebSocketMessageType.Close)) + { + _lastReceiveAsync = receiveTask = ReceiveAsyncPrivate(new ArraySegment(closeBuffer), cancellationToken); + } } - // We've not yet processed a received close frame, which means we need to wait for a received close to complete. - // There may already be one in flight, in which case we want to just wait for that one rather than kicking off - // another (we don't support concurrent receive operations). We need to kick off a new receive if either we've - // never issued a receive or if the last issued receive completed for reasons other than a close frame. There is - // a race condition here, e.g. if there's a in-flight receive that completes after we check, but that's fine: worst - // case is we then await it, find that it's not what we need, and try again. - receiveTask = _lastReceiveAsync; - if (receiveTask == null || - (receiveTask.Status == TaskStatus.RanToCompletion && receiveTask.Result.MessageType != WebSocketMessageType.Close)) - { - _lastReceiveAsync = receiveTask = ReceiveAsyncPrivate(new ArraySegment(closeBuffer), cancellationToken); - } + // Wait for whatever receive task we have. We'll then loop around again to re-check our state. + Debug.Assert(receiveTask != null); + await receiveTask.ConfigureAwait(false); } - - // Wait for whatever receive task we have. We'll then loop around again to re-check our state. - Debug.Assert(receiveTask != null); - await receiveTask.ConfigureAwait(false); + } + finally + { + ArrayPool.Shared.Return(closeBuffer); } // We're closed. Close the connection and update the status. @@ -1035,24 +1070,36 @@ namespace System.Net.WebSockets { // Close payload is two bytes containing the close status followed by a UTF8-encoding of the status description, if it exists. - byte[] buffer; - if (string.IsNullOrEmpty(closeStatusDescription)) + byte[] buffer = null; + try { - buffer = new byte[2]; + int count = 2; + if (string.IsNullOrEmpty(closeStatusDescription)) + { + buffer = ArrayPool.Shared.Rent(count); + } + else + { + count += s_textEncoding.GetByteCount(closeStatusDescription); + buffer = ArrayPool.Shared.Rent(count); + int encodedLength = s_textEncoding.GetBytes(closeStatusDescription, 0, closeStatusDescription.Length, buffer, 2); + Debug.Assert(count - 2 == encodedLength, $"GetByteCount and GetBytes encoded count didn't match"); + } + + ushort closeStatusValue = (ushort)closeStatus; + buffer[0] = (byte)(closeStatusValue >> 8); + buffer[1] = (byte)(closeStatusValue & 0xFF); + + await SendFrameAsync(MessageOpcode.Close, true, new ArraySegment(buffer, 0, count), cancellationToken).ConfigureAwait(false); } - else + finally { - buffer = new byte[2 + s_textEncoding.GetByteCount(closeStatusDescription)]; - int encodedLength = s_textEncoding.GetBytes(closeStatusDescription, 0, closeStatusDescription.Length, buffer, 2); - Debug.Assert(buffer.Length - 2 == encodedLength, $"GetByteCount and GetBytes encoded count didn't match"); + if (buffer != null) + { + ArrayPool.Shared.Return(buffer); + } } - ushort closeStatusValue = (ushort)closeStatus; - buffer[0] = (byte)(closeStatusValue >> 8); - buffer[1] = (byte)(closeStatusValue & 0xFF); - - await SendFrameAsync(MessageOpcode.Close, true, new ArraySegment(buffer), cancellationToken).ConfigureAwait(false); - lock (StateUpdateLock) { _sentCloseFrame = true; @@ -1111,15 +1158,21 @@ namespace System.Net.WebSockets } } - /// - /// Grows the specified buffer if it's not at least the specified minimum length. - /// Data is not copied if the buffer is grown. - /// - private static void EnsureBufferLength(ref byte[] buffer, int minLength) + /// Gets a send buffer from the pool. + private void AllocateSendBuffer(int minLength) { - if (buffer == null || buffer.Length < minLength) + Debug.Assert(_sendBuffer == null); // would only fail if had some catastrophic error previously that prevented cleaning up + _sendBuffer = ArrayPool.Shared.Rent(minLength); + } + + /// Releases the send buffer to the pool. + private void ReleaseSendBuffer() + { + byte[] old = _sendBuffer; + if (old != null) { - buffer = new byte[minLength]; + _sendBuffer = null; + ArrayPool.Shared.Return(old); } } @@ -1150,21 +1203,68 @@ namespace System.Net.WebSockets /// The next index into the mask to be used for future applications of the mask. private static unsafe int ApplyMask(byte[] toMask, int toMaskOffset, int mask, int maskIndex, long count) { - Debug.Assert(toMaskOffset <= toMask.Length - count, $"Unexpected inputs: {toMaskOffset}, {toMask.Length}, {count}"); - Debug.Assert(maskIndex < sizeof(int), $"Unexpected {nameof(maskIndex)}: {maskIndex}"); + int maskShift = maskIndex * 8; + int shiftedMask = (int)(((uint)mask >> maskShift) | ((uint)mask << (32 - maskShift))); - byte* maskPtr = (byte*)&mask; - fixed (byte* toMaskPtr = toMask) + // Try to use SIMD. We can if the number of bytes we're trying to mask is at least as much + // as the width of a vector and if the width is an even multiple of the mask. + if (Vector.IsHardwareAccelerated && + Vector.Count % sizeof(int) == 0 && + count >= Vector.Count) { - byte* p = toMaskPtr + toMaskOffset; - byte* end = p + count; - while (p < end) + // Mask bytes a vector at a time. + Vector maskVector = Vector.AsVectorByte(new Vector(shiftedMask)); + while (count >= Vector.Count) { - *p++ ^= maskPtr[maskIndex]; - maskIndex = (maskIndex + 1) & 3; // & 3 == faster % MaskLength + count -= Vector.Count; + (maskVector ^ new Vector(toMask, toMaskOffset)).CopyTo(toMask, toMaskOffset); + toMaskOffset += Vector.Count; } - return maskIndex; + + // Fall through to processing any remaining bytes that were less than a vector width. + // Since we processed full masks at a time, we don't need to update maskIndex, and + // toMaskOffset has already been updated to point to the correct location. } + + // If there are any bytes remaining (either we couldn't use vectors, or the count wasn't + // an even multiple of the vector width), process them without vectors. + if (count > 0) + { + fixed (byte* toMaskPtr = toMask) + { + // Get the location in the target array to continue processing. + byte* p = toMaskPtr + toMaskOffset; + + // Try to go an int at a time if the remaining data is 4-byte aligned and there's enough remaining. + if (((long)p % sizeof(int)) == 0) + { + while (count >= sizeof(int)) + { + count -= sizeof(int); + *((int*)p) ^= shiftedMask; + p += sizeof(int); + } + + // We don't need to update the maskIndex, as its mod-4 value won't have changed. + // `p` points to the remainder. + } + + // Process any remaining data a byte at a time. + if (count > 0) + { + byte* maskPtr = (byte*)&mask; + byte* end = p + count; + while (p < end) + { + *p++ ^= maskPtr[maskIndex]; + maskIndex = (maskIndex + 1) & 3; + } + } + } + } + + // Return the updated index. + return maskIndex; } /// Aborts the websocket and throws an exception if an existing operation is in progress. diff --git a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs index 06e07f29dd..4a1018610e 100644 --- a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs +++ b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs @@ -7,7 +7,7 @@ using System.Text; namespace System.Net.WebSockets { - internal static class WebSocketValidate + internal static partial class WebSocketValidate { internal const int MaxControlFramePayloadLength = 123; private const int CloseStatusCodeAbort = 1006; @@ -16,6 +16,34 @@ namespace System.Net.WebSockets private const int InvalidCloseStatusCodesTo = 999; private const string Separators = "()<>@,;:\\\"/[]?={} "; + internal static void ThrowIfInvalidState(WebSocketState currentState, bool isDisposed, WebSocketState[] validStates) + { + string validStatesText = string.Empty; + + if (validStates != null && validStates.Length > 0) + { + foreach (WebSocketState validState in validStates) + { + if (currentState == validState) + { + // Ordering is important to maintain .NET 4.5 WebSocket implementation exception behavior. + if (isDisposed) + { + throw new ObjectDisposedException("ClientWebSocket"); + } + + return; + } + } + + validStatesText = string.Join(", ", validStates); + } + + throw new WebSocketException( + WebSocketError.InvalidState, + SR.Format(SR.net_WebSockets_InvalidState, currentState, validStatesText)); + } + internal static void ValidateSubprotocol(string subProtocol) { if (string.IsNullOrWhiteSpace(subProtocol)) @@ -101,32 +129,22 @@ namespace System.Net.WebSockets } } - internal static void ThrowIfInvalidState(WebSocketState currentState, bool isDisposed, WebSocketState[] validStates) + internal static void ValidateBuffer(byte[] buffer, int offset, int count) { - string validStatesText = string.Empty; - - if (validStates != null && validStates.Length > 0) + if (buffer == null) { - foreach (WebSocketState validState in validStates) - { - if (currentState == validState) - { - // Ordering is important to maintain .NET 4.5 WebSocket implementation exception behavior. - if (isDisposed) - { - throw new ObjectDisposedException("ClientWebSocket"); - } - - return; - } - } - - validStatesText = string.Join(", ", validStates); + throw new ArgumentNullException(nameof(buffer)); } - throw new WebSocketException( - WebSocketError.InvalidState, - SR.Format(SR.net_WebSockets_InvalidState, currentState, validStatesText)); + if (offset < 0 || offset > buffer.Length) + { + throw new ArgumentOutOfRangeException(nameof(offset)); + } + + if (count < 0 || count > (buffer.Length - offset)) + { + throw new ArgumentOutOfRangeException(nameof(count)); + } } } } diff --git a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj index ed0bcaab59..40923e0978 100644 --- a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj +++ b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj @@ -14,6 +14,7 @@ + From f686e5f1ea26a925aca1f893fcdcbea594cd409d Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 14 Mar 2017 13:41:47 -0700 Subject: [PATCH 279/453] Update appveyor and travis settings --- .travis.yml | 1 - appveyor.yml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0dcc21dd07..358686a767 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,6 @@ python: os: - linux - osx -osx_image: xcode7.3 branches: only: - master diff --git a/appveyor.yml b/appveyor.yml index 3a702b88c1..9744c940ec 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,4 +14,4 @@ install: clone_depth: 1 test: off deploy: off -os: Visual Studio 2017 RC +os: Visual Studio 2017 From 4abe714f2b29a47ca368e80dfa97e52db5db6721 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 15 Mar 2017 19:29:21 -0700 Subject: [PATCH 280/453] Consolidate dependency versions into one file and remove workarounds --- .gitignore | 4 +--- build/dependencies.props | 7 ++++++- samples/EchoApp/EchoApp.csproj | 14 ++++++------- samples/EchoApp/runtimeconfig.template.json | 5 ----- samples/EchoApp/web.config | 14 ------------- .../Microsoft.AspNetCore.WebSockets.csproj | 4 ++-- test/AutobahnTestApp/AutobahnTestApp.csproj | 21 +++++++++---------- .../runtimeconfig.template.json | 5 ----- test/AutobahnTestApp/web.config | 14 ------------- ...pNetCore.WebSockets.ConformanceTest.csproj | 16 +++++++------- ...icrosoft.AspNetCore.WebSockets.Test.csproj | 13 ++++++------ 11 files changed, 40 insertions(+), 77 deletions(-) delete mode 100644 samples/EchoApp/runtimeconfig.template.json delete mode 100644 samples/EchoApp/web.config delete mode 100644 test/AutobahnTestApp/runtimeconfig.template.json delete mode 100644 test/AutobahnTestApp/web.config diff --git a/.gitignore b/.gitignore index 3d89b9fce4..b9545fe69a 100644 --- a/.gitignore +++ b/.gitignore @@ -23,10 +23,8 @@ nuget.exe *.*sdf *.ipch *.sln.ide -project.lock.json /.vs/ .testPublish/ .build/ autobahnreports/ -*.nuget.props -*.nuget.targets \ No newline at end of file +.vscode/ diff --git a/build/dependencies.props b/build/dependencies.props index e704edaec0..ecbe769d13 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,11 @@ - 1.6.1 + 1.2.0-* + 0.3.0-* + 1.0.0-* 4.3.0 + 1.6.1 + 15.0.0 + 2.2.0 diff --git a/samples/EchoApp/EchoApp.csproj b/samples/EchoApp/EchoApp.csproj index d28ce5eabb..0424007902 100644 --- a/samples/EchoApp/EchoApp.csproj +++ b/samples/EchoApp/EchoApp.csproj @@ -1,9 +1,9 @@ + + netcoreapp1.1 - true - Exe @@ -11,11 +11,11 @@ - - - - - + + + + + diff --git a/samples/EchoApp/runtimeconfig.template.json b/samples/EchoApp/runtimeconfig.template.json deleted file mode 100644 index 7305508a37..0000000000 --- a/samples/EchoApp/runtimeconfig.template.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "configProperties": { - "System.GC.Server": true - } -} \ No newline at end of file diff --git a/samples/EchoApp/web.config b/samples/EchoApp/web.config deleted file mode 100644 index dc0514fca5..0000000000 --- a/samples/EchoApp/web.config +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - diff --git a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj index 40923e0978..953fb4d119 100644 --- a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj +++ b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj @@ -12,8 +12,8 @@ - - + + diff --git a/test/AutobahnTestApp/AutobahnTestApp.csproj b/test/AutobahnTestApp/AutobahnTestApp.csproj index 869b258cd5..56d7f09dcd 100644 --- a/test/AutobahnTestApp/AutobahnTestApp.csproj +++ b/test/AutobahnTestApp/AutobahnTestApp.csproj @@ -1,10 +1,9 @@  - + netcoreapp1.1 - Exe @@ -16,14 +15,14 @@ - - - - - - - - + + + + + + + + - \ No newline at end of file + diff --git a/test/AutobahnTestApp/runtimeconfig.template.json b/test/AutobahnTestApp/runtimeconfig.template.json deleted file mode 100644 index 7305508a37..0000000000 --- a/test/AutobahnTestApp/runtimeconfig.template.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "configProperties": { - "System.GC.Server": true - } -} \ No newline at end of file diff --git a/test/AutobahnTestApp/web.config b/test/AutobahnTestApp/web.config deleted file mode 100644 index dc0514fca5..0000000000 --- a/test/AutobahnTestApp/web.config +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj index bf1315293c..58708a55fa 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj @@ -7,15 +7,15 @@ - - - - - - + + + + + + - - + + diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj index b1163a5c30..72c7be4d12 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj @@ -5,8 +5,7 @@ net452;netcoreapp1.1 netcoreapp1.1 - - win7-x64 + x64 @@ -14,11 +13,11 @@ - - - - - + + + + + From a61220d9073adf61e1424570a844f6a5367db46e Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Fri, 17 Mar 2017 15:09:18 -0700 Subject: [PATCH 281/453] suppress some Autobahn test failures (#153) * suppress some Autobahn test failures * disable autobahn in AppVeyor because they are flaky (port of aspnet/SignalR#302) --- appveyor.yml | 3 --- .../AutobahnTests.cs | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 9744c940ec..1041615c68 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,9 +8,6 @@ branches: - /^(.*\/)?ci-.*$/ build_script: - ps: .\build.ps1 -install: - - set PATH=C:\Python27\scripts;%PATH% - - pip install autobahntestsuite clone_depth: 1 test: off deploy: off diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs index 98757be0c6..760eb6ecca 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs @@ -65,6 +65,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest // IIS Express tests are a bit flaky, some tests fail occasionally or get non-strict passes // https://github.com/aspnet/WebSockets/issues/100 await tester.DeployTestAndAddToSpec(ServerType.IISExpress, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token, expectationConfig: expect => expect + .OkOrFail("2.6", "6.22.22") // Getting some transient failures on the CI for these. See https://github.com/aspnet/WebSockets/issues/152 .OkOrFail(Enumerable.Range(1, 20).Select(i => $"5.{i}").ToArray())); // 5.* occasionally fail on IIS express } From b79446ce5103737077e3293d261b75b279867aa2 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 21 Mar 2017 12:17:40 -0700 Subject: [PATCH 282/453] Update Travis to macOS Sierra [skip appveyor] --- .travis.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 358686a767..1513d96c35 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,6 @@ language: csharp -sudo: required +sudo: false dist: trusty -addons: - apt: - packages: - - gettext - - libcurl4-openssl-dev - - libicu-dev - - libssl-dev - - libunwind8 - - zlib1g env: global: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true @@ -20,6 +11,7 @@ python: os: - linux - osx +osx_image: xcode8.2 branches: only: - master From 52911cd3f143a7f5b0e87001403ee9eafc779435 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 21 Mar 2017 14:42:11 -0700 Subject: [PATCH 283/453] Change compilation targets. * Remove net451 as a compilation target * Upgrade to netcoreapp2.0 --- .gitignore | 1 + build/dependencies.props | 1 + samples/EchoApp/EchoApp.csproj | 2 +- .../Internal/fx/CompatHelpers.cs | 14 -------------- .../Microsoft.AspNetCore.WebSockets.csproj | 2 +- test/AutobahnTestApp/AutobahnTestApp.csproj | 2 +- .../Autobahn/AutobahnTester.cs | 7 +------ ...ft.AspNetCore.WebSockets.ConformanceTest.csproj | 2 +- .../Microsoft.AspNetCore.WebSockets.Test.csproj | 11 ++++------- 9 files changed, 11 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index b9545fe69a..0e10f4aa54 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ nuget.exe .build/ autobahnreports/ .vscode/ +global.json diff --git a/build/dependencies.props b/build/dependencies.props index ecbe769d13..59dbe299f5 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -5,6 +5,7 @@ 1.0.0-* 4.3.0 1.6.1 + 2.0.0-* 15.0.0 2.2.0 diff --git a/samples/EchoApp/EchoApp.csproj b/samples/EchoApp/EchoApp.csproj index 0424007902..0aac572423 100644 --- a/samples/EchoApp/EchoApp.csproj +++ b/samples/EchoApp/EchoApp.csproj @@ -3,7 +3,7 @@ - netcoreapp1.1 + netcoreapp2.0 diff --git a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/CompatHelpers.cs b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/CompatHelpers.cs index 53dc09608f..420f3e7503 100644 --- a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/CompatHelpers.cs +++ b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/CompatHelpers.cs @@ -16,31 +16,17 @@ namespace System.Net.WebSockets public static Task FromException(Exception ex) { -#if NET451 - return FromException(ex); -#else return Task.FromException(ex); -#endif } public static Task FromException(Exception ex) { -#if NET451 - var tcs = new TaskCompletionSource(); - tcs.SetException(ex); - return tcs.Task; -#else return Task.FromException(ex); -#endif } internal static T[] Empty() { -#if NET451 - return new T[0]; -#else return Array.Empty(); -#endif } } diff --git a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj index 953fb4d119..5a852d8c73 100644 --- a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj +++ b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj @@ -4,7 +4,7 @@ ASP.NET Core web socket middleware for use on top of opaque servers. - net451;netstandard1.3 + netstandard1.3 $(NoWarn);CS1591 true true diff --git a/test/AutobahnTestApp/AutobahnTestApp.csproj b/test/AutobahnTestApp/AutobahnTestApp.csproj index 56d7f09dcd..cec11d3850 100644 --- a/test/AutobahnTestApp/AutobahnTestApp.csproj +++ b/test/AutobahnTestApp/AutobahnTestApp.csproj @@ -3,7 +3,7 @@ - netcoreapp1.1 + netcoreapp2.0 diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index 66e1781241..52e53b11a1 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -100,7 +100,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { ApplicationBaseUriHint = baseUrl, ApplicationType = ApplicationType.Portable, - TargetFramework = "netcoreapp1.1", + TargetFramework = "netcoreapp2.0", EnvironmentName = environment, SiteName = "HttpTestSite", // This is configured in the Http.config ServerConfigTemplateContent = (server == ServerType.IISExpress) ? File.ReadAllText(configPath) : null, @@ -111,10 +111,6 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn _deployers.Add(deployer); cancellationToken.ThrowIfCancellationRequested(); -#if NET451 - System.Net.ServicePointManager.ServerCertificateValidationCallback = (_, __, ___, ____) => true; - var client = new HttpClient(); -#else var handler = new HttpClientHandler(); if (ssl) { @@ -124,7 +120,6 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn handler.ServerCertificateCustomValidationCallback = (_, __, ___, ____) => true; } var client = new HttpClient(handler); -#endif // Make sure the server works var resp = await RetryHelper.RetryRequest(() => diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj index 58708a55fa..e70d57c968 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj @@ -3,7 +3,7 @@ - netcoreapp1.1 + netcoreapp2.0 diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj index 72c7be4d12..670e5c1427 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj @@ -3,9 +3,9 @@ - net452;netcoreapp1.1 - netcoreapp1.1 - x64 + net46;netcoreapp2.0 + netcoreapp2.0 + x64 @@ -16,12 +16,9 @@ + - - - - From 214c41bf40403e29a4267cb38fe0066b0cb2e3bc Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Wed, 22 Mar 2017 10:47:41 -0700 Subject: [PATCH 284/453] remove reference to client components in README (#155) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index db96812f49..c7c69ee89b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ AppVeyor: [![AppVeyor](https://ci.appveyor.com/api/projects/status/lk5hyg6gki03h Travis: [![Travis](https://travis-ci.org/aspnet/WebSockets.svg?branch=dev)](https://travis-ci.org/aspnet/WebSockets) -Contains a managed implementation of the WebSocket protocol, along with client and server integration components. +Contains a managed implementation of the WebSocket protocol, along with server integration components. This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at the [Home](https://github.com/aspnet/home) repo. From eb0ab115d84704af6ce30a6932fa08d427ce0a1d Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Wed, 22 Mar 2017 15:24:36 -0700 Subject: [PATCH 285/453] capture wstest log output (#156) --- .../Autobahn/AutobahnTester.cs | 4 ++-- .../Autobahn/Executable.cs | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index 52e53b11a1..ccd9241104 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -43,7 +43,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn // Run the test (write something to the console so people know this will take a while...) _logger.LogInformation("Now launching Autobahn Test Suite. This will take a while."); - var exitCode = await Wstest.Default.ExecAsync("-m fuzzingclient -s " + specFile, cancellationToken); + var exitCode = await Wstest.Default.ExecAsync("-m fuzzingclient -s " + specFile, cancellationToken, _loggerFactory.CreateLogger("wstest")); if (exitCode != 0) { throw new Exception("wstest failed"); diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs index 41b798303e..e012a13dc2 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs @@ -4,6 +4,7 @@ using System.IO; using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; +using Microsoft.Extensions.Logging; namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { @@ -31,7 +32,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn return null; } - public async Task ExecAsync(string args, CancellationToken cancellationToken) + public async Task ExecAsync(string args, CancellationToken cancellationToken, ILogger logger) { var process = new Process() { @@ -40,6 +41,8 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn FileName = _path, Arguments = args, UseShellExecute = false, + RedirectStandardError = true, + RedirectStandardOutput = true }, EnableRaisingEvents = true }; @@ -48,13 +51,26 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn using (cancellationToken.Register(() => Cancel(process, tcs))) { process.Exited += (_, __) => tcs.TrySetResult(process.ExitCode); + process.OutputDataReceived += (_, a) => LogIfNotNull(logger.LogInformation, "stdout: {0}", a.Data); + process.ErrorDataReceived += (_, a) => LogIfNotNull(logger.LogError, "stderr: {0}", a.Data); process.Start(); + process.BeginErrorReadLine(); + process.BeginOutputReadLine(); + return await tcs.Task; } } + private void LogIfNotNull(Action logger, string message, string data) + { + if (!string.IsNullOrEmpty(data)) + { + logger(message, new[] { data }); + } + } + private static void Cancel(Process process, TaskCompletionSource tcs) { if (process != null && !process.HasExited) From 9254856007cbc5b55d7494cfd2f89323629c9836 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Mon, 27 Mar 2017 12:31:39 -0700 Subject: [PATCH 286/453] IIS tests are just too flaky, disable them (#158) --- .../AutobahnTests.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs index 760eb6ecca..c4a2b29601 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs @@ -53,22 +53,13 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest { await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token); - // Windows-only IIS tests, and Kestrel SSL tests (due to: https://github.com/aspnet/WebSockets/issues/102) + // Windows-only WebListener tests, and Kestrel SSL tests (due to: https://github.com/aspnet/WebSockets/issues/102) if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: true, environment: "ManagedSockets", cancellationToken: cts.Token); if (IsWindows8OrHigher()) { - if (IsIISExpress10Installed()) - { - // IIS Express tests are a bit flaky, some tests fail occasionally or get non-strict passes - // https://github.com/aspnet/WebSockets/issues/100 - await tester.DeployTestAndAddToSpec(ServerType.IISExpress, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token, expectationConfig: expect => expect - .OkOrFail("2.6", "6.22.22") // Getting some transient failures on the CI for these. See https://github.com/aspnet/WebSockets/issues/152 - .OkOrFail(Enumerable.Range(1, 20).Select(i => $"5.{i}").ToArray())); // 5.* occasionally fail on IIS express - } - // WebListener occasionally gives a non-strict response on 3.2. IIS Express seems to have the same behavior. Wonder if it's related to HttpSys? // For now, just allow the non-strict response, it's not a failure. await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token); From bfd1d48506d9a5b4ec296bd2e8e7009266e1d331 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 29 Mar 2017 11:30:37 -0700 Subject: [PATCH 287/453] Updating to 2.0.0 Internal.AspNetCore.Sdk --- build/common.props | 2 +- build/dependencies.props | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build/common.props b/build/common.props index 3afdffe756..39d70c0007 100644 --- a/build/common.props +++ b/build/common.props @@ -13,7 +13,7 @@ - + diff --git a/build/dependencies.props b/build/dependencies.props index 59dbe299f5..7c42cf44ca 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,9 +4,10 @@ 0.3.0-* 1.0.0-* 4.3.0 + 2.0.0-* 1.6.1 2.0.0-* 15.0.0 2.2.0 - + \ No newline at end of file From 9c2b7b78422c4a492e1a9145dbf1c5934888ddd0 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 3 Apr 2017 21:41:12 -0700 Subject: [PATCH 288/453] Updating versions to 2.0.0-preview1 --- build/dependencies.props | 2 +- version.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 7c42cf44ca..f702c7e7f3 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,6 @@ - 1.2.0-* + 2.0.0-* 0.3.0-* 1.0.0-* 4.3.0 diff --git a/version.props b/version.props index cd53f064e5..c7150e64f4 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ - 1.1.0 + 2.0.0 preview1 From e25a2eced8ff67eb175cdd0e074d48f230636711 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 13 Apr 2017 09:55:45 -0700 Subject: [PATCH 289/453] port dotnet/corefx#17444 to WebSockets (#162) --- .travis.yml | 1 + WebSockets.sln | 11 ++- appveyor.yml | 2 + build/dependencies.props | 4 +- .../System/Net/WebSockets/ManagedWebSocket.cs | 8 +- .../Autobahn/AutobahnTester.cs | 5 +- .../AutobahnTests.cs | 96 +++++++++---------- ...pNetCore.WebSockets.ConformanceTest.csproj | 2 +- 8 files changed, 72 insertions(+), 57 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1513d96c35..ad7de83e50 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ env: global: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_CLI_TELEMETRY_OPTOUT: 1 + - AUTOBAHN_SUITES_LOG: 1 mono: none python: - "2.7" diff --git a/WebSockets.sln b/WebSockets.sln index 30be8b4f80..512fa24505 100644 --- a/WebSockets.sln +++ b/WebSockets.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26228.4 +VisualStudioVersion = 15.0.26411.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2C7947A5-9FBD-4267-97C1-2D726D7B3BAF}" EndProject @@ -25,6 +25,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EchoApp", "samples\EchoApp\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutobahnTestApp", "test\AutobahnTestApp\AutobahnTestApp.csproj", "{150DF5A8-87C6-42F7-8886-CE07BFD02FD2}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{92CE12E6-E127-433B-96D3-164C0113EA17}" + ProjectSection(SolutionItems) = preProject + build\common.props = build\common.props + build\dependencies.props = build\dependencies.props + build\Key.snk = build\Key.snk + build\repo.props = build\repo.props + build\repo.targets = build\repo.targets + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/appveyor.yml b/appveyor.yml index 1041615c68..84253e7820 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,7 @@ init: - git config --global core.autocrlf true +environment: + AUTOBAHN_SUITES_LOG: 1 branches: only: - master diff --git a/build/dependencies.props b/build/dependencies.props index f702c7e7f3..fd031b40af 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,7 +1,7 @@ - + 2.0.0-* - 0.3.0-* + 0.4.0-* 1.0.0-* 4.3.0 2.0.0-* diff --git a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/ManagedWebSocket.cs b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/ManagedWebSocket.cs index 494b6a786d..ea8b828efe 100644 --- a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/ManagedWebSocket.cs +++ b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/ManagedWebSocket.cs @@ -732,9 +732,11 @@ namespace System.Net.WebSockets } catch (Exception exc) { - throw _state == WebSocketState.Aborted ? - new WebSocketException(WebSocketError.InvalidState, SR.Format(SR.net_WebSockets_InvalidState_ClosedOrAborted, "System.Net.WebSockets.InternalClientWebSocket", "Aborted"), exc) : - new WebSocketException(WebSocketError.ConnectionClosedPrematurely, exc); + if (_state == WebSocketState.Aborted) + { + throw new OperationCanceledException(nameof(WebSocketState.Aborted), exc); + } + throw new WebSocketException(WebSocketError.ConnectionClosedPrematurely, exc); } finally { diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index ccd9241104..5d2e6f44a1 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -7,6 +7,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Server.IntegrationTesting; +using Microsoft.AspNetCore.Server.IntegrationTesting.xunit; using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; using Xunit; @@ -106,8 +107,8 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn ServerConfigTemplateContent = (server == ServerType.IISExpress) ? File.ReadAllText(configPath) : null, }; - var deployer = ApplicationDeployerFactory.Create(parameters, logger); - var result = deployer.Deploy(); + var deployer = ApplicationDeployerFactory.Create(parameters, _loggerFactory); + var result = await deployer.DeployAsync(); _deployers.Add(deployer); cancellationToken.ThrowIfCancellationRequested(); diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs index c4a2b29601..e37e1b6d20 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs @@ -1,77 +1,77 @@ using System; using System.Diagnostics; using System.IO; -using System.Linq; using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Server.IntegrationTesting; +using Microsoft.AspNetCore.Server.IntegrationTesting.xunit; using Microsoft.AspNetCore.Testing.xunit; using Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn; -using Microsoft.Extensions.Logging; using Microsoft.Extensions.PlatformAbstractions; +using Xunit.Abstractions; namespace Microsoft.AspNetCore.WebSockets.ConformanceTest { - public class AutobahnTests + public class AutobahnTests : LoggedTest { + public AutobahnTests(ITestOutputHelper output) : base(output) + { + } + // Skip if wstest is not installed for now, see https://github.com/aspnet/WebSockets/issues/95 // We will enable Wstest on every build once we've gotten the necessary infrastructure sorted out :). [ConditionalFact] [SkipIfWsTestNotPresent] public async Task AutobahnTestSuite() { - var reportDir = Environment.GetEnvironmentVariable("AUTOBAHN_SUITES_REPORT_DIR"); - var outDir = !string.IsNullOrEmpty(reportDir) ? - reportDir : - Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "autobahnreports"); - - if (Directory.Exists(outDir)) + using (StartLog(out var loggerFactory)) { - Directory.Delete(outDir, recursive: true); - } + var reportDir = Environment.GetEnvironmentVariable("AUTOBAHN_SUITES_REPORT_DIR"); + var outDir = !string.IsNullOrEmpty(reportDir) ? + reportDir : + Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "autobahnreports"); - outDir = outDir.Replace("\\", "\\\\"); - - // 9.* is Limits/Performance which is VERY SLOW; 12.*/13.* are compression which we don't implement - var spec = new AutobahnSpec(outDir) - .IncludeCase("*") - .ExcludeCase("9.*", "12.*", "13.*"); - - var loggerFactory = new LoggerFactory(); // No logging by default! It's very loud... - - if (string.Equals(Environment.GetEnvironmentVariable("AUTOBAHN_SUITES_LOG"), "1", StringComparison.Ordinal)) - { - loggerFactory.AddConsole(); - } - - var cts = new CancellationTokenSource(); - cts.CancelAfter(TimeSpan.FromMinutes(5)); // These tests generally complete in just over 1 minute. - - AutobahnResult result; - using (var tester = new AutobahnTester(loggerFactory, spec)) - { - await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token); - - // Windows-only WebListener tests, and Kestrel SSL tests (due to: https://github.com/aspnet/WebSockets/issues/102) - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (Directory.Exists(outDir)) { - await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: true, environment: "ManagedSockets", cancellationToken: cts.Token); - - if (IsWindows8OrHigher()) - { - // WebListener occasionally gives a non-strict response on 3.2. IIS Express seems to have the same behavior. Wonder if it's related to HttpSys? - // For now, just allow the non-strict response, it's not a failure. - await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token); - } + Directory.Delete(outDir, recursive: true); } - result = await tester.Run(cts.Token); - tester.Verify(result); - } + outDir = outDir.Replace("\\", "\\\\"); - // If it hasn't been cancelled yet, cancel the token just to be sure - cts.Cancel(); + // 9.* is Limits/Performance which is VERY SLOW; 12.*/13.* are compression which we don't implement + var spec = new AutobahnSpec(outDir) + .IncludeCase("*") + .ExcludeCase("9.*", "12.*", "13.*"); + + var cts = new CancellationTokenSource(); + cts.CancelAfter(TimeSpan.FromMinutes(5)); // These tests generally complete in just over 1 minute. + + AutobahnResult result; + using (var tester = new AutobahnTester(loggerFactory, spec)) + { + await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token); + + // Windows-only WebListener tests, and Kestrel SSL tests (due to: https://github.com/aspnet/WebSockets/issues/102) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: true, environment: "ManagedSockets", cancellationToken: cts.Token); + + if (IsWindows8OrHigher()) + { + // WebListener occasionally gives a non-strict response on 3.2. IIS Express seems to have the same behavior. Wonder if it's related to HttpSys? + // For now, just allow the non-strict response, it's not a failure. + await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token); + } + } + + result = await tester.Run(cts.Token); + tester.Verify(result); + } + + // If it hasn't been cancelled yet, cancel the token just to be sure + cts.Cancel(); + } } private bool IsWindows8OrHigher() diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj index e70d57c968..18d5fc8df7 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj @@ -7,7 +7,7 @@ - + From bad5d7c8f7b50729fecbc419f3c977a44bcb4ed1 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 13 Apr 2017 14:25:23 -0700 Subject: [PATCH 290/453] fix build --- .../Microsoft.AspNetCore.WebSockets.Test.csproj | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj index 670e5c1427..60e7a8d6f3 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj @@ -6,6 +6,12 @@ net46;netcoreapp2.0 netcoreapp2.0 x64 + + + exe From a9a8f45158196b0e69d63cbf767a132ab72b4d2e Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Fri, 14 Apr 2017 10:48:44 -0700 Subject: [PATCH 291/453] change autobahn tests to use dynamic port (#167) --- test/AutobahnTestApp/Program.cs | 2 +- .../Autobahn/AutobahnTester.cs | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/test/AutobahnTestApp/Program.cs b/test/AutobahnTestApp/Program.cs index d056f14262..9349f21aab 100644 --- a/test/AutobahnTestApp/Program.cs +++ b/test/AutobahnTestApp/Program.cs @@ -27,7 +27,7 @@ namespace AutobahnTestApp else if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) { // ANCM is hosting the process. - // The port will not yet be configure at this point, but will also not require HTTPS. + // The port will not yet be configured at this point, but will also not require HTTPS. builder.UseKestrel(); } else diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index 5d2e6f44a1..50ac782996 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -16,7 +16,6 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { public class AutobahnTester : IDisposable { - private int _nextPort; private readonly List _deployers = new List(); private readonly List _expectations = new List(); private readonly ILoggerFactory _loggerFactory; @@ -24,11 +23,8 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn public AutobahnSpec Spec { get; } - public AutobahnTester(ILoggerFactory loggerFactory, AutobahnSpec baseSpec) : this(7000, loggerFactory, baseSpec) { } - - public AutobahnTester(int startPort, ILoggerFactory loggerFactory, AutobahnSpec baseSpec) + public AutobahnTester(ILoggerFactory loggerFactory, AutobahnSpec baseSpec) { - _nextPort = startPort; _loggerFactory = loggerFactory; _logger = _loggerFactory.CreateLogger("AutobahnTester"); @@ -89,8 +85,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn public async Task DeployTestAndAddToSpec(ServerType server, bool ssl, string environment, CancellationToken cancellationToken, Action expectationConfig = null) { - var port = Interlocked.Increment(ref _nextPort); - var baseUrl = ssl ? $"https://localhost:{port}" : $"http://localhost:{port}"; + var baseUrl = ssl ? "https://localhost:0" : "http://localhost:0"; var sslNamePart = ssl ? "SSL" : "NoSSL"; var name = $"{server}|{sslNamePart}|{environment}"; var logger = _loggerFactory.CreateLogger($"AutobahnTestApp:{server}:{sslNamePart}:{environment}"); From d8b172445482a22332cb5ac556d0edadd3324a9a Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Tue, 18 Apr 2017 11:53:45 -0700 Subject: [PATCH 292/453] improve logging of Autobahn tests (#166) --- test/AutobahnTestApp/Program.cs | 11 +++++++++++ test/AutobahnTestApp/Startup.cs | 3 ++- .../Autobahn/AutobahnTester.cs | 1 - 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/test/AutobahnTestApp/Program.cs b/test/AutobahnTestApp/Program.cs index 9349f21aab..89a4d9ec4a 100644 --- a/test/AutobahnTestApp/Program.cs +++ b/test/AutobahnTestApp/Program.cs @@ -3,6 +3,7 @@ using System.IO; using System.Net; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; namespace AutobahnTestApp { @@ -14,7 +15,12 @@ namespace AutobahnTestApp .AddCommandLine(args) .Build(); + var loggerFactory = new LoggerFactory() + .AddConsole(); + var logger = loggerFactory.CreateLogger(); + var builder = new WebHostBuilder() + .UseLoggerFactory(loggerFactory) .UseConfiguration(config) .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() @@ -22,12 +28,14 @@ namespace AutobahnTestApp if (string.Equals(builder.GetSetting("server"), "Microsoft.AspNetCore.Server.HttpSys", System.StringComparison.Ordinal)) { + logger.LogInformation("Using HttpSys server"); builder.UseHttpSys(); } else if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) { // ANCM is hosting the process. // The port will not yet be configured at this point, but will also not require HTTPS. + logger.LogInformation("Detected ANCM, using Kestrel"); builder.UseKestrel(); } else @@ -36,6 +44,8 @@ namespace AutobahnTestApp var urls = builder.GetSetting(WebHostDefaults.ServerUrlsKey) ?? builder.GetSetting("server.urls"); builder.UseSetting(WebHostDefaults.ServerUrlsKey, string.Empty); + logger.LogInformation("Using Kestrel, URL: {url}", urls); + if (urls.Contains(";")) { throw new NotSupportedException("This test app does not support multiple endpoints."); @@ -50,6 +60,7 @@ namespace AutobahnTestApp if (uri.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase)) { var certPath = Path.Combine(AppContext.BaseDirectory, "TestResources", "testCert.pfx"); + logger.LogInformation("Using SSL with certificate: {certPath}", certPath); listenOptions.UseHttps(certPath, "testPassword"); } }); diff --git a/test/AutobahnTestApp/Startup.cs b/test/AutobahnTestApp/Startup.cs index a7005b2247..671d503968 100644 --- a/test/AutobahnTestApp/Startup.cs +++ b/test/AutobahnTestApp/Startup.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Features; using Microsoft.Extensions.Logging; namespace AutobahnTestApp @@ -17,10 +16,12 @@ namespace AutobahnTestApp { app.UseWebSockets(); + var logger = loggerFactory.CreateLogger(); app.Use(async (context, next) => { if (context.WebSockets.IsWebSocketRequest) { + logger.LogInformation("Received WebSocket request"); var webSocket = await context.WebSockets.AcceptWebSocketAsync(); await Echo(webSocket); } diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index 50ac782996..52fdae6b7a 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -7,7 +7,6 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Server.IntegrationTesting; -using Microsoft.AspNetCore.Server.IntegrationTesting.xunit; using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; using Xunit; From 14b99f74fae9d301d5ceef7361c26a1fe1572b23 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 20 Apr 2017 09:31:10 -0700 Subject: [PATCH 293/453] react to removal of PlatformAbstractions (#168) --- .../AutobahnTests.cs | 3 +-- .../Microsoft.AspNetCore.WebSockets.ConformanceTest/Helpers.cs | 3 +-- .../Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs index e37e1b6d20..dcba43a738 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs @@ -8,7 +8,6 @@ using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.AspNetCore.Server.IntegrationTesting.xunit; using Microsoft.AspNetCore.Testing.xunit; using Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn; -using Microsoft.Extensions.PlatformAbstractions; using Xunit.Abstractions; namespace Microsoft.AspNetCore.WebSockets.ConformanceTest @@ -30,7 +29,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest var reportDir = Environment.GetEnvironmentVariable("AUTOBAHN_SUITES_REPORT_DIR"); var outDir = !string.IsNullOrEmpty(reportDir) ? reportDir : - Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "autobahnreports"); + Path.Combine(AppContext.BaseDirectory, "autobahnreports"); if (Directory.Exists(outDir)) { diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Helpers.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Helpers.cs index ad0f500837..37f65ca082 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Helpers.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Helpers.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using Microsoft.Extensions.PlatformAbstractions; namespace Microsoft.AspNetCore.WebSockets.ConformanceTest { @@ -8,7 +7,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest { public static string GetApplicationPath(string projectName) { - var applicationBasePath = PlatformServices.Default.Application.ApplicationBasePath; + var applicationBasePath = AppContext.BaseDirectory; var directoryInfo = new DirectoryInfo(applicationBasePath); do diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj index 18d5fc8df7..350e658791 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj @@ -11,7 +11,6 @@ - From 720cf1cf0efd6c9107c80ad85b0b8552f55c2e2f Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 25 Apr 2017 11:04:10 -0700 Subject: [PATCH 294/453] Use Bundled NETStandard.Library \ NETCoreApp versions instead of explicitly specifying one --- build/common.props | 2 +- build/dependencies.props | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/build/common.props b/build/common.props index 39d70c0007..c7f5bae299 100644 --- a/build/common.props +++ b/build/common.props @@ -17,7 +17,7 @@ - + diff --git a/build/dependencies.props b/build/dependencies.props index fd031b40af..9b2dce48bd 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,13 +1,11 @@ - + 2.0.0-* 0.4.0-* 1.0.0-* 4.3.0 2.0.0-* - 1.6.1 - 2.0.0-* 15.0.0 2.2.0 - \ No newline at end of file + From 5ed8116b0b99d1ce8b140c0cd1ea0576ac5f035c Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Tue, 25 Apr 2017 15:18:55 -0700 Subject: [PATCH 295/453] remove integration test logging (#172) now that logging.testing has it --- .../AutobahnTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs index dcba43a738..d24d36764d 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs @@ -5,9 +5,9 @@ using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Server.IntegrationTesting; -using Microsoft.AspNetCore.Server.IntegrationTesting.xunit; using Microsoft.AspNetCore.Testing.xunit; using Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn; +using Microsoft.Extensions.Logging.Testing; using Xunit.Abstractions; namespace Microsoft.AspNetCore.WebSockets.ConformanceTest From e882e3ac8e00cbb4c4a66ed6321d84067326fca1 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 25 Apr 2017 22:06:07 -0700 Subject: [PATCH 296/453] Branching for 2.0.0-preview1 --- NuGet.config | 2 +- build.ps1 | 2 +- build.sh | 2 +- build/dependencies.props | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/NuGet.config b/NuGet.config index 8e65695611..fa4304af9c 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + diff --git a/build.ps1 b/build.ps1 index 5bf0e2c113..225b1fe450 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0-preview1.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index b0bcadb579..702b25c636 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0-preview1.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi diff --git a/build/dependencies.props b/build/dependencies.props index 9b2dce48bd..e028502f9c 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,6 @@ - 2.0.0-* + 2.0.0-preview1-* 0.4.0-* 1.0.0-* 4.3.0 From 552ddd1011daa026126d63f4ce95d24aa1e34ba7 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 26 Apr 2017 07:13:45 -0700 Subject: [PATCH 297/453] Updating package version to preview2 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index c7150e64f4..6af4f81de2 100644 --- a/version.props +++ b/version.props @@ -2,6 +2,6 @@ 2.0.0 - preview1 + preview2 From 2f7fd9897e6c6f2e3eb7fc82f99c7d8a8a29e75f Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 1 May 2017 12:40:24 -0700 Subject: [PATCH 298/453] Use the bundled NETStandard.Library package in netstandard targeting libraries --- build/dependencies.props | 1 + 1 file changed, 1 insertion(+) diff --git a/build/dependencies.props b/build/dependencies.props index e028502f9c..4f7c9dd44f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -5,6 +5,7 @@ 1.0.0-* 4.3.0 2.0.0-* + $(BundledNETStandardPackageVersion) 15.0.0 2.2.0 From 319f95db5e3917375b6aa78de02c5bb3a5477792 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 4 May 2017 19:26:46 -0700 Subject: [PATCH 299/453] netcoreapp20 (#173) --- .../Microsoft.AspNetCore.WebSockets.csproj | 2 +- .../BufferStream.cs | 100 ------------------ .../DuplexStream.cs | 54 ---------- ...icrosoft.AspNetCore.WebSockets.Test.csproj | 3 +- 4 files changed, 2 insertions(+), 157 deletions(-) diff --git a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj index 5a852d8c73..eed3aa747b 100644 --- a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj +++ b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj @@ -4,7 +4,7 @@ ASP.NET Core web socket middleware for use on top of opaque servers. - netstandard1.3 + netcoreapp2.0 $(NoWarn);CS1591 true true diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs b/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs index 9b9a82f250..bba60a658b 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs @@ -152,73 +152,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } } -#if !NETCOREAPP1_1 - public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) - { - // TODO: This option doesn't preserve the state object. - // return ReadAsync(buffer, offset, count); - return base.BeginRead(buffer, offset, count, callback, state); - } - - public override int EndRead(IAsyncResult asyncResult) - { - // return ((Task)asyncResult).Result; - return base.EndRead(asyncResult); - } - - public async override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) - { - if(_terminated) - { - return 0; - } - - VerifyBuffer(buffer, offset, count, allowEmpty: false); - CancellationTokenRegistration registration = cancellationToken.Register(Abort); - await _readLock.WaitAsync(cancellationToken); - try - { - int totalRead = 0; - do - { - // Don't drained buffered data on abort. - CheckAborted(); - if (_topBuffer.Count <= 0) - { - byte[] topBuffer = null; - while (!_bufferedData.TryDequeue(out topBuffer)) - { - if (_disposed) - { - CheckAborted(); - // Graceful close - return totalRead; - } - await WaitForDataAsync(); - } - _topBuffer = new ArraySegment(topBuffer); - } - int actualCount = Math.Min(count, _topBuffer.Count); - Buffer.BlockCopy(_topBuffer.Array, _topBuffer.Offset, buffer, offset, actualCount); - _topBuffer = new ArraySegment(_topBuffer.Array, - _topBuffer.Offset + actualCount, - _topBuffer.Count - actualCount); - totalRead += actualCount; - offset += actualCount; - count -= actualCount; - } - while (count > 0 && (_topBuffer.Count > 0 || _bufferedData.Count > 0)); - // Keep reading while there is more data available and we have more space to put it in. - return totalRead; - } - finally - { - registration.Dispose(); - _readLock.Release(); - } - } -#endif - // Write with count 0 will still trigger OnFirstWrite public override void Write(byte[] buffer, int offset, int count) { @@ -245,39 +178,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } } -#if !NETCOREAPP1_1 - public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) - { - Write(buffer, offset, count); - TaskCompletionSource tcs = new TaskCompletionSource(state); - tcs.TrySetResult(null); - IAsyncResult result = tcs.Task; - if (callback != null) - { - callback(result); - } - return result; - } - - public override void EndWrite(IAsyncResult asyncResult) - { - } - - public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) - { - VerifyBuffer(buffer, offset, count, allowEmpty: true); - if (cancellationToken.IsCancellationRequested) - { - TaskCompletionSource tcs = new TaskCompletionSource(); - tcs.TrySetCanceled(); - return tcs.Task; - } - - Write(buffer, offset, count); - return Task.FromResult(null); - } -#endif - private static void VerifyBuffer(byte[] buffer, int offset, int count, bool allowEmpty) { if (offset < 0 || offset > buffer.Length) diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs b/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs index 11f65759cc..f2421bf4e6 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs @@ -94,33 +94,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test return ReadStream.Read(buffer, offset, count); } -#if !NETCOREAPP1_1 - public override int ReadByte() - { - return ReadStream.ReadByte(); - } - - public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) - { - return ReadStream.BeginRead(buffer, offset, count, callback, state); - } - - public override int EndRead(IAsyncResult asyncResult) - { - return ReadStream.EndRead(asyncResult); - } - - public override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) - { - return ReadStream.ReadAsync(buffer, offset, count, cancellationToken); - } - - public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken) - { - return ReadStream.CopyToAsync(destination, bufferSize, cancellationToken); - } -#endif - #endregion Read #region Write @@ -130,33 +103,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test WriteStream.Write(buffer, offset, count); } -#if !NETCOREAPP1_1 - public override void WriteByte(byte value) - { - WriteStream.WriteByte(value); - } - - public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) - { - return WriteStream.BeginWrite(buffer, offset, count, callback, state); - } - - public override void EndWrite(IAsyncResult asyncResult) - { - WriteStream.EndWrite(asyncResult); - } - - public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) - { - return WriteStream.WriteAsync(buffer, offset, count, cancellationToken); - } - - public override Task FlushAsync(CancellationToken cancellationToken) - { - return WriteStream.FlushAsync(cancellationToken); - } -#endif - public override void Flush() { WriteStream.Flush(); diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj index 60e7a8d6f3..56b131f821 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj @@ -3,8 +3,7 @@ - net46;netcoreapp2.0 - netcoreapp2.0 + netcoreapp2.0 x64 - exe + netcoreapp2.0;net461 + netcoreapp2.0 From 06028e81c77759357d8b16fa37795431feb1bb85 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Wed, 24 May 2017 18:20:46 -0700 Subject: [PATCH 305/453] fix build by adding OutputType exe to test project (#179) --- ...icrosoft.AspNetCore.WebSockets.Test.csproj | 6 ++++++ .../Program.cs | 20 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 test/Microsoft.AspNetCore.WebSockets.Test/Program.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj index b934260ee2..25e0f3a107 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj @@ -5,6 +5,12 @@ netcoreapp2.0;net461 netcoreapp2.0 + + + exe diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Program.cs b/test/Microsoft.AspNetCore.WebSockets.Test/Program.cs new file mode 100644 index 0000000000..5d248f9642 --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.Test/Program.cs @@ -0,0 +1,20 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +#if NET461 +using System; + +namespace Microsoft.AspNetCore.WebSockets.Test +{ + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine("This Program.Main is only here to work around https://github.com/dotnet/sdk/issues/909"); + } + } +} +#elif NETCOREAPP2_0 +#else +#error Target frameworks need to be updated +#endif From 461d8a77dbd139384b08ebc12e28ec96648b9870 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Fri, 26 May 2017 12:46:53 -0700 Subject: [PATCH 306/453] Updated to use the latest shared runtime --- build/dependencies.props | 1 + 1 file changed, 1 insertion(+) diff --git a/build/dependencies.props b/build/dependencies.props index 67ec9bf6fa..60534bf78f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -6,6 +6,7 @@ 4.4.0-* 2.1.0-* 2.0.0-* + 2.0.0-* 15.3.0-* 2.3.0-beta2-* From b1696835db05bd73b5064175eb154615da6fd0b0 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 31 May 2017 19:37:35 -0700 Subject: [PATCH 307/453] Branching for rel/2.0.0-preview2 --- NuGet.config | 7 ++++--- build/dependencies.props | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/NuGet.config b/NuGet.config index 8e65695611..c4bc056c4d 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,8 +1,9 @@ - + - + + - + \ No newline at end of file diff --git a/build/dependencies.props b/build/dependencies.props index 60534bf78f..0cdce27bfb 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,6 @@ - 2.0.0-* + 2.0.0-preview2-* 0.4.0-* 1.0.0-* 4.4.0-* From 5f23a96443354f61afc80f1049b69358bd273c2b Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 31 May 2017 19:53:37 -0700 Subject: [PATCH 308/453] Updating build scripts to point to 2.0.0-preview2 KoreBuild --- build.ps1 | 2 +- build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.ps1 b/build.ps1 index 5bf0e2c113..3a2476b2b4 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0-preview2.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index b0bcadb579..a40bdb87b1 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0-preview2.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From 24c6b73faf653a65c66cee3838a91da7565582ac Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 1 Jun 2017 10:47:58 -0700 Subject: [PATCH 309/453] Updating versions to preview3 --- NuGet.config | 3 ++- version.props | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/NuGet.config b/NuGet.config index 8e65695611..4e8a1f6de1 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,6 +1,7 @@ - + + diff --git a/version.props b/version.props index 6af4f81de2..193a5999d8 100644 --- a/version.props +++ b/version.props @@ -2,6 +2,6 @@ 2.0.0 - preview2 + preview3 From 79036ea166f4a1d1efa7ed7cf94fca8f017db4d5 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Fri, 2 Jun 2017 08:34:43 -0700 Subject: [PATCH 310/453] React to logging in DI (#180) --- test/AutobahnTestApp/Program.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/test/AutobahnTestApp/Program.cs b/test/AutobahnTestApp/Program.cs index 89a4d9ec4a..136a7c8639 100644 --- a/test/AutobahnTestApp/Program.cs +++ b/test/AutobahnTestApp/Program.cs @@ -15,12 +15,8 @@ namespace AutobahnTestApp .AddCommandLine(args) .Build(); - var loggerFactory = new LoggerFactory() - .AddConsole(); - var logger = loggerFactory.CreateLogger(); - var builder = new WebHostBuilder() - .UseLoggerFactory(loggerFactory) + .ConfigureLogging(loggingBuilder => loggingBuilder.AddConsole()) .UseConfiguration(config) .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() @@ -28,14 +24,14 @@ namespace AutobahnTestApp if (string.Equals(builder.GetSetting("server"), "Microsoft.AspNetCore.Server.HttpSys", System.StringComparison.Ordinal)) { - logger.LogInformation("Using HttpSys server"); + Console.WriteLine("Using HttpSys server"); builder.UseHttpSys(); } else if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) { // ANCM is hosting the process. // The port will not yet be configured at this point, but will also not require HTTPS. - logger.LogInformation("Detected ANCM, using Kestrel"); + Console.WriteLine("Detected ANCM, using Kestrel"); builder.UseKestrel(); } else @@ -44,7 +40,7 @@ namespace AutobahnTestApp var urls = builder.GetSetting(WebHostDefaults.ServerUrlsKey) ?? builder.GetSetting("server.urls"); builder.UseSetting(WebHostDefaults.ServerUrlsKey, string.Empty); - logger.LogInformation("Using Kestrel, URL: {url}", urls); + Console.WriteLine("Using Kestrel, URL: {url}", urls); if (urls.Contains(";")) { @@ -60,7 +56,7 @@ namespace AutobahnTestApp if (uri.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase)) { var certPath = Path.Combine(AppContext.BaseDirectory, "TestResources", "testCert.pfx"); - logger.LogInformation("Using SSL with certificate: {certPath}", certPath); + Console.WriteLine("Using SSL with certificate: {certPath}", certPath); listenOptions.UseHttps(certPath, "testPassword"); } }); From 43eb9574a15b58824ca8dd70b01c998a261ec7f4 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Sat, 3 Jun 2017 09:35:37 -0700 Subject: [PATCH 311/453] Fix invalid format string (#181) - Introduced in https://github.com/aspnet/WebSockets/commit/79036ea166f4a1d1efa7ed7cf94fca8f017db4d5 --- test/AutobahnTestApp/Program.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/AutobahnTestApp/Program.cs b/test/AutobahnTestApp/Program.cs index 136a7c8639..2ec9a97b96 100644 --- a/test/AutobahnTestApp/Program.cs +++ b/test/AutobahnTestApp/Program.cs @@ -40,7 +40,7 @@ namespace AutobahnTestApp var urls = builder.GetSetting(WebHostDefaults.ServerUrlsKey) ?? builder.GetSetting("server.urls"); builder.UseSetting(WebHostDefaults.ServerUrlsKey, string.Empty); - Console.WriteLine("Using Kestrel, URL: {url}", urls); + Console.WriteLine($"Using Kestrel, URL: {urls}"); if (urls.Contains(";")) { @@ -56,7 +56,7 @@ namespace AutobahnTestApp if (uri.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase)) { var certPath = Path.Combine(AppContext.BaseDirectory, "TestResources", "testCert.pfx"); - Console.WriteLine("Using SSL with certificate: {certPath}", certPath); + Console.WriteLine($"Using SSL with certificate: {certPath}"); listenOptions.UseHttps(certPath, "testPassword"); } }); From f34e87042c544b4c084466689d911079141433d9 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Fri, 9 Jun 2017 11:26:06 -0700 Subject: [PATCH 312/453] extend timeout and more logging (#183) --- test/AutobahnTestApp/Program.cs | 18 ++++++- test/AutobahnTestApp/Startup.cs | 18 +++---- .../Autobahn/AutobahnTester.cs | 48 ++++++++++++++++++- .../AutobahnTests.cs | 41 +++++++++------- 4 files changed, 97 insertions(+), 28 deletions(-) diff --git a/test/AutobahnTestApp/Program.cs b/test/AutobahnTestApp/Program.cs index 2ec9a97b96..ddd340a6e0 100644 --- a/test/AutobahnTestApp/Program.cs +++ b/test/AutobahnTestApp/Program.cs @@ -1,6 +1,7 @@ -using System; +using System; using System.IO; using System.Net; +using System.Runtime.Loader; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; @@ -11,6 +12,7 @@ namespace AutobahnTestApp { public static void Main(string[] args) { + var scenarioName = "Unknown"; var config = new ConfigurationBuilder() .AddCommandLine(args) .Build(); @@ -24,6 +26,7 @@ namespace AutobahnTestApp if (string.Equals(builder.GetSetting("server"), "Microsoft.AspNetCore.Server.HttpSys", System.StringComparison.Ordinal)) { + scenarioName = "HttpSysServer"; Console.WriteLine("Using HttpSys server"); builder.UseHttpSys(); } @@ -31,6 +34,7 @@ namespace AutobahnTestApp { // ANCM is hosting the process. // The port will not yet be configured at this point, but will also not require HTTPS. + scenarioName = "AspNetCoreModule"; Console.WriteLine("Detected ANCM, using Kestrel"); builder.UseKestrel(); } @@ -55,15 +59,27 @@ namespace AutobahnTestApp { if (uri.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase)) { + scenarioName = "Kestrel(SSL)"; var certPath = Path.Combine(AppContext.BaseDirectory, "TestResources", "testCert.pfx"); Console.WriteLine($"Using SSL with certificate: {certPath}"); listenOptions.UseHttps(certPath, "testPassword"); } + else + { + scenarioName = "Kestrel(NonSSL)"; + } }); }); } var host = builder.Build(); + + AppDomain.CurrentDomain.UnhandledException += (_, a) => + { + Console.WriteLine($"Unhandled exception (Scenario: {scenarioName}): {a.ExceptionObject.ToString()}"); + }; + + Console.WriteLine($"Starting Server for Scenario: {scenarioName}"); host.Run(); } } diff --git a/test/AutobahnTestApp/Startup.cs b/test/AutobahnTestApp/Startup.cs index 671d503968..f244e76358 100644 --- a/test/AutobahnTestApp/Startup.cs +++ b/test/AutobahnTestApp/Startup.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Net.WebSockets; using System.Threading; using System.Threading.Tasks; @@ -22,8 +22,10 @@ namespace AutobahnTestApp if (context.WebSockets.IsWebSocketRequest) { logger.LogInformation("Received WebSocket request"); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - await Echo(webSocket); + using (var webSocket = await context.WebSockets.AcceptWebSocketAsync()) + { + await Echo(webSocket, context.RequestAborted); + } } else { @@ -35,16 +37,16 @@ namespace AutobahnTestApp } - private async Task Echo(WebSocket webSocket) + private async Task Echo(WebSocket webSocket, CancellationToken cancellationToken) { var buffer = new byte[1024 * 4]; - var result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); + var result = await webSocket.ReceiveAsync(new ArraySegment(buffer), cancellationToken); while (!result.CloseStatus.HasValue) { - await webSocket.SendAsync(new ArraySegment(buffer, 0, result.Count), result.MessageType, result.EndOfMessage, CancellationToken.None); - result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); + await webSocket.SendAsync(new ArraySegment(buffer, 0, result.Count), result.MessageType, result.EndOfMessage, cancellationToken); + result = await webSocket.ReceiveAsync(new ArraySegment(buffer), cancellationToken); } - await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, cancellationToken); } } } diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index 52fdae6b7a..18b3dd49a5 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -16,6 +16,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn public class AutobahnTester : IDisposable { private readonly List _deployers = new List(); + private readonly List _deployments = new List(); private readonly List _expectations = new List(); private readonly ILoggerFactory _loggerFactory; private readonly ILogger _logger; @@ -35,6 +36,10 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn var specFile = Path.GetTempFileName(); try { + // Start pinging the servers to see that they're still running + var pingCts = new CancellationTokenSource(); + var pinger = new Timer(state => Pinger((CancellationToken)state), pingCts.Token, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10)); + Spec.WriteJson(specFile); // Run the test (write something to the console so people know this will take a while...) @@ -44,6 +49,8 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { throw new Exception("wstest failed"); } + + pingCts.Cancel(); } finally { @@ -63,6 +70,42 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn } } + // Async void! It's OK here because we are running in a timer. We're just using async void to chain continuations. + // There's nobody to await this, hence async void. + private async void Pinger(CancellationToken token) + { + try + { + while (!token.IsCancellationRequested) + { + try + { + foreach (var deployment in _deployments) + { + if (token.IsCancellationRequested) + { + return; + } + + var resp = await deployment.HttpClient.GetAsync("/ping", token); + if (!resp.IsSuccessStatusCode) + { + _logger.LogWarning("Non-successful response when pinging {url}: {statusCode} {reasonPhrase}", deployment.ApplicationBaseUri, resp.StatusCode, resp.ReasonPhrase); + } + } + } + catch (OperationCanceledException) + { + // We don't want to throw when the token fires, just stop. + } + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Error while pinging servers"); + } + } + public void Verify(AutobahnResult result) { var failures = new StringBuilder(); @@ -104,6 +147,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn var deployer = ApplicationDeployerFactory.Create(parameters, _loggerFactory); var result = await deployer.DeployAsync(); _deployers.Add(deployer); + _deployments.Add(result); cancellationToken.ThrowIfCancellationRequested(); var handler = new HttpClientHandler(); @@ -114,7 +158,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn // See https://github.com/dotnet/corefx/issues/9728 handler.ServerCertificateCustomValidationCallback = (_, __, ___, ____) => true; } - var client = new HttpClient(handler); + var client = result.CreateHttpClient(handler); // Make sure the server works var resp = await RetryHelper.RetryRequest(() => diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs index d24d36764d..6ef652be4f 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.AspNetCore.Testing.xunit; using Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn; +using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Testing; using Xunit.Abstractions; @@ -14,6 +15,8 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest { public class AutobahnTests : LoggedTest { + private static readonly TimeSpan TestTimeout = TimeSpan.FromMinutes(3); + public AutobahnTests(ITestOutputHelper output) : base(output) { } @@ -26,6 +29,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest { using (StartLog(out var loggerFactory)) { + var logger = loggerFactory.CreateLogger(); var reportDir = Environment.GetEnvironmentVariable("AUTOBAHN_SUITES_REPORT_DIR"); var outDir = !string.IsNullOrEmpty(reportDir) ? reportDir : @@ -44,28 +48,31 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest .ExcludeCase("9.*", "12.*", "13.*"); var cts = new CancellationTokenSource(); - cts.CancelAfter(TimeSpan.FromMinutes(5)); // These tests generally complete in just over 1 minute. + cts.CancelAfter(TestTimeout); // These tests generally complete in just over 1 minute. - AutobahnResult result; - using (var tester = new AutobahnTester(loggerFactory, spec)) + using (cts.Token.Register(() => logger.LogError("Test run is taking longer than maximum duration of {timeoutMinutes:0.00} minutes. Aborting...", TestTimeout.TotalMinutes))) { - await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token); - - // Windows-only WebListener tests, and Kestrel SSL tests (due to: https://github.com/aspnet/WebSockets/issues/102) - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + AutobahnResult result; + using (var tester = new AutobahnTester(loggerFactory, spec)) { - await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: true, environment: "ManagedSockets", cancellationToken: cts.Token); + await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token); - if (IsWindows8OrHigher()) + // Windows-only WebListener tests, and Kestrel SSL tests (due to: https://github.com/aspnet/WebSockets/issues/102) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - // WebListener occasionally gives a non-strict response on 3.2. IIS Express seems to have the same behavior. Wonder if it's related to HttpSys? - // For now, just allow the non-strict response, it's not a failure. - await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token); - } - } + await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: true, environment: "ManagedSockets", cancellationToken: cts.Token); - result = await tester.Run(cts.Token); - tester.Verify(result); + if (IsWindows8OrHigher()) + { + // WebListener occasionally gives a non-strict response on 3.2. IIS Express seems to have the same behavior. Wonder if it's related to HttpSys? + // For now, just allow the non-strict response, it's not a failure. + await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token); + } + } + + result = await tester.Run(cts.Token); + tester.Verify(result); + } } // If it hasn't been cancelled yet, cancel the token just to be sure From 98c8899155790911a7f2fff1e7891203fb96cf51 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Mon, 26 Jun 2017 09:43:03 -0700 Subject: [PATCH 313/453] Adding libunwind8 to .travis.yml [skip appveyor] --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index ad7de83e50..c553197516 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,10 @@ os: - linux - osx osx_image: xcode8.2 +addons: + apt: + packages: + - libunwind8 branches: only: - master From 42f43e6cdfe93f60b285c550a4cd5699e4671f74 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Tue, 27 Jun 2017 15:49:27 -0700 Subject: [PATCH 314/453] Upgrade TargetFramework in TestServer from 4.5 to 4.6.1 (#190) * Addresses https://github.com/aspnet/WebSockets/issues/185 --- samples/TestServer/App.config | 2 +- samples/TestServer/TestServer.csproj | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/TestServer/App.config b/samples/TestServer/App.config index 8e15646352..731f6de6c2 100644 --- a/samples/TestServer/App.config +++ b/samples/TestServer/App.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/samples/TestServer/TestServer.csproj b/samples/TestServer/TestServer.csproj index 24d42de384..b3e359eaef 100644 --- a/samples/TestServer/TestServer.csproj +++ b/samples/TestServer/TestServer.csproj @@ -9,7 +9,7 @@ Properties TestServer TestServer - v4.5 + v4.6.1 512 @@ -55,4 +55,4 @@ --> - \ No newline at end of file + From 172ab264f82bb1a6e1da48f1a5fe52c6bb29d6e7 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 29 Jun 2017 09:11:19 -0700 Subject: [PATCH 315/453] Add NETStandardImplicitPackageVersion --- build/dependencies.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 60534bf78f..7a7a8a29c6 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,10 +1,11 @@ - + 2.0.0-* 0.4.0-* 1.0.0-* 4.4.0-* 2.1.0-* + 2.0.0-* 2.0.0-* 2.0.0-* 15.3.0-* From 954e186261f6d4267274fd5b6460569006c404d9 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 3 Jul 2017 14:08:32 -0700 Subject: [PATCH 316/453] Update LICENSE.txt text --- LICENSE.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 0bdc1962b6..7b2956ecee 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,10 +1,12 @@ -Copyright (c) .NET Foundation. All rights reserved. +Copyright (c) .NET Foundation and Contributors + +All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use -these files except in compliance with the License. You may obtain a copy of the +this file except in compliance with the License. You may obtain a copy of the License at -http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR From 249722ca0db19d90215a3e4fb0cd3540cb23fd13 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 6 Jul 2017 10:39:47 -0700 Subject: [PATCH 317/453] React to aspnet/BuildTools#293 [ci skip] --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 7a7a8a29c6..eec35d5341 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,7 +4,7 @@ 0.4.0-* 1.0.0-* 4.4.0-* - 2.1.0-* + 2.0.1-* 2.0.0-* 2.0.0-* 2.0.0-* From 9130651a698acad16da8e9b95953c9caea9b6172 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Thu, 6 Jul 2017 12:30:49 -0700 Subject: [PATCH 318/453] Set "TreatWarningsAsErrors" before NuGet restore * Ensures our build stays clean of NuGet warnings --- build/common.props | 1 + 1 file changed, 1 insertion(+) diff --git a/build/common.props b/build/common.props index 4954e5032a..e86b531042 100644 --- a/build/common.props +++ b/build/common.props @@ -10,6 +10,7 @@ true true $(VersionSuffix)-$(BuildNumber) + true From 5205f6c0196f70dd991a6d6a40ad7315803315e1 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 6 Jul 2017 15:08:58 -0700 Subject: [PATCH 319/453] Update version suffix for 2.0.0 RTM release --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 193a5999d8..eba6b16756 100644 --- a/version.props +++ b/version.props @@ -2,6 +2,6 @@ 2.0.0 - preview3 + rtm From 69ef854add58d9f50031fdd7c092d02f587bf7df Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Thu, 6 Jul 2017 15:56:04 -0700 Subject: [PATCH 320/453] Remove NETStandard.Library.NETFramework --- build/common.props | 4 ---- samples/EchoApp/EchoApp.csproj | 4 ---- 2 files changed, 8 deletions(-) diff --git a/build/common.props b/build/common.props index e86b531042..30e0a1dcbf 100644 --- a/build/common.props +++ b/build/common.props @@ -17,8 +17,4 @@ - - - - diff --git a/samples/EchoApp/EchoApp.csproj b/samples/EchoApp/EchoApp.csproj index 6499a0a23f..a21a4036e8 100644 --- a/samples/EchoApp/EchoApp.csproj +++ b/samples/EchoApp/EchoApp.csproj @@ -18,8 +18,4 @@ - - - - From c7913f21c92b4f6d6c32b1b45c4061320179b9e6 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 10 Jul 2017 11:46:59 -0700 Subject: [PATCH 321/453] Branching for 2.0.0 rtm --- NuGet.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.config b/NuGet.config index 4e8a1f6de1..37f0d27ea0 100644 --- a/NuGet.config +++ b/NuGet.config @@ -2,7 +2,7 @@ - + From 78e303f23482a74f7f07fee8b7d095354b500e5f Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 10 Jul 2017 11:58:02 -0700 Subject: [PATCH 322/453] Updating KoreBuild branch --- build.ps1 | 2 +- build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.ps1 b/build.ps1 index 5bf0e2c113..1785334385 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index b0bcadb579..5e27ed8efb 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From ecd56f1074a186c083376ef8e3f4c7f883be06c5 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Fri, 7 Jul 2017 14:58:43 -0700 Subject: [PATCH 323/453] Skip first time experience on Appveyor --- appveyor.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 84253e7820..09082f7327 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -init: +init: - git config --global core.autocrlf true environment: AUTOBAHN_SUITES_LOG: 1 @@ -11,6 +11,10 @@ branches: build_script: - ps: .\build.ps1 clone_depth: 1 +environment: + global: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: 1 test: off deploy: off os: Visual Studio 2017 From 667c2c4acc305e127c6500019c473a4b7ee9656d Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Fri, 7 Jul 2017 15:12:21 -0700 Subject: [PATCH 324/453] Join environment vars --- appveyor.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 09082f7327..da3f6288e9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,6 +2,9 @@ - git config --global core.autocrlf true environment: AUTOBAHN_SUITES_LOG: 1 + global: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: 1 branches: only: - master @@ -11,10 +14,6 @@ branches: build_script: - ps: .\build.ps1 clone_depth: 1 -environment: - global: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_CLI_TELEMETRY_OPTOUT: 1 test: off deploy: off os: Visual Studio 2017 From 84e720180ee595978f0d3c9eb0c743963eaba341 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Fri, 21 Jul 2017 13:03:37 -0700 Subject: [PATCH 325/453] 2.0.0-rtm to 2.1.0-preview1 --- version.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.props b/version.props index eba6b16756..1ea46af42a 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ - 2.0.0 - rtm + 2.1.0 + preview1 From 47a58a305b597121c1342b0b3567c64cb7d86ae7 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 24 Jul 2017 17:59:32 -0700 Subject: [PATCH 326/453] Set AspNetCoreVersion --- build/dependencies.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index eec35d5341..d406d0b136 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,6 @@ - + - 2.0.0-* + 2.1.0-* 0.4.0-* 1.0.0-* 4.4.0-* From ab0bdefb8fda3d890850214d9e397218b64206bc Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 25 Jul 2017 15:15:20 -0700 Subject: [PATCH 327/453] Updating to InternalAspNetCoreSdkVersion 2.1.1-* --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index d406d0b136..b8ee5dd254 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,7 +4,7 @@ 0.4.0-* 1.0.0-* 4.4.0-* - 2.0.1-* + 2.1.1-* 2.0.0-* 2.0.0-* 2.0.0-* From 68c937359b190747703206d2836c00249eb38dcc Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 25 Jul 2017 16:35:25 -0700 Subject: [PATCH 328/453] Update bootstrappers to use the compiled version of KoreBuild [ci skip] --- .gitignore | 1 + build.cmd | 2 +- build.ps1 | 218 +++++++++++++++++++++++++--------- build.sh | 224 +++++++++++++++++++++++++++++------ build/common.props | 2 +- version.props => version.xml | 3 +- 6 files changed, 356 insertions(+), 94 deletions(-) rename version.props => version.xml (55%) diff --git a/.gitignore b/.gitignore index 0e10f4aa54..8ff010f6a0 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ nuget.exe autobahnreports/ .vscode/ global.json +korebuild-lock.txt diff --git a/build.cmd b/build.cmd index 7d4894cb4a..b6c8d24864 100644 --- a/build.cmd +++ b/build.cmd @@ -1,2 +1,2 @@ @ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" \ No newline at end of file +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" diff --git a/build.ps1 b/build.ps1 index 5bf0e2c113..d5eb4d5cf2 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,67 +1,177 @@ -$ErrorActionPreference = "Stop" +#!/usr/bin/env powershell +#requires -version 4 -function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries) -{ - while($true) - { - try - { - Invoke-WebRequest $url -OutFile $downloadLocation - break - } - catch - { - $exceptionMessage = $_.Exception.Message - Write-Host "Failed to download '$url': $exceptionMessage" - if ($retries -gt 0) { - $retries-- - Write-Host "Waiting 10 seconds before retrying. Retries left: $retries" - Start-Sleep -Seconds 10 +<# +.SYNOPSIS +Build this repository +.DESCRIPTION +Downloads korebuild if required. Then builds the repository. + +.PARAMETER Path +The folder to build. Defaults to the folder containing this script. + +.PARAMETER Channel +The channel of KoreBuild to download. Overrides the value from the config file. + +.PARAMETER DotNetHome +The directory where .NET Core tools will be stored. + +.PARAMETER ToolsSource +The base url where build tools can be downloaded. Overrides the value from the config file. + +.PARAMETER Update +Updates KoreBuild to the latest version even if a lock file is present. + +.PARAMETER ConfigFile +The path to the configuration file that stores values. Defaults to version.xml. + +.PARAMETER MSBuildArgs +Arguments to be passed to MSBuild + +.NOTES +This function will create a file $PSScriptRoot/korebuild-lock.txt. This lock file can be committed to source, but does not have to be. +When the lockfile is not present, KoreBuild will create one using latest available version from $Channel. + +The $ConfigFile is expected to be an XML file. It is optional, and the configuration values in it are optional as well. + +.EXAMPLE +Example config file: +```xml + + + + dev + https://aspnetcore.blob.core.windows.net/buildtools + + +``` +#> +[CmdletBinding(PositionalBinding = $false)] +param( + [string]$Path = $PSScriptRoot, + [Alias('c')] + [string]$Channel, + [Alias('d')] + [string]$DotNetHome, + [Alias('s')] + [string]$ToolsSource, + [Alias('u')] + [switch]$Update, + [string]$ConfigFile = (Join-Path $PSScriptRoot 'version.xml'), + [Parameter(ValueFromRemainingArguments = $true)] + [string[]]$MSBuildArgs +) + +Set-StrictMode -Version 2 +$ErrorActionPreference = 'Stop' + +# +# Functions +# + +function Get-KoreBuild { + + $lockFile = Join-Path $Path 'korebuild-lock.txt' + + if (!(Test-Path $lockFile) -or $Update) { + Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile + } + + $version = Get-Content $lockFile | Where-Object { $_ -like 'version:*' } | Select-Object -first 1 + if (!$version) { + Write-Error "Failed to parse version from $lockFile. Expected a line that begins with 'version:'" + } + $version = $version.TrimStart('version:').Trim() + $korebuildPath = Join-Paths $DotNetHome ('buildtools', 'korebuild', $version) + + if (!(Test-Path $korebuildPath)) { + Write-Host -ForegroundColor Magenta "Downloading KoreBuild $version" + New-Item -ItemType Directory -Path $korebuildPath | Out-Null + $remotePath = "$ToolsSource/korebuild/artifacts/$version/korebuild.$version.zip" + + try { + $tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip" + Get-RemoteFile $remotePath $tmpfile + if (Get-Command -Name 'Expand-Archive' -ErrorAction Ignore) { + # Use built-in commands where possible as they are cross-plat compatible + Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath } - else - { - $exception = $_.Exception - throw $exception + else { + # Fallback to old approach for old installations of PowerShell + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($tmpfile, $korebuildPath) } } + catch { + Remove-Item -Recurse -Force $korebuildPath -ErrorAction Ignore + throw + } + finally { + Remove-Item $tmpfile -ErrorAction Ignore + } } + + return $korebuildPath } -cd $PSScriptRoot - -$repoFolder = $PSScriptRoot -$env:REPO_FOLDER = $repoFolder - -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" -if ($env:KOREBUILD_ZIP) -{ - $koreBuildZip=$env:KOREBUILD_ZIP +function Join-Paths([string]$path, [string[]]$childPaths) { + $childPaths | ForEach-Object { $path = Join-Path $path $_ } + return $path } -$buildFolder = ".build" -$buildFile="$buildFolder\KoreBuild.ps1" - -if (!(Test-Path $buildFolder)) { - Write-Host "Downloading KoreBuild from $koreBuildZip" - - $tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid() - New-Item -Path "$tempFolder" -Type directory | Out-Null - - $localZipFile="$tempFolder\korebuild.zip" - - DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6 - - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder) - - New-Item -Path "$buildFolder" -Type directory | Out-Null - copy-item "$tempFolder\**\build\*" $buildFolder -Recurse - - # Cleanup - if (Test-Path $tempFolder) { - Remove-Item -Recurse -Force $tempFolder +function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) { + if ($RemotePath -notlike 'http*') { + Copy-Item $RemotePath $LocalPath + return } + + $retries = 10 + while ($retries -gt 0) { + $retries -= 1 + try { + Invoke-WebRequest -UseBasicParsing -Uri $RemotePath -OutFile $LocalPath + return + } + catch { + Write-Verbose "Request failed. $retries retries remaining" + } + } + + Write-Error "Download failed: '$RemotePath'." } -&"$buildFile" @args +# +# Main +# + +# Load configuration or set defaults + +if (Test-Path $ConfigFile) { + [xml] $config = Get-Content $ConfigFile + if (!($Channel)) { [string] $Channel = Select-Xml -Xml $config -XPath '/Project/PropertyGroup/KoreBuildChannel' } + if (!($ToolsSource)) { [string] $ToolsSource = Select-Xml -Xml $config -XPath '/Project/PropertyGroup/KoreBuildToolsSource' } +} + +if (!$DotNetHome) { + $DotNetHome = if ($env:DOTNET_HOME) { $env:DOTNET_HOME } ` + elseif ($env:USERPROFILE) { Join-Path $env:USERPROFILE '.dotnet'} ` + elseif ($env:HOME) {Join-Path $env:HOME '.dotnet'}` + else { Join-Path $PSScriptRoot '.dotnet'} +} + +if (!$Channel) { $Channel = 'dev' } +if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' } + +# Execute + +$korebuildPath = Get-KoreBuild +Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') + +try { + Install-Tools $ToolsSource $DotNetHome + Invoke-RepositoryBuild $Path @MSBuildArgs +} +finally { + Remove-Module 'KoreBuild' -ErrorAction Ignore +} diff --git a/build.sh b/build.sh index b0bcadb579..ab590e62f1 100755 --- a/build.sh +++ b/build.sh @@ -1,46 +1,196 @@ #!/usr/bin/env bash -repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" -if [ ! -z $KOREBUILD_ZIP ]; then - koreBuildZip=$KOREBUILD_ZIP -fi +set -euo pipefail -buildFolder=".build" -buildFile="$buildFolder/KoreBuild.sh" +# +# variables +# -if test ! -d $buildFolder; then - echo "Downloading KoreBuild from $koreBuildZip" +RESET="\033[0m" +RED="\033[0;31m" +MAGENTA="\033[0;95m" +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +[ -z "${DOTNET_HOME:-}"] && DOTNET_HOME="$HOME/.dotnet" +config_file="$DIR/version.xml" +verbose=false +update=false +repo_path="$DIR" +channel='' +tools_source='' - tempFolder="/tmp/KoreBuild-$(uuidgen)" - mkdir $tempFolder +# +# Functions +# +__usage() { + echo "Usage: $(basename ${BASH_SOURCE[0]}) [options] [[--] ...]" + echo "" + echo "Arguments:" + echo " ... Arguments passed to MSBuild. Variable number of arguments allowed." + echo "" + echo "Options:" + echo " --verbose Show verbose output." + echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." + echo " --config-file TThe path to the configuration file that stores values. Defaults to version.xml." + echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." + echo " --path The directory to build. Defaults to the directory containing the script." + echo " -s|--tools-source The base url where build tools can be downloaded. Overrides the value from the config file." + echo " -u|--update Update to the latest KoreBuild even if the lock file is present." + echo "" + echo "Description:" + echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." + echo " When the lockfile is not present, KoreBuild will create one using latest available version from \$channel." - localZipFile="$tempFolder/korebuild.zip" - - retries=6 - until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null) - do - echo "Failed to download '$koreBuildZip'" - if [ "$retries" -le 0 ]; then - exit 1 - fi - retries=$((retries - 1)) - echo "Waiting 10 seconds before retrying. Retries left: $retries" - sleep 10s - done - - unzip -q -d $tempFolder $localZipFile - - mkdir $buildFolder - cp -r $tempFolder/**/build/** $buildFolder - - chmod +x $buildFile - - # Cleanup - if test -d $tempFolder; then - rm -rf $tempFolder + if [[ "${1:-}" != '--no-exit' ]]; then + exit 2 fi +} + +get_korebuild() { + local lock_file="$repo_path/korebuild-lock.txt" + if [ ! -f $lock_file ] || [ "$update" = true ]; then + __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" $lock_file + fi + local version="$(grep 'version:*' -m 1 $lock_file)" + if [[ "$version" == '' ]]; then + __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" + return 1 + fi + version="$(echo ${version#version:} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" + + { + if [ ! -d "$korebuild_path" ]; then + mkdir -p "$korebuild_path" + local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" + tmpfile="$(mktemp)" + echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" + if __get_remote_file $remote_path $tmpfile; then + unzip -q -d "$korebuild_path" $tmpfile + fi + rm $tmpfile || true + fi + + source "$korebuild_path/KoreBuild.sh" + } || { + if [ -d "$korebuild_path" ]; then + echo "Cleaning up after failed installation" + rm -rf "$korebuild_path" || true + fi + return 1 + } +} + +__error() { + echo -e "${RED}$@${RESET}" 1>&2 +} + +__machine_has() { + hash "$1" > /dev/null 2>&1 + return $? +} + +__get_remote_file() { + local remote_path=$1 + local local_path=$2 + + if [[ "$remote_path" != 'http'* ]]; then + cp $remote_path $local_path + return 0 + fi + + failed=false + if __machine_has wget; then + wget --tries 10 --quiet -O $local_path $remote_path || failed=true + fi + + if [ "$failed" = true ] && __machine_has curl; then + failed=false + curl --retry 10 -sSL -f --create-dirs -o $local_path $remote_path || failed=true + fi + + if [ "$failed" = true ]; then + __error "Download failed: $remote_path" 1>&2 + return 1 + fi +} + +__read_dom () { local IFS=\> ; read -d \< ENTITY CONTENT ;} + +# +# main +# + +while [[ $# > 0 ]]; do + case $1 in + -\?|-h|--help) + __usage --no-exit + exit 0 + ;; + -c|--channel|-Channel) + shift + channel=${1:-} + [ -z "$channel" ] && __usage + ;; + --config-file|-ConfigFile) + shift + config_file="${1:-}" + [ -z "$config_file" ] && __usage + ;; + -d|--dotnet-home|-DotNetHome) + shift + DOTNET_HOME=${1:-} + [ -z "$DOTNET_HOME" ] && __usage + ;; + --path|-Path) + shift + repo_path="${1:-}" + [ -z "$repo_path" ] && __usage + ;; + -s|--tools-source|-ToolsSource) + shift + tools_source="${1:-}" + [ -z "$tools_source" ] && __usage + ;; + -u|--update|-Update) + update=true + ;; + --verbose|-Verbose) + verbose=true + ;; + --) + shift + break + ;; + *) + break + ;; + esac + shift +done + +if ! __machine_has unzip; then + __error 'Missing required command: unzip' + exit 1 fi -$buildFile -r $repoFolder "$@" +if ! __machine_has curl && ! __machine_has wget; then + __error 'Missing required command. Either wget or curl is required.' + exit 1 +fi + +if [ -f $config_file ]; then + comment=false + while __read_dom; do + if [ "$comment" = true ]; then [[ $CONTENT == *'-->'* ]] && comment=false ; continue; fi + if [[ $ENTITY == '!--'* ]]; then comment=true; continue; fi + if [ -z "$channel" ] && [[ $ENTITY == "KoreBuildChannel" ]]; then channel=$CONTENT; fi + if [ -z "$tools_source" ] && [[ $ENTITY == "KoreBuildToolsSource" ]]; then tools_source=$CONTENT; fi + done < $config_file +fi + +[ -z "$channel" ] && channel='dev' +[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' + +get_korebuild +install_tools "$tools_source" "$DOTNET_HOME" +invoke_repository_build "$repo_path" $@ diff --git a/build/common.props b/build/common.props index 30e0a1dcbf..21478e0cfd 100644 --- a/build/common.props +++ b/build/common.props @@ -1,6 +1,6 @@ - + Microsoft ASP.NET Core diff --git a/version.props b/version.xml similarity index 55% rename from version.props rename to version.xml index 1ea46af42a..3c05022b7d 100644 --- a/version.props +++ b/version.xml @@ -1,6 +1,7 @@ - + + dev 2.1.0 preview1 From 01c2b6334843bff19d91edef2ada809eab5fec69 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 26 Jul 2017 10:29:30 -0700 Subject: [PATCH 329/453] Fix syntax warning when running build.sh on older versions of bash [ci skip] --- build.sh | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/build.sh b/build.sh index ab590e62f1..5568c6182a 100755 --- a/build.sh +++ b/build.sh @@ -10,7 +10,7 @@ RESET="\033[0m" RED="\033[0;31m" MAGENTA="\033[0;95m" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -[ -z "${DOTNET_HOME:-}"] && DOTNET_HOME="$HOME/.dotnet" +[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" config_file="$DIR/version.xml" verbose=false update=false @@ -22,7 +22,7 @@ tools_source='' # Functions # __usage() { - echo "Usage: $(basename ${BASH_SOURCE[0]}) [options] [[--] ...]" + echo "Usage: $(basename "${BASH_SOURCE[0]}") [options] [[--] ...]" echo "" echo "Arguments:" echo " ... Arguments passed to MSBuild. Variable number of arguments allowed." @@ -46,16 +46,17 @@ __usage() { } get_korebuild() { + local version local lock_file="$repo_path/korebuild-lock.txt" - if [ ! -f $lock_file ] || [ "$update" = true ]; then - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" $lock_file + if [ ! -f "$lock_file" ] || [ "$update" = true ]; then + __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" fi - local version="$(grep 'version:*' -m 1 $lock_file)" + version="$(grep 'version:*' -m 1 "$lock_file")" if [[ "$version" == '' ]]; then __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" return 1 fi - version="$(echo ${version#version:} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" { @@ -64,10 +65,10 @@ get_korebuild() { local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" tmpfile="$(mktemp)" echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" - if __get_remote_file $remote_path $tmpfile; then - unzip -q -d "$korebuild_path" $tmpfile + if __get_remote_file "$remote_path" "$tmpfile"; then + unzip -q -d "$korebuild_path" "$tmpfile" fi - rm $tmpfile || true + rm "$tmpfile" || true fi source "$korebuild_path/KoreBuild.sh" @@ -81,7 +82,7 @@ get_korebuild() { } __error() { - echo -e "${RED}$@${RESET}" 1>&2 + echo -e "${RED}$*${RESET}" 1>&2 } __machine_has() { @@ -94,18 +95,18 @@ __get_remote_file() { local local_path=$2 if [[ "$remote_path" != 'http'* ]]; then - cp $remote_path $local_path + cp "$remote_path" "$local_path" return 0 fi failed=false if __machine_has wget; then - wget --tries 10 --quiet -O $local_path $remote_path || failed=true + wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true fi if [ "$failed" = true ] && __machine_has curl; then failed=false - curl --retry 10 -sSL -f --create-dirs -o $local_path $remote_path || failed=true + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true fi if [ "$failed" = true ]; then @@ -114,13 +115,13 @@ __get_remote_file() { fi } -__read_dom () { local IFS=\> ; read -d \< ENTITY CONTENT ;} +__read_dom () { local IFS=\> ; read -r -d \< ENTITY CONTENT ;} # # main # -while [[ $# > 0 ]]; do +while [[ $# -gt 0 ]]; do case $1 in -\?|-h|--help) __usage --no-exit @@ -128,7 +129,7 @@ while [[ $# > 0 ]]; do ;; -c|--channel|-Channel) shift - channel=${1:-} + channel="${1:-}" [ -z "$channel" ] && __usage ;; --config-file|-ConfigFile) @@ -138,7 +139,7 @@ while [[ $# > 0 ]]; do ;; -d|--dotnet-home|-DotNetHome) shift - DOTNET_HOME=${1:-} + DOTNET_HOME="${1:-}" [ -z "$DOTNET_HOME" ] && __usage ;; --path|-Path) @@ -178,14 +179,14 @@ if ! __machine_has curl && ! __machine_has wget; then exit 1 fi -if [ -f $config_file ]; then +if [ -f "$config_file" ]; then comment=false while __read_dom; do if [ "$comment" = true ]; then [[ $CONTENT == *'-->'* ]] && comment=false ; continue; fi if [[ $ENTITY == '!--'* ]]; then comment=true; continue; fi if [ -z "$channel" ] && [[ $ENTITY == "KoreBuildChannel" ]]; then channel=$CONTENT; fi if [ -z "$tools_source" ] && [[ $ENTITY == "KoreBuildToolsSource" ]]; then tools_source=$CONTENT; fi - done < $config_file + done < "$config_file" fi [ -z "$channel" ] && channel='dev' @@ -193,4 +194,4 @@ fi get_korebuild install_tools "$tools_source" "$DOTNET_HOME" -invoke_repository_build "$repo_path" $@ +invoke_repository_build "$repo_path" "$@" From ccb9bf93e4116934d1872cf74cb00d0a9ca5a53d Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 2 Aug 2017 12:44:49 -0700 Subject: [PATCH 330/453] Update __get_remote_file logic --- build.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/build.sh b/build.sh index 5568c6182a..8eace4c20d 100755 --- a/build.sh +++ b/build.sh @@ -99,17 +99,16 @@ __get_remote_file() { return 0 fi - failed=false + local succeeded=false if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true + wget --tries 10 --quiet -O "$local_path" "$remote_path" && succeeded=true fi - if [ "$failed" = true ] && __machine_has curl; then - failed=false - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true + if [ "$succeeded" = false ] && __machine_has curl; then + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" && succeeded=true fi - if [ "$failed" = true ]; then + if [ "$succeeded" = false ]; then __error "Download failed: $remote_path" 1>&2 return 1 fi From 3f0b4a09e259017c7d18ce3c6a60f1f80a7bd9d5 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 2 Aug 2017 14:34:25 -0700 Subject: [PATCH 331/453] Ensure fallback to curl after failed wget --- build.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index 8eace4c20d..11cdbe5504 100755 --- a/build.sh +++ b/build.sh @@ -99,16 +99,19 @@ __get_remote_file() { return 0 fi - local succeeded=false + local failed=false if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "$remote_path" && succeeded=true + wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true + else + failed=true fi - if [ "$succeeded" = false ] && __machine_has curl; then - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" && succeeded=true + if [ "$failed" = true ] && __machine_has curl; then + failed=false + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true fi - if [ "$succeeded" = false ]; then + if [ "$failed" = true ]; then __error "Download failed: $remote_path" 1>&2 return 1 fi From 2ab1c093012ed379e0205b91dfd4d1bfc4416dca Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 7 Aug 2017 16:59:37 -0700 Subject: [PATCH 332/453] Update Microsoft.AspNetCore.Server.IntegrationTesting package version --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index b8ee5dd254..87cc74fd02 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,7 +1,7 @@ 2.1.0-* - 0.4.0-* + 0.5.0-* 1.0.0-* 4.4.0-* 2.1.1-* From 413c161345239999fa303b33a1d803b871c88b29 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 22 Aug 2017 18:18:47 -0700 Subject: [PATCH 333/453] Upgrade to xunit 2.3.0-beta4 --- build/dependencies.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 87cc74fd02..51e3766fe1 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -8,7 +8,7 @@ 2.0.0-* 2.0.0-* 2.0.0-* - 15.3.0-* - 2.3.0-beta2-* + 15.3.0 + 2.3.0-beta4-build3742 From 59290efa6a780a0e4e79bb4e8246c2faff1467a1 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 29 Aug 2017 12:06:04 -0700 Subject: [PATCH 334/453] Use Directory.Build.props/targets --- appveyor.yml => .appveyor.yml | 0 build/common.props => Directory.Build.props | 13 ++++--------- Directory.Build.targets | 2 ++ WebSockets.sln | 18 ++++++++++++++++-- samples/EchoApp/EchoApp.csproj | 4 +--- src/Directory.Build.props | 7 +++++++ .../Microsoft.AspNetCore.WebSockets.csproj | 4 +--- test/AutobahnTestApp/AutobahnTestApp.csproj | 2 -- test/Directory.Build.props | 7 +++++++ ...spNetCore.WebSockets.ConformanceTest.csproj | 4 +--- ...Microsoft.AspNetCore.WebSockets.Test.csproj | 4 +--- 11 files changed, 40 insertions(+), 25 deletions(-) rename appveyor.yml => .appveyor.yml (100%) rename build/common.props => Directory.Build.props (59%) create mode 100644 Directory.Build.targets create mode 100644 src/Directory.Build.props create mode 100644 test/Directory.Build.props diff --git a/appveyor.yml b/.appveyor.yml similarity index 100% rename from appveyor.yml rename to .appveyor.yml diff --git a/build/common.props b/Directory.Build.props similarity index 59% rename from build/common.props rename to Directory.Build.props index 21478e0cfd..40022b1ea2 100644 --- a/build/common.props +++ b/Directory.Build.props @@ -1,20 +1,15 @@ - - - + + + Microsoft ASP.NET Core https://github.com/aspnet/WebSockets git - $(MSBuildThisFileDirectory)Key.snk + $(MSBuildThisFileDirectory)build\Key.snk true true $(VersionSuffix)-$(BuildNumber) true - - - - - diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 0000000000..f75adf7e4d --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,2 @@ + + diff --git a/WebSockets.sln b/WebSockets.sln index 512fa24505..4ed91db448 100644 --- a/WebSockets.sln +++ b/WebSockets.sln @@ -1,10 +1,16 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26411.1 +VisualStudioVersion = 15.0.26730.10 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2C7947A5-9FBD-4267-97C1-2D726D7B3BAF}" + ProjectSection(SolutionItems) = preProject + src\Directory.Build.props = src\Directory.Build.props + EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{C45106D0-76C8-4776-A140-F7DD83CA2958}" + ProjectSection(SolutionItems) = preProject + test\Directory.Build.props = test\Directory.Build.props + EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B}" EndProject @@ -27,13 +33,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutobahnTestApp", "test\Aut EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{92CE12E6-E127-433B-96D3-164C0113EA17}" ProjectSection(SolutionItems) = preProject - build\common.props = build\common.props build\dependencies.props = build\dependencies.props build\Key.snk = build\Key.snk build\repo.props = build\repo.props build\repo.targets = build\repo.targets EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7A963B09-471B-4D67-B5C0-6039AF0C39EE}" + ProjectSection(SolutionItems) = preProject + Directory.Build.props = Directory.Build.props + Directory.Build.targets = Directory.Build.targets + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -128,4 +139,7 @@ Global {421954B0-5C6B-4092-8D4D-EACA4CE60AFB} = {9E55FC5B-FD9C-4266-AB24-F3AA649D7C8B} {150DF5A8-87C6-42F7-8886-CE07BFD02FD2} = {C45106D0-76C8-4776-A140-F7DD83CA2958} EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D3542868-F8C6-401B-8071-37FE3C981604} + EndGlobalSection EndGlobal diff --git a/samples/EchoApp/EchoApp.csproj b/samples/EchoApp/EchoApp.csproj index a21a4036e8..fc2393b23a 100644 --- a/samples/EchoApp/EchoApp.csproj +++ b/samples/EchoApp/EchoApp.csproj @@ -1,6 +1,4 @@ - - - + netcoreapp2.0;net461 diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 0000000000..d704a37df9 --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj index 2f2730ab86..f54048369c 100644 --- a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj +++ b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj @@ -1,6 +1,4 @@ - - - + ASP.NET Core web socket middleware for use on top of opaque servers. diff --git a/test/AutobahnTestApp/AutobahnTestApp.csproj b/test/AutobahnTestApp/AutobahnTestApp.csproj index cec11d3850..10f2c8e9fc 100644 --- a/test/AutobahnTestApp/AutobahnTestApp.csproj +++ b/test/AutobahnTestApp/AutobahnTestApp.csproj @@ -1,7 +1,5 @@  - - netcoreapp2.0 diff --git a/test/Directory.Build.props b/test/Directory.Build.props new file mode 100644 index 0000000000..d704a37df9 --- /dev/null +++ b/test/Directory.Build.props @@ -0,0 +1,7 @@ + + + + + + + diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj index cb193dbb01..aad1afd766 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj @@ -1,6 +1,4 @@ - - - + netcoreapp2.0 diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj index 25e0f3a107..c3d2ac6eed 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj @@ -1,6 +1,4 @@ - - - + netcoreapp2.0;net461 From 82ba6b51ef4a31d524a50faca0e0724e3f9d7f30 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 29 Aug 2017 12:08:10 -0700 Subject: [PATCH 335/453] Use PackageLineup to manage PackageReference versions --- Directory.Build.props | 1 - Directory.Build.targets | 14 +++++++++++++- NuGet.config | 1 - build/dependencies.props | 14 -------------- build/repo.props | 4 +++- samples/EchoApp/EchoApp.csproj | 10 +++++----- src/Directory.Build.props | 2 +- .../Microsoft.AspNetCore.WebSockets.csproj | 6 +++--- test/AutobahnTestApp/AutobahnTestApp.csproj | 16 ++++++++-------- test/Directory.Build.props | 2 +- ....AspNetCore.WebSockets.ConformanceTest.csproj | 14 +++++++------- .../Microsoft.AspNetCore.WebSockets.Test.csproj | 10 +++++----- 12 files changed, 46 insertions(+), 48 deletions(-) delete mode 100644 build/dependencies.props diff --git a/Directory.Build.props b/Directory.Build.props index 40022b1ea2..8a760f7371 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,4 @@  - diff --git a/Directory.Build.targets b/Directory.Build.targets index f75adf7e4d..bc118fd907 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,2 +1,14 @@ - + + + + <_BootstrapperFile Condition=" $([MSBuild]::IsOSUnixLike()) ">build.sh + <_BootstrapperFile Condition="! $([MSBuild]::IsOSUnixLike()) ">build.cmd + <_BootstrapperError> + Package references have not been pinned. Run './$(_BootstrapperFile) /t:Pin'. + Also, you can run './$(_BootstrapperFile) /t:Restore' which will pin *and* restore packages. '$(_BootstrapperFile)' can be found in '$(MSBuildThisFileDirectory)'. + + + + + diff --git a/NuGet.config b/NuGet.config index 4e8a1f6de1..20060c934e 100644 --- a/NuGet.config +++ b/NuGet.config @@ -3,7 +3,6 @@ - diff --git a/build/dependencies.props b/build/dependencies.props deleted file mode 100644 index 51e3766fe1..0000000000 --- a/build/dependencies.props +++ /dev/null @@ -1,14 +0,0 @@ - - - 2.1.0-* - 0.5.0-* - 1.0.0-* - 4.4.0-* - 2.1.1-* - 2.0.0-* - 2.0.0-* - 2.0.0-* - 15.3.0 - 2.3.0-beta4-build3742 - - diff --git a/build/repo.props b/build/repo.props index 3aad2de9e6..d5675010ee 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,5 +1,7 @@ - + + + diff --git a/samples/EchoApp/EchoApp.csproj b/samples/EchoApp/EchoApp.csproj index fc2393b23a..1035e5f69c 100644 --- a/samples/EchoApp/EchoApp.csproj +++ b/samples/EchoApp/EchoApp.csproj @@ -9,11 +9,11 @@ - - - - - + + + + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index d704a37df9..9d9a3de33a 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -2,6 +2,6 @@ - + diff --git a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj index f54048369c..1613ddde8f 100644 --- a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj +++ b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj @@ -10,9 +10,9 @@ - - - + + + diff --git a/test/AutobahnTestApp/AutobahnTestApp.csproj b/test/AutobahnTestApp/AutobahnTestApp.csproj index 10f2c8e9fc..506917e973 100644 --- a/test/AutobahnTestApp/AutobahnTestApp.csproj +++ b/test/AutobahnTestApp/AutobahnTestApp.csproj @@ -13,14 +13,14 @@ - - - - - - - - + + + + + + + + diff --git a/test/Directory.Build.props b/test/Directory.Build.props index d704a37df9..9d9a3de33a 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -2,6 +2,6 @@ - + diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj index aad1afd766..0667bd4045 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj @@ -5,13 +5,13 @@ - - - - - - - + + + + + + + diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj index c3d2ac6eed..ea392809c4 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj @@ -16,11 +16,11 @@ - - - - - + + + + + From 31c1e9d7d727fda23ae657cb3598c7c3f3950d15 Mon Sep 17 00:00:00 2001 From: Justin Kotalik Date: Thu, 21 Sep 2017 18:01:55 -0700 Subject: [PATCH 336/453] Increase Minimum Version of Visual Studio to 15.3.0 --- WebSockets.sln | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebSockets.sln b/WebSockets.sln index 4ed91db448..6977d2812e 100644 --- a/WebSockets.sln +++ b/WebSockets.sln @@ -1,7 +1,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26730.10 -MinimumVisualStudioVersion = 10.0.40219.1 +MinimumVisualStudioVersion = 15.0.26730.03 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2C7947A5-9FBD-4267-97C1-2D726D7B3BAF}" ProjectSection(SolutionItems) = preProject src\Directory.Build.props = src\Directory.Build.props From 46fedaed6ca98129415186bc12abb83aa5fb47b0 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Wed, 20 Sep 2017 13:24:31 -0700 Subject: [PATCH 337/453] Update bootstrappers --- .appveyor.yml | 4 +- build.cmd | 2 +- build.sh | 197 +------------------------------------- run.cmd | 2 + build.ps1 => run.ps1 | 56 +++++++---- run.sh | 223 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 266 insertions(+), 218 deletions(-) create mode 100644 run.cmd rename build.ps1 => run.ps1 (73%) create mode 100755 run.sh diff --git a/.appveyor.yml b/.appveyor.yml index da3f6288e9..05a7c4ff85 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,4 +1,4 @@ -init: +init: - git config --global core.autocrlf true environment: AUTOBAHN_SUITES_LOG: 1 @@ -12,7 +12,7 @@ branches: - dev - /^(.*\/)?ci-.*$/ build_script: - - ps: .\build.ps1 + - ps: .\run.ps1 default-build clone_depth: 1 test: off deploy: off diff --git a/build.cmd b/build.cmd index b6c8d24864..c0050bda12 100644 --- a/build.cmd +++ b/build.cmd @@ -1,2 +1,2 @@ @ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' default-build %*; exit $LASTEXITCODE" diff --git a/build.sh b/build.sh index 11cdbe5504..98a4b22765 100755 --- a/build.sh +++ b/build.sh @@ -1,199 +1,8 @@ #!/usr/bin/env bash set -euo pipefail - -# -# variables -# - -RESET="\033[0m" -RED="\033[0;31m" -MAGENTA="\033[0;95m" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" -config_file="$DIR/version.xml" -verbose=false -update=false -repo_path="$DIR" -channel='' -tools_source='' -# -# Functions -# -__usage() { - echo "Usage: $(basename "${BASH_SOURCE[0]}") [options] [[--] ...]" - echo "" - echo "Arguments:" - echo " ... Arguments passed to MSBuild. Variable number of arguments allowed." - echo "" - echo "Options:" - echo " --verbose Show verbose output." - echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." - echo " --config-file TThe path to the configuration file that stores values. Defaults to version.xml." - echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." - echo " --path The directory to build. Defaults to the directory containing the script." - echo " -s|--tools-source The base url where build tools can be downloaded. Overrides the value from the config file." - echo " -u|--update Update to the latest KoreBuild even if the lock file is present." - echo "" - echo "Description:" - echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." - echo " When the lockfile is not present, KoreBuild will create one using latest available version from \$channel." - - if [[ "${1:-}" != '--no-exit' ]]; then - exit 2 - fi -} - -get_korebuild() { - local version - local lock_file="$repo_path/korebuild-lock.txt" - if [ ! -f "$lock_file" ] || [ "$update" = true ]; then - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" - fi - version="$(grep 'version:*' -m 1 "$lock_file")" - if [[ "$version" == '' ]]; then - __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" - return 1 - fi - version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" - local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" - - { - if [ ! -d "$korebuild_path" ]; then - mkdir -p "$korebuild_path" - local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" - tmpfile="$(mktemp)" - echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" - if __get_remote_file "$remote_path" "$tmpfile"; then - unzip -q -d "$korebuild_path" "$tmpfile" - fi - rm "$tmpfile" || true - fi - - source "$korebuild_path/KoreBuild.sh" - } || { - if [ -d "$korebuild_path" ]; then - echo "Cleaning up after failed installation" - rm -rf "$korebuild_path" || true - fi - return 1 - } -} - -__error() { - echo -e "${RED}$*${RESET}" 1>&2 -} - -__machine_has() { - hash "$1" > /dev/null 2>&1 - return $? -} - -__get_remote_file() { - local remote_path=$1 - local local_path=$2 - - if [[ "$remote_path" != 'http'* ]]; then - cp "$remote_path" "$local_path" - return 0 - fi - - local failed=false - if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true - else - failed=true - fi - - if [ "$failed" = true ] && __machine_has curl; then - failed=false - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true - fi - - if [ "$failed" = true ]; then - __error "Download failed: $remote_path" 1>&2 - return 1 - fi -} - -__read_dom () { local IFS=\> ; read -r -d \< ENTITY CONTENT ;} - -# -# main -# - -while [[ $# -gt 0 ]]; do - case $1 in - -\?|-h|--help) - __usage --no-exit - exit 0 - ;; - -c|--channel|-Channel) - shift - channel="${1:-}" - [ -z "$channel" ] && __usage - ;; - --config-file|-ConfigFile) - shift - config_file="${1:-}" - [ -z "$config_file" ] && __usage - ;; - -d|--dotnet-home|-DotNetHome) - shift - DOTNET_HOME="${1:-}" - [ -z "$DOTNET_HOME" ] && __usage - ;; - --path|-Path) - shift - repo_path="${1:-}" - [ -z "$repo_path" ] && __usage - ;; - -s|--tools-source|-ToolsSource) - shift - tools_source="${1:-}" - [ -z "$tools_source" ] && __usage - ;; - -u|--update|-Update) - update=true - ;; - --verbose|-Verbose) - verbose=true - ;; - --) - shift - break - ;; - *) - break - ;; - esac - shift -done - -if ! __machine_has unzip; then - __error 'Missing required command: unzip' - exit 1 -fi - -if ! __machine_has curl && ! __machine_has wget; then - __error 'Missing required command. Either wget or curl is required.' - exit 1 -fi - -if [ -f "$config_file" ]; then - comment=false - while __read_dom; do - if [ "$comment" = true ]; then [[ $CONTENT == *'-->'* ]] && comment=false ; continue; fi - if [[ $ENTITY == '!--'* ]]; then comment=true; continue; fi - if [ -z "$channel" ] && [[ $ENTITY == "KoreBuildChannel" ]]; then channel=$CONTENT; fi - if [ -z "$tools_source" ] && [[ $ENTITY == "KoreBuildToolsSource" ]]; then tools_source=$CONTENT; fi - done < "$config_file" -fi - -[ -z "$channel" ] && channel='dev' -[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' - -get_korebuild -install_tools "$tools_source" "$DOTNET_HOME" -invoke_repository_build "$repo_path" "$@" +# Call "sync" between "chmod" and execution to prevent "text file busy" error in Docker (aufs) +chmod +x "$DIR/run.sh"; sync +"$DIR/run.sh" default-build "$@" diff --git a/run.cmd b/run.cmd new file mode 100644 index 0000000000..d52d5c7e68 --- /dev/null +++ b/run.cmd @@ -0,0 +1,2 @@ +@ECHO OFF +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' %*; exit $LASTEXITCODE" diff --git a/build.ps1 b/run.ps1 similarity index 73% rename from build.ps1 rename to run.ps1 index d5eb4d5cf2..49c2899856 100644 --- a/build.ps1 +++ b/run.ps1 @@ -3,10 +3,13 @@ <# .SYNOPSIS -Build this repository +Executes KoreBuild commands. .DESCRIPTION -Downloads korebuild if required. Then builds the repository. +Downloads korebuild if required. Then executes the KoreBuild command. To see available commands, execute with `-Command help`. + +.PARAMETER Command +The KoreBuild command to run. .PARAMETER Path The folder to build. Defaults to the folder containing this script. @@ -24,31 +27,32 @@ The base url where build tools can be downloaded. Overrides the value from the c Updates KoreBuild to the latest version even if a lock file is present. .PARAMETER ConfigFile -The path to the configuration file that stores values. Defaults to version.xml. +The path to the configuration file that stores values. Defaults to korebuild.json. -.PARAMETER MSBuildArgs -Arguments to be passed to MSBuild +.PARAMETER Arguments +Arguments to be passed to the command .NOTES This function will create a file $PSScriptRoot/korebuild-lock.txt. This lock file can be committed to source, but does not have to be. When the lockfile is not present, KoreBuild will create one using latest available version from $Channel. -The $ConfigFile is expected to be an XML file. It is optional, and the configuration values in it are optional as well. +The $ConfigFile is expected to be an JSON file. It is optional, and the configuration values in it are optional as well. Any options set +in the file are overridden by command line parameters. .EXAMPLE Example config file: -```xml - - - - dev - https://aspnetcore.blob.core.windows.net/buildtools - - +```json +{ + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", + "channel": "dev", + "toolsSource": "https://aspnetcore.blob.core.windows.net/buildtools" +} ``` #> [CmdletBinding(PositionalBinding = $false)] param( + [Parameter(Mandatory=$true, Position = 0)] + [string]$Command, [string]$Path = $PSScriptRoot, [Alias('c')] [string]$Channel, @@ -58,9 +62,9 @@ param( [string]$ToolsSource, [Alias('u')] [switch]$Update, - [string]$ConfigFile = (Join-Path $PSScriptRoot 'version.xml'), + [string]$ConfigFile, [Parameter(ValueFromRemainingArguments = $true)] - [string[]]$MSBuildArgs + [string[]]$Arguments ) Set-StrictMode -Version 2 @@ -147,10 +151,20 @@ function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) { # Load configuration or set defaults +$Path = Resolve-Path $Path +if (!$ConfigFile) { $ConfigFile = Join-Path $Path 'korebuild.json' } + if (Test-Path $ConfigFile) { - [xml] $config = Get-Content $ConfigFile - if (!($Channel)) { [string] $Channel = Select-Xml -Xml $config -XPath '/Project/PropertyGroup/KoreBuildChannel' } - if (!($ToolsSource)) { [string] $ToolsSource = Select-Xml -Xml $config -XPath '/Project/PropertyGroup/KoreBuildToolsSource' } + try { + $config = Get-Content -Raw -Encoding UTF8 -Path $ConfigFile | ConvertFrom-Json + if ($config) { + if (!($Channel) -and (Get-Member -Name 'channel' -InputObject $config)) { [string] $Channel = $config.channel } + if (!($ToolsSource) -and (Get-Member -Name 'toolsSource' -InputObject $config)) { [string] $ToolsSource = $config.toolsSource} + } + } catch { + Write-Warning "$ConfigFile could not be read. Its settings will be ignored." + Write-Warning $Error[0] + } } if (!$DotNetHome) { @@ -169,8 +183,8 @@ $korebuildPath = Get-KoreBuild Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') try { - Install-Tools $ToolsSource $DotNetHome - Invoke-RepositoryBuild $Path @MSBuildArgs + Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile + Invoke-KoreBuildCommand $Command @Arguments } finally { Remove-Module 'KoreBuild' -ErrorAction Ignore diff --git a/run.sh b/run.sh new file mode 100755 index 0000000000..c278423acc --- /dev/null +++ b/run.sh @@ -0,0 +1,223 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# +# variables +# + +RESET="\033[0m" +RED="\033[0;31m" +YELLOW="\033[0;33m" +MAGENTA="\033[0;95m" +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" +verbose=false +update=false +repo_path="$DIR" +channel='' +tools_source='' + +# +# Functions +# +__usage() { + echo "Usage: $(basename "${BASH_SOURCE[0]}") command [options] [[--] ...]" + echo "" + echo "Arguments:" + echo " command The command to be run." + echo " ... Arguments passed to the command. Variable number of arguments allowed." + echo "" + echo "Options:" + echo " --verbose Show verbose output." + echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." + echo " --config-file The path to the configuration file that stores values. Defaults to korebuild.json." + echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." + echo " --path The directory to build. Defaults to the directory containing the script." + echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." + echo " -u|--update Update to the latest KoreBuild even if the lock file is present." + echo "" + echo "Description:" + echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." + echo " When the lockfile is not present, KoreBuild will create one using latest available version from \$channel." + + if [[ "${1:-}" != '--no-exit' ]]; then + exit 2 + fi +} + +get_korebuild() { + local version + local lock_file="$repo_path/korebuild-lock.txt" + if [ ! -f "$lock_file" ] || [ "$update" = true ]; then + __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" + fi + version="$(grep 'version:*' -m 1 "$lock_file")" + if [[ "$version" == '' ]]; then + __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" + return 1 + fi + version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" + + { + if [ ! -d "$korebuild_path" ]; then + mkdir -p "$korebuild_path" + local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" + tmpfile="$(mktemp)" + echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" + if __get_remote_file "$remote_path" "$tmpfile"; then + unzip -q -d "$korebuild_path" "$tmpfile" + fi + rm "$tmpfile" || true + fi + + source "$korebuild_path/KoreBuild.sh" + } || { + if [ -d "$korebuild_path" ]; then + echo "Cleaning up after failed installation" + rm -rf "$korebuild_path" || true + fi + return 1 + } +} + +__error() { + echo -e "${RED}error: $*${RESET}" 1>&2 +} + +__warn() { + echo -e "${YELLOW}warning: $*${RESET}" +} + +__machine_has() { + hash "$1" > /dev/null 2>&1 + return $? +} + +__get_remote_file() { + local remote_path=$1 + local local_path=$2 + + if [[ "$remote_path" != 'http'* ]]; then + cp "$remote_path" "$local_path" + return 0 + fi + + local failed=false + if __machine_has wget; then + wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true + else + failed=true + fi + + if [ "$failed" = true ] && __machine_has curl; then + failed=false + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true + fi + + if [ "$failed" = true ]; then + __error "Download failed: $remote_path" 1>&2 + return 1 + fi +} + +# +# main +# + +command="${1:-}" +shift + +while [[ $# -gt 0 ]]; do + case $1 in + -\?|-h|--help) + __usage --no-exit + exit 0 + ;; + -c|--channel|-Channel) + shift + channel="${1:-}" + [ -z "$channel" ] && __usage + ;; + --config-file|-ConfigFile) + shift + config_file="${1:-}" + [ -z "$config_file" ] && __usage + if [ ! -f "$config_file" ]; then + __error "Invalid value for --config-file. $config_file does not exist." + exit 1 + fi + ;; + -d|--dotnet-home|-DotNetHome) + shift + DOTNET_HOME="${1:-}" + [ -z "$DOTNET_HOME" ] && __usage + ;; + --path|-Path) + shift + repo_path="${1:-}" + [ -z "$repo_path" ] && __usage + ;; + -s|--tools-source|-ToolsSource) + shift + tools_source="${1:-}" + [ -z "$tools_source" ] && __usage + ;; + -u|--update|-Update) + update=true + ;; + --verbose|-Verbose) + verbose=true + ;; + --) + shift + break + ;; + *) + break + ;; + esac + shift +done + +if ! __machine_has unzip; then + __error 'Missing required command: unzip' + exit 1 +fi + +if ! __machine_has curl && ! __machine_has wget; then + __error 'Missing required command. Either wget or curl is required.' + exit 1 +fi + +[ -z "${config_file:-}" ] && config_file="$repo_path/korebuild.json" +if [ -f "$config_file" ]; then + if __machine_has jq ; then + if jq '.' "$config_file" >/dev/null ; then + config_channel="$(jq -r 'select(.channel!=null) | .channel' "$config_file")" + config_tools_source="$(jq -r 'select(.toolsSource!=null) | .toolsSource' "$config_file")" + else + __warn "$config_file is invalid JSON. Its settings will be ignored." + fi + elif __machine_has python ; then + if python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then + config_channel="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')")" + config_tools_source="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")" + else + __warn "$config_file is invalid JSON. Its settings will be ignored." + fi + else + __warn 'Missing required command: jq or pyton. Could not parse the JSON file. Its settings will be ignored.' + fi + + [ ! -z "${config_channel:-}" ] && channel="$config_channel" + [ ! -z "${config_tools_source:-}" ] && tools_source="$config_tools_source" +fi + +[ -z "$channel" ] && channel='dev' +[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' + +get_korebuild +set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" +invoke_korebuild_command "$command" "$@" From f17facd32960ff7e0a64eac863cf444b98ea16d9 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 16 Oct 2017 12:53:37 -0700 Subject: [PATCH 338/453] Add RepositoryRoot --- Directory.Build.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 8a760f7371..ddaeac6a43 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,10 +1,11 @@ - + Microsoft ASP.NET Core https://github.com/aspnet/WebSockets git + $(MSBuildThisFileDirectory) $(MSBuildThisFileDirectory)build\Key.snk true true From 5bbab01ba512ed3a990095a284ea103d0fe1c2fe Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 1 Nov 2017 16:52:00 -0700 Subject: [PATCH 339/453] Pin tool and package versions to make builds more repeatable Part of aspnet/Universe#575 --- .gitignore | 1 - Directory.Build.props | 6 ++-- Directory.Build.targets | 17 +++-------- NuGet.config | 1 + build/dependencies.props | 28 +++++++++++++++++++ build/repo.props | 8 ++++-- korebuild-lock.txt | 2 ++ korebuild.json | 4 +++ samples/EchoApp/EchoApp.csproj | 10 +++---- src/Directory.Build.props | 2 +- .../Microsoft.AspNetCore.WebSockets.csproj | 6 ++-- test/AutobahnTestApp/AutobahnTestApp.csproj | 16 +++++------ test/Directory.Build.props | 2 +- ...pNetCore.WebSockets.ConformanceTest.csproj | 14 +++++----- ...icrosoft.AspNetCore.WebSockets.Test.csproj | 10 +++---- version.props | 10 +++++++ version.xml | 8 ------ 17 files changed, 88 insertions(+), 57 deletions(-) create mode 100644 build/dependencies.props create mode 100644 korebuild-lock.txt create mode 100644 korebuild.json create mode 100644 version.props delete mode 100644 version.xml diff --git a/.gitignore b/.gitignore index 8ff010f6a0..0e10f4aa54 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,3 @@ nuget.exe autobahnreports/ .vscode/ global.json -korebuild-lock.txt diff --git a/Directory.Build.props b/Directory.Build.props index ddaeac6a43..2e796e23c4 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,6 @@ - - + + + Microsoft ASP.NET Core @@ -9,7 +10,6 @@ $(MSBuildThisFileDirectory)build\Key.snk true true - $(VersionSuffix)-$(BuildNumber) true diff --git a/Directory.Build.targets b/Directory.Build.targets index bc118fd907..e83ff95e39 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,14 +1,5 @@ - - - - <_BootstrapperFile Condition=" $([MSBuild]::IsOSUnixLike()) ">build.sh - <_BootstrapperFile Condition="! $([MSBuild]::IsOSUnixLike()) ">build.cmd - <_BootstrapperError> - Package references have not been pinned. Run './$(_BootstrapperFile) /t:Pin'. - Also, you can run './$(_BootstrapperFile) /t:Restore' which will pin *and* restore packages. '$(_BootstrapperFile)' can be found in '$(MSBuildThisFileDirectory)'. - - - - - + + + $(MicrosoftNETCoreApp20PackageVersion) + diff --git a/NuGet.config b/NuGet.config index 20060c934e..4e8a1f6de1 100644 --- a/NuGet.config +++ b/NuGet.config @@ -3,6 +3,7 @@ + diff --git a/build/dependencies.props b/build/dependencies.props new file mode 100644 index 0000000000..e6f1b1f429 --- /dev/null +++ b/build/dependencies.props @@ -0,0 +1,28 @@ + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + + + 2.1.0-preview1-15550 + 1.0.0-pre-10141 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 0.5.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.0.0 + 15.3.0 + 4.4.0 + 2.3.0 + 2.3.0 + + + diff --git a/build/repo.props b/build/repo.props index d5675010ee..e9647fd79d 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,7 +1,11 @@  - - + + + + Internal.AspNetCore.Universe.Lineup + https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json + diff --git a/korebuild-lock.txt b/korebuild-lock.txt new file mode 100644 index 0000000000..36d8056037 --- /dev/null +++ b/korebuild-lock.txt @@ -0,0 +1,2 @@ +version:2.1.0-preview1-15550 +commithash:0dd080d0d87b4d1966ec0af9961dc8bacc04f84f diff --git a/korebuild.json b/korebuild.json new file mode 100644 index 0000000000..bd5d51a51b --- /dev/null +++ b/korebuild.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", + "channel": "dev" +} diff --git a/samples/EchoApp/EchoApp.csproj b/samples/EchoApp/EchoApp.csproj index 1035e5f69c..628bac1d74 100644 --- a/samples/EchoApp/EchoApp.csproj +++ b/samples/EchoApp/EchoApp.csproj @@ -9,11 +9,11 @@ - - - - - + + + + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 9d9a3de33a..1e0980f663 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -2,6 +2,6 @@ - + diff --git a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj index 1613ddde8f..56d06497f5 100644 --- a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj +++ b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj @@ -10,9 +10,9 @@ - - - + + + diff --git a/test/AutobahnTestApp/AutobahnTestApp.csproj b/test/AutobahnTestApp/AutobahnTestApp.csproj index 506917e973..29bda6ab83 100644 --- a/test/AutobahnTestApp/AutobahnTestApp.csproj +++ b/test/AutobahnTestApp/AutobahnTestApp.csproj @@ -13,14 +13,14 @@ - - - - - - - - + + + + + + + + diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 9d9a3de33a..1e0980f663 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -2,6 +2,6 @@ - + diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj index 0667bd4045..f017f57f30 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj @@ -5,13 +5,13 @@ - - - - - - - + + + + + + + diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj index ea392809c4..0e83b6ad49 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj @@ -16,11 +16,11 @@ - - - - - + + + + + diff --git a/version.props b/version.props new file mode 100644 index 0000000000..5c4a7c32d1 --- /dev/null +++ b/version.props @@ -0,0 +1,10 @@ + + + 2.1.0 + preview1 + $(VersionPrefix) + $(VersionPrefix)-$(VersionSuffix)-final + t000 + $(VersionSuffix)-$(BuildNumber) + + diff --git a/version.xml b/version.xml deleted file mode 100644 index 3c05022b7d..0000000000 --- a/version.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - dev - 2.1.0 - preview1 - - From 80b794342d8f1ffbb0582bc8ae6dcc5e1bb96b7c Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 16 Nov 2017 13:31:33 -0800 Subject: [PATCH 340/453] Update samples and tests to target netcoreapp2.1 --- Directory.Build.props | 4 +++ build/dependencies.props | 26 +++++++++---------- korebuild-lock.txt | 4 +-- samples/EchoApp/EchoApp.csproj | 2 +- test/AutobahnTestApp/AutobahnTestApp.csproj | 3 ++- test/Directory.Build.props | 7 +++++ .../Autobahn/AutobahnTester.cs | 10 ++++++- ...pNetCore.WebSockets.ConformanceTest.csproj | 3 ++- ...icrosoft.AspNetCore.WebSockets.Test.csproj | 9 +------ .../Program.cs | 2 +- 10 files changed, 42 insertions(+), 28 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 2e796e23c4..b14d03cc84 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,4 +1,8 @@  + + diff --git a/build/dependencies.props b/build/dependencies.props index e6f1b1f429..f158eed45e 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -5,19 +5,19 @@ 2.1.0-preview1-15550 1.0.0-pre-10141 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 0.5.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 + 2.1.0-preview1-27602 + 2.1.0-preview1-27602 + 2.1.0-preview1-27602 + 2.1.0-preview1-27602 + 0.5.0-preview1-27602 + 2.1.0-preview1-27602 + 2.1.0-preview1-27602 + 2.1.0-preview1-27602 + 2.1.0-preview1-27602 + 2.1.0-preview1-27602 + 2.1.0-preview1-27602 + 2.1.0-preview1-27602 + 2.1.0-preview1-27602 2.0.0 15.3.0 4.4.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 36d8056037..b2036f3394 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15550 -commithash:0dd080d0d87b4d1966ec0af9961dc8bacc04f84f +version:2.1.0-preview1-15569 +commithash:47312a6364ad0ee6d7052eada54da940c9b17931 diff --git a/samples/EchoApp/EchoApp.csproj b/samples/EchoApp/EchoApp.csproj index 628bac1d74..f5696ccf03 100644 --- a/samples/EchoApp/EchoApp.csproj +++ b/samples/EchoApp/EchoApp.csproj @@ -1,7 +1,7 @@  - netcoreapp2.0;net461 + netcoreapp2.1;net461 diff --git a/test/AutobahnTestApp/AutobahnTestApp.csproj b/test/AutobahnTestApp/AutobahnTestApp.csproj index 29bda6ab83..cd973145bb 100644 --- a/test/AutobahnTestApp/AutobahnTestApp.csproj +++ b/test/AutobahnTestApp/AutobahnTestApp.csproj @@ -1,7 +1,8 @@  - netcoreapp2.0 + netcoreapp2.1 + $(TargetFrameworks);netcoreapp2.0 diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 1e0980f663..270e1fa209 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -1,6 +1,13 @@  + + netcoreapp2.1 + $(DeveloperBuildTestTfms) + netcoreapp2.1;netcoreapp2.0 + $(StandardTestTfms);net461 + + diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index 18b3dd49a5..c9e6007cb2 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -134,11 +134,19 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn var appPath = Helpers.GetApplicationPath("AutobahnTestApp"); var configPath = Path.Combine(Directory.GetCurrentDirectory(), "..", "..", "..", "Http.config"); + var targetFramework = +#if NETCOREAPP2_1 + "netcoreapp2.1"; +#elif NETCOREAPP2_0 + "netcoreapp2.0"; +#else +#error Target frameworks need to be updated +#endif var parameters = new DeploymentParameters(appPath, server, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64) { ApplicationBaseUriHint = baseUrl, ApplicationType = ApplicationType.Portable, - TargetFramework = "netcoreapp2.0", + TargetFramework = targetFramework, EnvironmentName = environment, SiteName = "HttpTestSite", // This is configured in the Http.config ServerConfigTemplateContent = (server == ServerType.IISExpress) ? File.ReadAllText(configPath) : null, diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj index f017f57f30..79e3839b12 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj @@ -1,7 +1,8 @@  - netcoreapp2.0 + netcoreapp2.1 + $(TargetFrameworks);netcoreapp2.0 diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj index 0e83b6ad49..c85c41eb0e 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj @@ -1,14 +1,7 @@  - netcoreapp2.0;net461 - netcoreapp2.0 - - - exe + $(StandardTestTfms) diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Program.cs b/test/Microsoft.AspNetCore.WebSockets.Test/Program.cs index 5d248f9642..7f9f5d0035 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/Program.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/Program.cs @@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test } } } -#elif NETCOREAPP2_0 +#elif NETCOREAPP2_0 || NETCOREAPP2_1 #else #error Target frameworks need to be updated #endif From 516975346a60c56c8b1ca438045d61e0bdc59b5f Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 17 Nov 2017 13:00:27 -0800 Subject: [PATCH 341/453] Use MicrosoftNETCoreApp21PackageVersion to determine the runtime framework in netcoreapp2.1 --- Directory.Build.targets | 1 + build/dependencies.props | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Directory.Build.targets b/Directory.Build.targets index e83ff95e39..894b1d0cf8 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,5 +1,6 @@  $(MicrosoftNETCoreApp20PackageVersion) + $(MicrosoftNETCoreApp21PackageVersion) diff --git a/build/dependencies.props b/build/dependencies.props index f158eed45e..d423a2bb35 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,4 +1,4 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) @@ -19,6 +19,7 @@ 2.1.0-preview1-27602 2.1.0-preview1-27602 2.0.0 + 2.1.0-preview1-25907-02 15.3.0 4.4.0 2.3.0 From e328a1a5272d4690593acb55073b9528f981c0a1 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Mon, 20 Nov 2017 12:18:43 -0800 Subject: [PATCH 342/453] Use MSBuild to set NuGet feeds instead of NuGet.config --- Directory.Build.props | 1 + NuGet.config | 4 +--- build/sources.props | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 build/sources.props diff --git a/Directory.Build.props b/Directory.Build.props index b14d03cc84..6c76a5608f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,6 +5,7 @@ + Microsoft ASP.NET Core diff --git a/NuGet.config b/NuGet.config index 4e8a1f6de1..e32bddfd51 100644 --- a/NuGet.config +++ b/NuGet.config @@ -2,8 +2,6 @@ - - - + diff --git a/build/sources.props b/build/sources.props new file mode 100644 index 0000000000..c03f3ddb60 --- /dev/null +++ b/build/sources.props @@ -0,0 +1,16 @@ + + + + + $(DotNetRestoreSources) + + $(RestoreSources); + https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json; + https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; + + + $(RestoreSources); + https://api.nuget.org/v3/index.json; + + + From 5fe9e22c90e0ab5939dc895527e8a9e346fe522e Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 21 Nov 2017 15:49:13 -0800 Subject: [PATCH 343/453] Replace aspnetcore-ci-dev feed with aspnetcore-dev --- build/dependencies.props | 34 +++++++++++++++++----------------- build/repo.props | 2 +- build/sources.props | 2 +- korebuild-lock.txt | 4 ++-- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index d423a2bb35..a59a4c203c 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,27 +1,27 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15550 - 1.0.0-pre-10141 - 2.1.0-preview1-27602 - 2.1.0-preview1-27602 - 2.1.0-preview1-27602 - 2.1.0-preview1-27602 - 0.5.0-preview1-27602 - 2.1.0-preview1-27602 - 2.1.0-preview1-27602 - 2.1.0-preview1-27602 - 2.1.0-preview1-27602 - 2.1.0-preview1-27602 - 2.1.0-preview1-27602 - 2.1.0-preview1-27602 - 2.1.0-preview1-27602 + 2.1.0-preview1-15576 + 1.0.0-pre-10202 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 0.5.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 2.0.0 2.1.0-preview1-25907-02 15.3.0 - 4.4.0 + 4.5.0-preview1-25902-08 2.3.0 2.3.0 diff --git a/build/repo.props b/build/repo.props index e9647fd79d..ed56a4c23b 100644 --- a/build/repo.props +++ b/build/repo.props @@ -6,6 +6,6 @@ Internal.AspNetCore.Universe.Lineup - https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json + https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json diff --git a/build/sources.props b/build/sources.props index c03f3ddb60..9feff29d09 100644 --- a/build/sources.props +++ b/build/sources.props @@ -5,7 +5,7 @@ $(DotNetRestoreSources) $(RestoreSources); - https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json; + https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; diff --git a/korebuild-lock.txt b/korebuild-lock.txt index b2036f3394..1a99066b7c 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15569 -commithash:47312a6364ad0ee6d7052eada54da940c9b17931 +version:2.1.0-preview1-15576 +commithash:2f3856d2ba4f659fcb9253215b83946a06794a27 From 11e0f8456edfb4bcc8dab696d82aea05d35b4649 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 29 Nov 2017 14:09:31 -0800 Subject: [PATCH 344/453] Specify runtime versions to install --- build/repo.props | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build/repo.props b/build/repo.props index ed56a4c23b..a7ce27ecb1 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,11 +1,17 @@  + + - Internal.AspNetCore.Universe.Lineup https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json + + + + + From e199bd15e22aad4a6e1bcc01f49dcb90f71100d3 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Fri, 1 Dec 2017 10:28:20 -0800 Subject: [PATCH 345/453] Update bootstrappers --- run.ps1 | 17 +++++++++++------ run.sh | 30 +++++++++++++++++++----------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/run.ps1 b/run.ps1 index 49c2899856..27dcf848f8 100644 --- a/run.ps1 +++ b/run.ps1 @@ -29,6 +29,9 @@ Updates KoreBuild to the latest version even if a lock file is present. .PARAMETER ConfigFile The path to the configuration file that stores values. Defaults to korebuild.json. +.PARAMETER ToolsSourceSuffix +The Suffix to append to the end of the ToolsSource. Useful for query strings in blob stores. + .PARAMETER Arguments Arguments to be passed to the command @@ -51,7 +54,7 @@ Example config file: #> [CmdletBinding(PositionalBinding = $false)] param( - [Parameter(Mandatory=$true, Position = 0)] + [Parameter(Mandatory = $true, Position = 0)] [string]$Command, [string]$Path = $PSScriptRoot, [Alias('c')] @@ -63,6 +66,7 @@ param( [Alias('u')] [switch]$Update, [string]$ConfigFile, + [string]$ToolsSourceSuffix, [Parameter(ValueFromRemainingArguments = $true)] [string[]]$Arguments ) @@ -79,7 +83,7 @@ function Get-KoreBuild { $lockFile = Join-Path $Path 'korebuild-lock.txt' if (!(Test-Path $lockFile) -or $Update) { - Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile + Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile $ToolsSourceSuffix } $version = Get-Content $lockFile | Where-Object { $_ -like 'version:*' } | Select-Object -first 1 @@ -96,7 +100,7 @@ function Get-KoreBuild { try { $tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip" - Get-RemoteFile $remotePath $tmpfile + Get-RemoteFile $remotePath $tmpfile $ToolsSourceSuffix if (Get-Command -Name 'Expand-Archive' -ErrorAction Ignore) { # Use built-in commands where possible as they are cross-plat compatible Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath @@ -124,7 +128,7 @@ function Join-Paths([string]$path, [string[]]$childPaths) { return $path } -function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) { +function Get-RemoteFile([string]$RemotePath, [string]$LocalPath, [string]$RemoteSuffix) { if ($RemotePath -notlike 'http*') { Copy-Item $RemotePath $LocalPath return @@ -134,7 +138,7 @@ function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) { while ($retries -gt 0) { $retries -= 1 try { - Invoke-WebRequest -UseBasicParsing -Uri $RemotePath -OutFile $LocalPath + Invoke-WebRequest -UseBasicParsing -Uri $($RemotePath + $RemoteSuffix) -OutFile $LocalPath return } catch { @@ -161,7 +165,8 @@ if (Test-Path $ConfigFile) { if (!($Channel) -and (Get-Member -Name 'channel' -InputObject $config)) { [string] $Channel = $config.channel } if (!($ToolsSource) -and (Get-Member -Name 'toolsSource' -InputObject $config)) { [string] $ToolsSource = $config.toolsSource} } - } catch { + } + catch { Write-Warning "$ConfigFile could not be read. Its settings will be ignored." Write-Warning $Error[0] } diff --git a/run.sh b/run.sh index c278423acc..834961fc3a 100755 --- a/run.sh +++ b/run.sh @@ -17,6 +17,7 @@ update=false repo_path="$DIR" channel='' tools_source='' +tools_source_suffix='' # # Functions @@ -29,13 +30,14 @@ __usage() { echo " ... Arguments passed to the command. Variable number of arguments allowed." echo "" echo "Options:" - echo " --verbose Show verbose output." - echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." - echo " --config-file The path to the configuration file that stores values. Defaults to korebuild.json." - echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." - echo " --path The directory to build. Defaults to the directory containing the script." - echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." - echo " -u|--update Update to the latest KoreBuild even if the lock file is present." + echo " --verbose Show verbose output." + echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." + echo " --config-file The path to the configuration file that stores values. Defaults to korebuild.json." + echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." + echo " --path The directory to build. Defaults to the directory containing the script." + echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." + echo " --tools-source-suffix|-ToolsSourceSuffix The suffix to append to tools-source. Useful for query strings." + echo " -u|--update Update to the latest KoreBuild even if the lock file is present." echo "" echo "Description:" echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." @@ -50,7 +52,7 @@ get_korebuild() { local version local lock_file="$repo_path/korebuild-lock.txt" if [ ! -f "$lock_file" ] || [ "$update" = true ]; then - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" + __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" "$tools_source_suffix" fi version="$(grep 'version:*' -m 1 "$lock_file")" if [[ "$version" == '' ]]; then @@ -66,7 +68,7 @@ get_korebuild() { local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" tmpfile="$(mktemp)" echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" - if __get_remote_file "$remote_path" "$tmpfile"; then + if __get_remote_file "$remote_path" "$tmpfile" "$tools_source_suffix"; then unzip -q -d "$korebuild_path" "$tmpfile" fi rm "$tmpfile" || true @@ -98,6 +100,7 @@ __machine_has() { __get_remote_file() { local remote_path=$1 local local_path=$2 + local remote_path_suffix=$3 if [[ "$remote_path" != 'http'* ]]; then cp "$remote_path" "$local_path" @@ -106,14 +109,14 @@ __get_remote_file() { local failed=false if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true + wget --tries 10 --quiet -O "$local_path" "${remote_path}${remote_path_suffix}" || failed=true else failed=true fi if [ "$failed" = true ] && __machine_has curl; then failed=false - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "${remote_path}${remote_path_suffix}" || failed=true fi if [ "$failed" = true ]; then @@ -164,6 +167,11 @@ while [[ $# -gt 0 ]]; do tools_source="${1:-}" [ -z "$tools_source" ] && __usage ;; + --tools-source-suffix|-ToolsSourceSuffix) + shift + tools_source_suffix="${1:-}" + [ -z "$tools_source_suffix" ] && __usage + ;; -u|--update|-Update) update=true ;; From 63874540d1d3554cf61af3c01d3763767443d3bb Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 10 Dec 2017 14:13:55 -0800 Subject: [PATCH 346/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 38 +++++++++++++++++++------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index a59a4c203c..218132127c 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,27 +3,27 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15576 - 1.0.0-pre-10202 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 0.5.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 + 2.1.0-preview1-15618 + 1.0.0-pre-10223 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 0.5.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 2.0.0 - 2.1.0-preview1-25907-02 + 2.1.0-preview1-25915-01 15.3.0 - 4.5.0-preview1-25902-08 - 2.3.0 - 2.3.0 + 4.5.0-preview1-25914-04 + 2.3.1 + 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 1a99066b7c..e7cce93009 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15576 -commithash:2f3856d2ba4f659fcb9253215b83946a06794a27 +version:2.1.0-preview1-15618 +commithash:00ce1383114015fe89b221146036e59e6bc11219 From 4d7697c9e1e21a88c9f7e0f4d6ff95e96c15d33b Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Wed, 13 Dec 2017 22:05:42 +0000 Subject: [PATCH 347/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 32 ++++++++++++++++---------------- korebuild-lock.txt | 4 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 218132127c..9b9b9e17da 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,25 +3,25 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15618 + 2.1.0-preview1-15626 1.0.0-pre-10223 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 0.5.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 0.5.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 2.0.0 - 2.1.0-preview1-25915-01 + 2.1.0-preview1-26008-01 15.3.0 - 4.5.0-preview1-25914-04 + 4.5.0-preview1-26006-06 2.3.1 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index e7cce93009..8d52a6128c 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15618 -commithash:00ce1383114015fe89b221146036e59e6bc11219 +version:2.1.0-preview1-15626 +commithash:fd6410e9c90c428bc01238372303ad09cb9ec889 From 814c03206eb09f664a2d5bd888c1afc0ac7d40b0 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Mon, 18 Dec 2017 18:18:59 -0800 Subject: [PATCH 348/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 9b9b9e17da..8b6182f051 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -5,23 +5,23 @@ 2.1.0-preview1-15626 1.0.0-pre-10223 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 0.5.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 0.5.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 2.0.0 - 2.1.0-preview1-26008-01 + 2.1.0-preview1-26016-05 15.3.0 - 4.5.0-preview1-26006-06 + 4.5.0-preview1-26016-05 2.3.1 2.3.1 From ad729f0eb159a489b331f4ca3870c44b752bd8c1 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Sat, 30 Dec 2017 17:16:25 +0100 Subject: [PATCH 349/453] fix typo (#215) --- test/AutobahnTestApp/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/AutobahnTestApp/README.md b/test/AutobahnTestApp/README.md index ece563a39b..6d76d57e64 100644 --- a/test/AutobahnTestApp/README.md +++ b/test/AutobahnTestApp/README.md @@ -1,6 +1,6 @@ # Autobahn Testing -This application is used to provide the server for the [Autobahn Test Suite](http://autobahn.ws/testsuite) 'fuzzingclient' mode to test. It is a simple echo server that echos each frame recieved back to the client. +This application is used to provide the server for the [Autobahn Test Suite](http://autobahn.ws/testsuite) 'fuzzingclient' mode to test. It is a simple echo server that echos each frame received back to the client. In order to run these tests you must install CPython 2.7, Pip, and the test suite modules. You must also have the `wstest` executable provided by the Autobahn Suite on the `PATH`. See http://autobahn.ws/testsuite/installation.html#installation for more info @@ -11,4 +11,4 @@ Once Autobahn is installed, launch this application in the desired configuration > .\scripts\RunAutobahnTests.ps1 -ServerUrl ws://server:1234 ``` -By default, all cases are run and the report is written to the `autobahnreports` sub-directory of the directory in which you run the script. You can change either by using the `-Cases` and `-OutputDir` switches, use `.\script\RunAutobahnTests.ps1 -?` for help. \ No newline at end of file +By default, all cases are run and the report is written to the `autobahnreports` sub-directory of the directory in which you run the script. You can change either by using the `-Cases` and `-OutputDir` switches, use `.\script\RunAutobahnTests.ps1 -?` for help. From 28fe0bc6013f14b6870723fde086aa4b83aff966 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 31 Dec 2017 22:21:40 +0000 Subject: [PATCH 350/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 30 +++++++++++++++--------------- korebuild-lock.txt | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 8b6182f051..7bbfc66cf9 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,21 +3,21 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15626 - 1.0.0-pre-10223 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 0.5.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 + 2.1.0-preview1-15651 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 0.5.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 2.0.0 2.1.0-preview1-26016-05 15.3.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 8d52a6128c..7c2e97aa79 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15626 -commithash:fd6410e9c90c428bc01238372303ad09cb9ec889 +version:2.1.0-preview1-15651 +commithash:ebf2365121c2c6a6a0fbfa9b0f37bb5effc89323 From 2f7dd78d7c3bf7e15d163be4454dba102a7ea282 Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Tue, 2 Jan 2018 14:23:59 -0800 Subject: [PATCH 351/453] Create ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000000..101a084f0a --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,3 @@ +THIS ISSUE TRACKER IS CLOSED - please log new issues here: https://github.com/aspnet/Home/issues + +For information about this change, see https://github.com/aspnet/Announcements/issues/283 From 27bcf521a1729ab98495ef28e2d0084c2a02baee Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 4 Jan 2018 02:29:15 +0000 Subject: [PATCH 352/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 7bbfc66cf9..4ac85faae8 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,20 +4,20 @@ 2.1.0-preview1-15651 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 0.5.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 0.5.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 2.0.0 2.1.0-preview1-26016-05 15.3.0 From de3355454c6a0fc2f86fd5fa21903e8eae44ed04 Mon Sep 17 00:00:00 2001 From: Justin Kotalik Date: Thu, 4 Jan 2018 16:58:30 -0800 Subject: [PATCH 353/453] Make M.A.AspNetCoreModule a conditional dependency (#218) --- test/AutobahnTestApp/AutobahnTestApp.csproj | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/AutobahnTestApp/AutobahnTestApp.csproj b/test/AutobahnTestApp/AutobahnTestApp.csproj index cd973145bb..175f724c74 100644 --- a/test/AutobahnTestApp/AutobahnTestApp.csproj +++ b/test/AutobahnTestApp/AutobahnTestApp.csproj @@ -13,8 +13,11 @@ - + + + + From d3687bbc3fedb2bd673f93c28f1e2ca780956da6 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Fri, 5 Jan 2018 12:39:11 -0800 Subject: [PATCH 354/453] Unbreak Travis and unskip some tests (#219) --- .travis.yml | 7 +- build/setup-wstest.sh | 30 ++ .../Autobahn/AutobahnTester.cs | 1 + .../Autobahn/Executable.cs | 6 +- .../Autobahn/Wstest.cs | 6 +- .../WebSocketMiddlewareTests.cs | 375 ++++++++---------- 6 files changed, 217 insertions(+), 208 deletions(-) create mode 100755 build/setup-wstest.sh diff --git a/.travis.yml b/.travis.yml index c553197516..05069ec25f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,9 +6,10 @@ env: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - AUTOBAHN_SUITES_LOG: 1 + - ASPNETCORE_WSTEST_PATH: "$TRAVIS_BUILD_DIR/.virtualenv/bin/wstest" mono: none python: - - "2.7" + - pypy os: - linux - osx @@ -23,9 +24,7 @@ branches: - release - dev - /^(.*\/)?ci-.*$/ -before_install: - - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl python; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi install: - - pip install autobahntestsuite "six>=1.9.0" + - ./build/setup-wstest.sh script: - ./build.sh diff --git a/build/setup-wstest.sh b/build/setup-wstest.sh new file mode 100755 index 0000000000..2fb19c5bf3 --- /dev/null +++ b/build/setup-wstest.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +if [ "$TRAVIS_OS_NAME" == "osx" ]; then + # Install python + brew update > /dev/null + brew install python +fi + +type -p python +python --version + +# Install local virtualenv +mkdir .python +cd .python +curl -O https://pypi.python.org/packages/d4/0c/9840c08189e030873387a73b90ada981885010dd9aea134d6de30cd24cb8/virtualenv-15.1.0.tar.gz +tar xf virtualenv-15.1.0.tar.gz +cd .. + +# Make a virtualenv +python ./.python/virtualenv-15.1.0/virtualenv.py .virtualenv + +.virtualenv/bin/python --version +.virtualenv/bin/pip --version + +# Install autobahn into the virtualenv +.virtualenv/bin/pip install autobahntestsuite + +# We're done. The travis config has already established the path to WSTest should be within the virtualenv. +ls -l .virtualenv/bin +.virtualenv/bin/wstest --version \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index c9e6007cb2..bc629e759b 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -43,6 +43,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn Spec.WriteJson(specFile); // Run the test (write something to the console so people know this will take a while...) + _logger.LogInformation("Using 'wstest' from: {WsTestPath}", Wstest.Default.Location); _logger.LogInformation("Now launching Autobahn Test Suite. This will take a while."); var exitCode = await Wstest.Default.ExecAsync("-m fuzzingclient -s " + specFile, cancellationToken, _loggerFactory.CreateLogger("wstest")); if (exitCode != 0) diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs index e012a13dc2..097b600d5a 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs @@ -12,11 +12,11 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { private static readonly string _exeSuffix = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : string.Empty; - private readonly string _path; + public string Location { get; } protected Executable(string path) { - _path = path; + Location = path; } public static string Locate(string name) @@ -38,7 +38,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { StartInfo = new ProcessStartInfo() { - FileName = _path, + FileName = Location, Arguments = args, UseShellExecute = false, RedirectStandardError = true, diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs index bfa2c18af9..a60a91e7c7 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs @@ -15,7 +15,11 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn private static Wstest Create() { - var location = Locate("wstest"); + var location = Environment.GetEnvironmentVariable("ASPNETCORE_WSTEST_PATH"); + if (string.IsNullOrEmpty(location)) + { + location = Locate("wstest"); + } return location == null ? null : new Wstest(location); } } diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs index 4034af10a4..cb0d8ec052 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs @@ -16,8 +16,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test private static string ClientAddress = "ws://localhost:54321/"; [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] - [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task Connect_Success() { @@ -35,8 +33,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] - [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task NegotiateSubProtocol_Success() { @@ -53,14 +49,19 @@ namespace Microsoft.AspNetCore.WebSockets.Test client.Options.AddSubProtocol("bravo"); client.Options.AddSubProtocol("charlie"); await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - Assert.Equal("Bravo", client.SubProtocol); + + // The Windows version of ClientWebSocket uses the casing from the header (Bravo) + // However, the Managed version seems match the header against the list generated by + // the AddSubProtocol calls (case-insensitively) and then use the version from + // that list as the value for SubProtocol. This is fine, but means we need to ignore case here. + // We could update our AddSubProtocols above to the same case but I think it's better to + // ensure this behavior is codified by this test. + Assert.Equal("Bravo", client.SubProtocol, ignoreCase: true); } } } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] - [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task SendEmptyData_Success() { @@ -86,8 +87,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] - [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task SendShortData_Success() { @@ -114,8 +113,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] - [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task SendMediumData_Success() { @@ -142,8 +139,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] - [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task SendLongData_Success() { @@ -182,8 +177,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] - [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task SendFragmentedData_Success() { @@ -228,8 +221,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] - [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task ReceiveShortData_Success() { @@ -256,8 +247,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] - [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task ReceiveMediumData_Success() { @@ -284,8 +273,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] - [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task ReceiveLongData() { @@ -319,223 +306,211 @@ namespace Microsoft.AspNetCore.WebSockets.Test } } - [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] - [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] - [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] - public async Task ReceiveFragmentedData_Success() - { - var orriginalData = Encoding.UTF8.GetBytes("Hello World"); - using (var server = KestrelWebSocketHelpers.CreateServer(async context => + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] + public async Task ReceiveFragmentedData_Success() { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - await webSocket.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); - await webSocket.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); - await webSocket.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); - })) - { - using (var client = new ClientWebSocket()) + var orriginalData = Encoding.UTF8.GetBytes("Hello World"); + using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - var clientBuffer = new byte[orriginalData.Length]; - var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); - Assert.False(result.EndOfMessage); - Assert.Equal(2, result.Count); - int totalReceived = result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - result = await client.ReceiveAsync( - new ArraySegment(clientBuffer, totalReceived, clientBuffer.Length - totalReceived), CancellationToken.None); - Assert.False(result.EndOfMessage); - Assert.Equal(2, result.Count); - totalReceived += result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + await webSocket.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); + await webSocket.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); + await webSocket.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var clientBuffer = new byte[orriginalData.Length]; + var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.False(result.EndOfMessage); + Assert.Equal(2, result.Count); + int totalReceived = result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - result = await client.ReceiveAsync( - new ArraySegment(clientBuffer, totalReceived, clientBuffer.Length - totalReceived), CancellationToken.None); + result = await client.ReceiveAsync( + new ArraySegment(clientBuffer, totalReceived, clientBuffer.Length - totalReceived), CancellationToken.None); + Assert.False(result.EndOfMessage); + Assert.Equal(2, result.Count); + totalReceived += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + result = await client.ReceiveAsync( + new ArraySegment(clientBuffer, totalReceived, clientBuffer.Length - totalReceived), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(7, result.Count); + totalReceived += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + Assert.Equal(orriginalData, clientBuffer); + } + } + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] + public async Task SendClose_Success() + { + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(async context => + { + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + var serverBuffer = new byte[1024]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); Assert.True(result.EndOfMessage); - Assert.Equal(7, result.Count); - totalReceived += result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - Assert.Equal(orriginalData, clientBuffer); + Assert.Equal(WebSocketState.CloseSent, client.State); + } } } - } - [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] - [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] - [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] - public async Task SendClose_Success() - { - string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(async context => + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] + public async Task ReceiveClose_Success() { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - var serverBuffer = new byte[1024]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Close, result.MessageType); - Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); - Assert.Equal(closeDescription, result.CloseStatusDescription); - })) - { - using (var client = new ClientWebSocket()) + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - await client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - Assert.Equal(WebSocketState.CloseSent, client.State); + await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var clientBuffer = new byte[1024]; + var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + + Assert.Equal(WebSocketState.CloseReceived, client.State); + } } } - } - [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] - [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] - [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] - public async Task ReceiveClose_Success() - { - string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(async context => + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] + public async Task CloseFromOpen_Success() { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - })) - { - using (var client = new ClientWebSocket()) + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - var clientBuffer = new byte[1024]; - var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + var serverBuffer = new byte[1024]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); Assert.True(result.EndOfMessage); Assert.Equal(0, result.Count); Assert.Equal(WebSocketMessageType.Close, result.MessageType); Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); Assert.Equal(closeDescription, result.CloseStatusDescription); - Assert.Equal(WebSocketState.CloseReceived, client.State); + await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + + Assert.Equal(WebSocketState.Closed, client.State); + } } } - } - [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] - [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] - [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] - public async Task CloseFromOpen_Success() - { - string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(async context => + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] + public async Task CloseFromCloseSent_Success() { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - var serverBuffer = new byte[1024]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Close, result.MessageType); - Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); - Assert.Equal(closeDescription, result.CloseStatusDescription); - - await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); - })) - { - using (var client = new ClientWebSocket()) + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(async context => { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - await client.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - Assert.Equal(WebSocketState.Closed, client.State); - } - } - } - - [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] - [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] - [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] - public async Task CloseFromCloseSent_Success() - { - string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - var serverBuffer = new byte[1024]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Close, result.MessageType); - Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); - Assert.Equal(closeDescription, result.CloseStatusDescription); - - await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); - })) - { - using (var client = new ClientWebSocket()) - { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - await client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - Assert.Equal(WebSocketState.CloseSent, client.State); - - await client.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - Assert.Equal(WebSocketState.Closed, client.State); - } - } - } - - [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux, SkipReason = "No WebSockets Client for this platform")] - [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "No WebSockets Client for this platform")] - [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] - public async Task CloseFromCloseReceived_Success() - { - string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - - var serverBuffer = new byte[1024]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Close, result.MessageType); - Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); - Assert.Equal(closeDescription, result.CloseStatusDescription); - })) - { - using (var client = new ClientWebSocket()) - { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - var clientBuffer = new byte[1024]; - var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + var serverBuffer = new byte[1024]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); Assert.True(result.EndOfMessage); Assert.Equal(0, result.Count); Assert.Equal(WebSocketMessageType.Close, result.MessageType); Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); Assert.Equal(closeDescription, result.CloseStatusDescription); - Assert.Equal(WebSocketState.CloseReceived, client.State); + await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + Assert.Equal(WebSocketState.CloseSent, client.State); - await client.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + await client.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + Assert.Equal(WebSocketState.Closed, client.State); + } + } + } - Assert.Equal(WebSocketState.Closed, client.State); + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] + public async Task CloseFromCloseReceived_Success() + { + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(async context => + { + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + + var serverBuffer = new byte[1024]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var clientBuffer = new byte[1024]; + var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + + Assert.Equal(WebSocketState.CloseReceived, client.State); + + await client.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + + Assert.Equal(WebSocketState.Closed, client.State); + } } } } } -} From 8e15dab86b0f22bc2912a9f0387a667fc6a84e13 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sat, 6 Jan 2018 15:55:14 -0800 Subject: [PATCH 355/453] Update dependencies.props [auto-updated: dependencies] --- korebuild-lock.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 7c2e97aa79..2146d006d7 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15651 -commithash:ebf2365121c2c6a6a0fbfa9b0f37bb5effc89323 +version:2.1.0-preview1-15661 +commithash:c9349d4c8a495d3085d9b879214d80f2f45e2193 From ec442c3d80ea1ab800350cc401dfebf54291d19e Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Mon, 22 Jan 2018 16:08:39 -0800 Subject: [PATCH 356/453] set HasRuntimeOutput for test projects (#221) --- test/Directory.Build.props | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 270e1fa209..be781a6b15 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -7,6 +7,14 @@ netcoreapp2.1;netcoreapp2.0 $(StandardTestTfms);net461 + + + + true + From eaa2b146ff39732a1f6d1778c27a43d47eaf8f10 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 23 Jan 2018 15:33:22 -0800 Subject: [PATCH 357/453] Branching for 2.1.0-preview1 --- build/dependencies.props | 34 +++++++++++++++++----------------- build/repo.props | 4 ++-- build/sources.props | 4 ++-- korebuild-lock.txt | 4 ++-- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 4ac85faae8..026ab70166 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,25 +3,25 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15651 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 0.5.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 + 2.1.0-preview1-15679 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 0.5.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 2.0.0 - 2.1.0-preview1-26016-05 + 2.1.0-preview1-26115-03 15.3.0 - 4.5.0-preview1-26016-05 + 4.5.0-preview1-26112-01 2.3.1 2.3.1 diff --git a/build/repo.props b/build/repo.props index a7ce27ecb1..cc5826a085 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,4 +1,4 @@ - + @@ -7,7 +7,7 @@ Internal.AspNetCore.Universe.Lineup - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json + https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json diff --git a/build/sources.props b/build/sources.props index 9feff29d09..5d66393335 100644 --- a/build/sources.props +++ b/build/sources.props @@ -1,11 +1,11 @@ - + $(DotNetRestoreSources) $(RestoreSources); - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; + https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 2146d006d7..a474bc0e35 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15661 -commithash:c9349d4c8a495d3085d9b879214d80f2f45e2193 +version:2.1.0-preview1-15679 +commithash:5347461137cb45a77ddcc0b55b2478092de43338 From 6bc49ad6ca029ff43310411e8db545b86bc985e8 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Tue, 23 Jan 2018 19:57:28 -0800 Subject: [PATCH 358/453] update to use corefx package (#222) --- .appveyor.yml | 2 +- .travis.yml | 2 +- build/dependencies.props | 2 +- scripts/UpdateCoreFxCode.ps1 | 44 - .../Internal/WebSocketFactory.cs | 32 - .../Internal/fx/CompatHelpers.cs | 35 - .../Internal/fx/README.md | 5 - .../Internal/fx/SR.cs | 24 - .../System/Net/WebSockets/ManagedWebSocket.cs | 1408 ----------------- .../Net/WebSockets/WebSocketValidate.cs | 150 -- .../Microsoft.AspNetCore.WebSockets.csproj | 2 +- .../WebSocketMiddleware.cs | 2 +- .../WebSocketPair.cs | 8 +- 13 files changed, 9 insertions(+), 1707 deletions(-) delete mode 100644 scripts/UpdateCoreFxCode.ps1 delete mode 100644 src/Microsoft.AspNetCore.WebSockets/Internal/WebSocketFactory.cs delete mode 100644 src/Microsoft.AspNetCore.WebSockets/Internal/fx/CompatHelpers.cs delete mode 100644 src/Microsoft.AspNetCore.WebSockets/Internal/fx/README.md delete mode 100644 src/Microsoft.AspNetCore.WebSockets/Internal/fx/SR.cs delete mode 100644 src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/ManagedWebSocket.cs delete mode 100644 src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs diff --git a/.appveyor.yml b/.appveyor.yml index 05a7c4ff85..7ca6d1770f 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -8,7 +8,7 @@ environment: branches: only: - master - - release + - /release\/.*/ - dev - /^(.*\/)?ci-.*$/ build_script: diff --git a/.travis.yml b/.travis.yml index 05069ec25f..1a8a676d38 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ addons: branches: only: - master - - release + - /release\/.*/ - dev - /^(.*\/)?ci-.*$/ install: diff --git a/build/dependencies.props b/build/dependencies.props index 026ab70166..5ba8e54c2c 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -21,7 +21,7 @@ 2.0.0 2.1.0-preview1-26115-03 15.3.0 - 4.5.0-preview1-26112-01 + 4.5.0-preview1-26119-06 2.3.1 2.3.1 diff --git a/scripts/UpdateCoreFxCode.ps1 b/scripts/UpdateCoreFxCode.ps1 deleted file mode 100644 index 09cfc3e448..0000000000 --- a/scripts/UpdateCoreFxCode.ps1 +++ /dev/null @@ -1,44 +0,0 @@ -param([string]$CoreFxRepoRoot) - -$RepoRoot = Split-Path -Parent $PSScriptRoot - -$FilesToCopy = @( - "src\Common\src\System\Net\WebSockets\ManagedWebSocket.cs", - "src\Common\src\System\Net\WebSockets\WebSocketValidate.cs" -) - -if(!$CoreFxRepoRoot) { - $CoreFxRepoRoot = "$RepoRoot\..\..\dotnet\corefx" -} - -if(!(Test-Path $CoreFxRepoRoot)) { - throw "Could not find CoreFx repo at $CoreFxRepoRoot" -} -$CoreFxRepoRoot = Convert-Path $CoreFxRepoRoot - -$DestinationRoot = "$RepoRoot\src\Microsoft.AspNetCore.WebSockets\Internal\fx" - -$FilesToCopy | foreach { - $Source = Join-Path $CoreFxRepoRoot $_ - $Destination = Join-Path $DestinationRoot $_ - $DestinationDir = Split-Path -Parent $Destination - - if(!(Test-Path $Source)) { - Write-Warning "Can't find source file: $Source" - } else { - if(!(Test-Path $DestinationDir)) { - mkdir $DestinationDir | Out-Null - } - if(Test-Path $Destination) { - del $Destination - } - Write-Host "Copying $_" - - $SourceCode = [IO.File]::ReadAllText($Source) - $SourceCode = $SourceCode.Replace("Task.FromException", "CompatHelpers.FromException") - $SourceCode = $SourceCode.Replace("Task.CompletedTask", "CompatHelpers.CompletedTask") - $SourceCode = $SourceCode.Replace("Array.Empty", "CompatHelpers.Empty") - $SourceCode = $SourceCode.Replace("nameof(ClientWebSocket)", "`"ClientWebSocket`"") - [IO.File]::WriteAllText($Destination, $SourceCode) - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets/Internal/WebSocketFactory.cs b/src/Microsoft.AspNetCore.WebSockets/Internal/WebSocketFactory.cs deleted file mode 100644 index d9f13b6d3d..0000000000 --- a/src/Microsoft.AspNetCore.WebSockets/Internal/WebSocketFactory.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.IO; -using System.Net.WebSockets; - -namespace Microsoft.AspNetCore.WebSockets.Internal -{ - public static class WebSocketFactory - { - public static WebSocket CreateClientWebSocket(Stream stream, string subProtocol, TimeSpan keepAliveInterval, int receiveBufferSize) - { - return ManagedWebSocket.CreateFromConnectedStream( - stream, - isServer: false, - subprotocol: subProtocol, - keepAliveInterval: keepAliveInterval, - receiveBufferSize: receiveBufferSize); - } - - public static WebSocket CreateServerWebSocket(Stream stream, string subProtocol, TimeSpan keepAliveInterval, int receiveBufferSize) - { - return ManagedWebSocket.CreateFromConnectedStream( - stream, - isServer: true, - subprotocol: subProtocol, - keepAliveInterval: keepAliveInterval, - receiveBufferSize: receiveBufferSize); - } - } -} diff --git a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/CompatHelpers.cs b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/CompatHelpers.cs deleted file mode 100644 index 420f3e7503..0000000000 --- a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/CompatHelpers.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Threading.Tasks; - -namespace System.Net.WebSockets -{ - // Needed to support the WebSockets code from CoreFX. - internal static class CompatHelpers - { - internal static readonly Task CompletedTask; - - static CompatHelpers() - { - var tcs = new TaskCompletionSource(); - tcs.SetResult(null); - CompletedTask = tcs.Task; - } - - public static Task FromException(Exception ex) - { - return Task.FromException(ex); - } - - public static Task FromException(Exception ex) - { - return Task.FromException(ex); - } - - internal static T[] Empty() - { - return Array.Empty(); - } - } - - // This is just here to be used by a nameof in the CoreFX code. - //internal static class ClientWebSocket { } -} diff --git a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/README.md b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/README.md deleted file mode 100644 index ac2ad020a7..0000000000 --- a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Code copied from dotnet/corefx - -This is code copied out of dotnet/corefx. **Do not** modify anything under the `src` subdirectory as it is copied by `scripts\UpdateCoreFxCore.ps1` in this repo. The files in the root of this directory are only here to shim out code that the corefx code depends on. - -Any changes to code under `src` in this directory MUST be made in dotnet/corefx as well and should mention `Tratcher`, `anurse` and `stephentoub`. \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/SR.cs b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/SR.cs deleted file mode 100644 index 4466198e20..0000000000 --- a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/SR.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace System.Net.WebSockets -{ - // Needed to support the WebSockets code from CoreFX. - internal static class SR - { - internal static readonly string net_Websockets_AlreadyOneOutstandingOperation = nameof(net_Websockets_AlreadyOneOutstandingOperation); - internal static readonly string net_WebSockets_Argument_InvalidMessageType = nameof(net_WebSockets_Argument_InvalidMessageType); - internal static readonly string net_WebSockets_InvalidCharInProtocolString = nameof(net_WebSockets_InvalidCharInProtocolString); - internal static readonly string net_WebSockets_InvalidCloseStatusCode = nameof(net_WebSockets_InvalidCloseStatusCode); - internal static readonly string net_WebSockets_InvalidCloseStatusDescription = nameof(net_WebSockets_InvalidCloseStatusDescription); - internal static readonly string net_WebSockets_InvalidEmptySubProtocol = nameof(net_WebSockets_InvalidEmptySubProtocol); - internal static readonly string net_WebSockets_InvalidState = nameof(net_WebSockets_InvalidState); - internal static readonly string net_WebSockets_InvalidState_ClosedOrAborted = nameof(net_WebSockets_InvalidState_ClosedOrAborted); - internal static readonly string net_WebSockets_ReasonNotNull = nameof(net_WebSockets_ReasonNotNull); - internal static readonly string net_WebSockets_UnsupportedPlatform = nameof(net_WebSockets_UnsupportedPlatform); - - internal static string Format(string name, params object[] args) => $"TODO, RESX: {name}; ({string.Join(",", args)})"; - } -} diff --git a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/ManagedWebSocket.cs b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/ManagedWebSocket.cs deleted file mode 100644 index ea8b828efe..0000000000 --- a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/ManagedWebSocket.cs +++ /dev/null @@ -1,1408 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Buffers; -using System.Diagnostics; -using System.IO; -using System.Numerics; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Security.Cryptography; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -// NOTE: This file is shared between CoreFX and ASP.NET. Be very thoughtful when changing it. - -namespace System.Net.WebSockets -{ - /// A managed implementation of a web socket that sends and receives data via a . - /// - /// Thread-safety: - /// - It's acceptable to call ReceiveAsync and SendAsync in parallel. One of each may run concurrently. - /// - It's acceptable to have a pending ReceiveAsync while CloseOutputAsync or CloseAsync is called. - /// - Attemping to invoke any other operations in parallel may corrupt the instance. Attempting to invoke - /// a send operation while another is in progress or a receive operation while another is in progress will - /// result in an exception. - /// - internal sealed class ManagedWebSocket : WebSocket - { - /// Creates a from a connected to a websocket endpoint. - /// The connected Stream. - /// true if this is the server-side of the connection; false if this is the client-side of the connection. - /// The agreed upon subprotocol for the connection. - /// The interval to use for keep-alive pings. - /// The buffer size to use for received data. - /// Optional buffer to use for receives. - /// The created instance. - public static ManagedWebSocket CreateFromConnectedStream( - Stream stream, bool isServer, string subprotocol, TimeSpan keepAliveInterval, int receiveBufferSize, ArraySegment? receiveBuffer = null) - { - return new ManagedWebSocket(stream, isServer, subprotocol, keepAliveInterval, receiveBufferSize, receiveBuffer); - } - - /// Per-thread cached 4-byte mask byte array. - [ThreadStatic] - private static byte[] t_headerMask; - - /// Thread-safe random number generator used to generate masks for each send. - private static readonly RandomNumberGenerator s_random = RandomNumberGenerator.Create(); - /// Encoding for the payload of text messages: UTF8 encoding that throws if invalid bytes are discovered, per the RFC. - private static readonly UTF8Encoding s_textEncoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true); - - /// Valid states to be in when calling SendAsync. - private static readonly WebSocketState[] s_validSendStates = { WebSocketState.Open, WebSocketState.CloseReceived }; - /// Valid states to be in when calling ReceiveAsync. - private static readonly WebSocketState[] s_validReceiveStates = { WebSocketState.Open, WebSocketState.CloseSent }; - /// Valid states to be in when calling CloseOutputAsync. - private static readonly WebSocketState[] s_validCloseOutputStates = { WebSocketState.Open, WebSocketState.CloseReceived }; - /// Valid states to be in when calling CloseAsync. - private static readonly WebSocketState[] s_validCloseStates = { WebSocketState.Open, WebSocketState.CloseReceived, WebSocketState.CloseSent }; - - /// The maximum size in bytes of a message frame header that includes mask bytes. - private const int MaxMessageHeaderLength = 14; - /// The maximum size of a control message payload. - private const int MaxControlPayloadLength = 125; - /// Length of the mask XOR'd with the payload data. - private const int MaskLength = 4; - - /// The stream used to communicate with the remote server. - private readonly Stream _stream; - /// - /// true if this is the server-side of the connection; false if it's client. - /// This impacts masking behavior: clients always mask payloads they send and - /// expect to always receive unmasked payloads, whereas servers always send - /// unmasked payloads and expect to always receive masked payloads. - /// - private readonly bool _isServer = false; - /// The agreed upon subprotocol with the server. - private readonly string _subprotocol; - /// Timer used to send periodic pings to the server, at the interval specified - private readonly Timer _keepAliveTimer; - /// CancellationTokenSource used to abort all current and future operations when anything is canceled or any error occurs. - private readonly CancellationTokenSource _abortSource = new CancellationTokenSource(); - /// Buffer used for reading data from the network. - private byte[] _receiveBuffer; - /// Gets whether the receive buffer came from the ArrayPool. - private readonly bool _receiveBufferFromPool; - /// - /// Tracks the state of the validity of the UTF8 encoding of text payloads. Text may be split across fragments. - /// - private readonly Utf8MessageState _utf8TextState = new Utf8MessageState(); - /// - /// Semaphore used to ensure that calls to SendFrameAsync don't run concurrently. While - /// is used to fail if a caller tries to issue another SendAsync while a previous one is running, internally - /// we use SendFrameAsync as an implementation detail, and it should not cause user requests to SendAsync to fail, - /// nor should such internal usage be allowed to run concurrently with other internal usage or with SendAsync. - /// - private readonly SemaphoreSlim _sendFrameAsyncLock = new SemaphoreSlim(1, 1); - - // We maintain the current WebSocketState in _state. However, we separately maintain _sentCloseFrame and _receivedCloseFrame - // as there isn't a strict ordering between CloseSent and CloseReceived. If we receive a close frame from the server, we need to - // transition to CloseReceived even if we're currently in CloseSent, and if we send a close frame, we need to transition to - // CloseSent even if we're currently in CloseReceived. - - /// The current state of the web socket in the protocol. - private WebSocketState _state = WebSocketState.Open; - /// true if Dispose has been called; otherwise, false. - private bool _disposed; - /// Whether we've ever sent a close frame. - private bool _sentCloseFrame; - /// Whether we've ever received a close frame. - private bool _receivedCloseFrame; - /// The reason for the close, as sent by the server, or null if not yet closed. - private WebSocketCloseStatus? _closeStatus = null; - /// A description of the close reason as sent by the server, or null if not yet closed. - private string _closeStatusDescription = null; - - /// - /// The last header received in a ReceiveAsync. If ReceiveAsync got a header but then - /// returned fewer bytes than was indicated in the header, subsequent ReceiveAsync calls - /// will use the data from the header to construct the subsequent receive results, and - /// the payload length in this header will be decremented to indicate the number of bytes - /// remaining to be received for that header. As a result, between fragments, the payload - /// length in this header should be 0. - /// - private MessageHeader _lastReceiveHeader = new MessageHeader { Opcode = MessageOpcode.Text, Fin = true }; - /// The offset of the next available byte in the _receiveBuffer. - private int _receiveBufferOffset = 0; - /// The number of bytes available in the _receiveBuffer. - private int _receiveBufferCount = 0; - /// - /// When dealing with partially read fragments of binary/text messages, a mask previously received may still - /// apply, and the first new byte received may not correspond to the 0th position in the mask. This value is - /// the next offset into the mask that should be applied. - /// - private int _receivedMaskOffsetOffset = 0; - /// - /// Temporary send buffer. This should be released back to the ArrayPool once it's - /// no longer needed for the current send operation. It is stored as an instance - /// field to minimize needing to pass it around and to avoid it becoming a field on - /// various async state machine objects. - /// - private byte[] _sendBuffer; - /// - /// Whether the last SendAsync had endOfMessage==false. We need to track this so that we - /// can send the subsequent message with a continuation opcode if the last message was a fragment. - /// - private bool _lastSendWasFragment; - /// - /// The task returned from the last SendAsync operation to not complete synchronously. - /// If this is not null and not completed when a subsequent SendAsync is issued, an exception occurs. - /// - private Task _lastSendAsync; - /// - /// The task returned from the last ReceiveAsync operation to not complete synchronously. - /// If this is not null and not completed when a subsequent ReceiveAsync is issued, an exception occurs. - /// - private Task _lastReceiveAsync; - - /// Lock used to protect update and check-and-update operations on _state. - private object StateUpdateLock => _abortSource; - /// - /// We need to coordinate between receives and close operations happening concurrently, as a ReceiveAsync may - /// be pending while a Close{Output}Async is issued, which itself needs to loop until a close frame is received. - /// As such, we need thread-safety in the management of . - /// - private object ReceiveAsyncLock => _utf8TextState; // some object, as we're simply lock'ing on it - - /// Initializes the websocket. - /// The connected Stream. - /// true if this is the server-side of the connection; false if this is the client-side of the connection. - /// The agreed upon subprotocol for the connection. - /// The interval to use for keep-alive pings. - /// The buffer size to use for received data. - /// Optional buffer to use for receives - private ManagedWebSocket(Stream stream, bool isServer, string subprotocol, TimeSpan keepAliveInterval, int receiveBufferSize, ArraySegment? receiveBuffer) - { - Debug.Assert(StateUpdateLock != null, $"Expected {nameof(StateUpdateLock)} to be non-null"); - Debug.Assert(ReceiveAsyncLock != null, $"Expected {nameof(ReceiveAsyncLock)} to be non-null"); - Debug.Assert(StateUpdateLock != ReceiveAsyncLock, "Locks should be different objects"); - - Debug.Assert(stream != null, $"Expected non-null stream"); - Debug.Assert(stream.CanRead, $"Expected readable stream"); - Debug.Assert(stream.CanWrite, $"Expected writeable stream"); - Debug.Assert(keepAliveInterval == Timeout.InfiniteTimeSpan || keepAliveInterval >= TimeSpan.Zero, $"Invalid keepalive interval: {keepAliveInterval}"); - Debug.Assert(receiveBufferSize >= MaxMessageHeaderLength, $"Receive buffer size {receiveBufferSize} is too small"); - - _stream = stream; - _isServer = isServer; - _subprotocol = subprotocol; - - // If we were provided with a buffer to use, use it, as long as it's big enough for our needs, and for simplicity - // as long as we're not supposed to use only a portion of it. If it doesn't meet our criteria, just create a new one. - if (receiveBuffer.HasValue && - receiveBuffer.Value.Offset == 0 && receiveBuffer.Value.Count == receiveBuffer.Value.Array.Length && - receiveBuffer.Value.Count >= MaxMessageHeaderLength) - { - _receiveBuffer = receiveBuffer.Value.Array; - } - else - { - _receiveBufferFromPool = true; - _receiveBuffer = ArrayPool.Shared.Rent(Math.Max(receiveBufferSize, MaxMessageHeaderLength)); - } - - // Set up the abort source so that if it's triggered, we transition the instance appropriately. - _abortSource.Token.Register(s => - { - var thisRef = (ManagedWebSocket)s; - - lock (thisRef.StateUpdateLock) - { - WebSocketState state = thisRef._state; - if (state != WebSocketState.Closed && state != WebSocketState.Aborted) - { - thisRef._state = state != WebSocketState.None && state != WebSocketState.Connecting ? - WebSocketState.Aborted : - WebSocketState.Closed; - } - } - }, this); - - // Now that we're opened, initiate the keep alive timer to send periodic pings - if (keepAliveInterval > TimeSpan.Zero) - { - _keepAliveTimer = new Timer(s => ((ManagedWebSocket)s).SendKeepAliveFrameAsync(), this, keepAliveInterval, keepAliveInterval); - } - } - - public override void Dispose() - { - lock (StateUpdateLock) - { - DisposeCore(); - } - } - - private void DisposeCore() - { - Debug.Assert(Monitor.IsEntered(StateUpdateLock), $"Expected {nameof(StateUpdateLock)} to be held"); - if (!_disposed) - { - _disposed = true; - _keepAliveTimer?.Dispose(); - _stream?.Dispose(); - if (_receiveBufferFromPool) - { - byte[] old = _receiveBuffer; - _receiveBuffer = null; - ArrayPool.Shared.Return(old); - } - if (_state < WebSocketState.Aborted) - { - _state = WebSocketState.Closed; - } - } - } - - public override WebSocketCloseStatus? CloseStatus => _closeStatus; - - public override string CloseStatusDescription => _closeStatusDescription; - - public override WebSocketState State => _state; - - public override string SubProtocol => _subprotocol; - - public override Task SendAsync(ArraySegment buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken) - { - if (messageType != WebSocketMessageType.Text && messageType != WebSocketMessageType.Binary) - { - throw new ArgumentException(SR.Format( - SR.net_WebSockets_Argument_InvalidMessageType, - nameof(WebSocketMessageType.Close), nameof(SendAsync), nameof(WebSocketMessageType.Binary), nameof(WebSocketMessageType.Text), nameof(CloseOutputAsync)), - nameof(messageType)); - } - WebSocketValidate.ValidateArraySegment(buffer, nameof(buffer)); - - try - { - WebSocketValidate.ThrowIfInvalidState(_state, _disposed, s_validSendStates); - ThrowIfOperationInProgress(_lastSendAsync); - } - catch (Exception exc) - { - return CompatHelpers.FromException(exc); - } - - MessageOpcode opcode = - _lastSendWasFragment ? MessageOpcode.Continuation : - messageType == WebSocketMessageType.Binary ? MessageOpcode.Binary : - MessageOpcode.Text; - - Task t = SendFrameAsync(opcode, endOfMessage, buffer, cancellationToken); - _lastSendWasFragment = !endOfMessage; - _lastSendAsync = t; - return t; - } - - public override Task ReceiveAsync(ArraySegment buffer, CancellationToken cancellationToken) - { - WebSocketValidate.ValidateArraySegment(buffer, nameof(buffer)); - - try - { - WebSocketValidate.ThrowIfInvalidState(_state, _disposed, s_validReceiveStates); - - Debug.Assert(!Monitor.IsEntered(StateUpdateLock), $"{nameof(StateUpdateLock)} must never be held when acquiring {nameof(ReceiveAsyncLock)}"); - lock (ReceiveAsyncLock) // synchronize with receives in CloseAsync - { - ThrowIfOperationInProgress(_lastReceiveAsync); - Task t = ReceiveAsyncPrivate(buffer, cancellationToken); - _lastReceiveAsync = t; - return t; - } - } - catch (Exception exc) - { - return CompatHelpers.FromException(exc); - } - } - - public override Task CloseAsync(WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken) - { - WebSocketValidate.ValidateCloseStatus(closeStatus, statusDescription); - - try - { - WebSocketValidate.ThrowIfInvalidState(_state, _disposed, s_validCloseStates); - } - catch (Exception exc) - { - return CompatHelpers.FromException(exc); - } - - return CloseAsyncPrivate(closeStatus, statusDescription, cancellationToken); - } - - public override Task CloseOutputAsync(WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken) - { - WebSocketValidate.ValidateCloseStatus(closeStatus, statusDescription); - - try - { - WebSocketValidate.ThrowIfInvalidState(_state, _disposed, s_validCloseOutputStates); - } - catch (Exception exc) - { - return CompatHelpers.FromException(exc); - } - - return SendCloseFrameAsync(closeStatus, statusDescription, cancellationToken); - } - - public override void Abort() - { - _abortSource.Cancel(); - Dispose(); // forcibly tear down connection - } - - /// Sends a websocket frame to the network. - /// The opcode for the message. - /// The value of the FIN bit for the message. - /// The buffer containing the payload data fro the message. - /// The CancellationToken to use to cancel the websocket. - private Task SendFrameAsync(MessageOpcode opcode, bool endOfMessage, ArraySegment payloadBuffer, CancellationToken cancellationToken) - { - // TODO: #4900 SendFrameAsync should in theory typically complete synchronously, making it fast and allocation free. - // However, due to #4900, it almost always yields, resulting in all of the allocations involved in an async method - // yielding, e.g. the boxed state machine, the Action delegate, the MoveNextRunner, and the resulting Task, plus it's - // common that the awaited operation completes so fast after the await that we may end up allocating an AwaitTaskContinuation - // inside of the TaskAwaiter. Since SendFrameAsync is such a core code path, until that can be fixed, we put some - // optimizations in place to avoid a few of those expenses, at the expense of more complicated code; for the common case, - // this code has fewer than half the number and size of allocations. If/when that issue is fixed, this method should be deleted - // and replaced by SendFrameFallbackAsync, which is the same logic but in a much more easily understand flow. - - // If a cancelable cancellation token was provided, that would require registering with it, which means more state we have to - // pass around (the CancellationTokenRegistration), so if it is cancelable, just immediately go to the fallback path. - // Similarly, it should be rare that there are multiple outstanding calls to SendFrameAsync, but if there are, again - // fall back to the fallback path. - return cancellationToken.CanBeCanceled || !_sendFrameAsyncLock.Wait(0) ? - SendFrameFallbackAsync(opcode, endOfMessage, payloadBuffer, cancellationToken) : - SendFrameLockAcquiredNonCancelableAsync(opcode, endOfMessage, payloadBuffer); - } - - /// Sends a websocket frame to the network. The caller must hold the sending lock. - /// The opcode for the message. - /// The value of the FIN bit for the message. - /// The buffer containing the payload data fro the message. - private Task SendFrameLockAcquiredNonCancelableAsync(MessageOpcode opcode, bool endOfMessage, ArraySegment payloadBuffer) - { - Debug.Assert(_sendFrameAsyncLock.CurrentCount == 0, "Caller should hold the _sendFrameAsyncLock"); - - // If we get here, the cancellation token is not cancelable so we don't have to worry about it, - // and we own the semaphore, so we don't need to asynchronously wait for it. - Task writeTask = null; - bool releaseSemaphoreAndSendBuffer = true; - try - { - // Write the payload synchronously to the buffer, then write that buffer out to the network. - int sendBytes = WriteFrameToSendBuffer(opcode, endOfMessage, payloadBuffer); - writeTask = _stream.WriteAsync(_sendBuffer, 0, sendBytes, CancellationToken.None); - - // If the operation happens to complete synchronously (or, more specifically, by - // the time we get from the previous line to here, release the semaphore, propagate - // exceptions, and we're done. - if (writeTask.IsCompleted) - { - writeTask.GetAwaiter().GetResult(); // propagate any exceptions - return CompatHelpers.CompletedTask; - } - - // Up until this point, if an exception occurred (such as when accessing _stream or when - // calling GetResult), we want to release the semaphore and the send buffer. After this point, - // both need to be held until writeTask completes. - releaseSemaphoreAndSendBuffer = false; - } - catch (Exception exc) - { - return CompatHelpers.FromException(_state == WebSocketState.Aborted ? - CreateOperationCanceledException(exc) : - new WebSocketException(WebSocketError.ConnectionClosedPrematurely, exc)); - } - finally - { - if (releaseSemaphoreAndSendBuffer) - { - _sendFrameAsyncLock.Release(); - ReleaseSendBuffer(); - } - } - - // The write was not yet completed. Create and return a continuation that will - // release the semaphore and translate any exception that occurred. - return writeTask.ContinueWith((t, s) => - { - var thisRef = (ManagedWebSocket)s; - thisRef._sendFrameAsyncLock.Release(); - thisRef.ReleaseSendBuffer(); - - try { t.GetAwaiter().GetResult(); } - catch (Exception exc) - { - throw thisRef._state == WebSocketState.Aborted ? - CreateOperationCanceledException(exc) : - new WebSocketException(WebSocketError.ConnectionClosedPrematurely, exc); - } - }, this, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default); - } - - private async Task SendFrameFallbackAsync(MessageOpcode opcode, bool endOfMessage, ArraySegment payloadBuffer, CancellationToken cancellationToken) - { - await _sendFrameAsyncLock.WaitAsync().ConfigureAwait(false); - try - { - int sendBytes = WriteFrameToSendBuffer(opcode, endOfMessage, payloadBuffer); - using (cancellationToken.Register(s => ((ManagedWebSocket)s).Abort(), this)) - { - await _stream.WriteAsync(_sendBuffer, 0, sendBytes, cancellationToken).ConfigureAwait(false); - } - } - catch (Exception exc) - { - throw _state == WebSocketState.Aborted ? - CreateOperationCanceledException(exc, cancellationToken) : - new WebSocketException(WebSocketError.ConnectionClosedPrematurely, exc); - } - finally - { - _sendFrameAsyncLock.Release(); - ReleaseSendBuffer(); - } - } - - /// Writes a frame into the send buffer, which can then be sent over the network. - private int WriteFrameToSendBuffer(MessageOpcode opcode, bool endOfMessage, ArraySegment payloadBuffer) - { - // Ensure we have a _sendBuffer. - AllocateSendBuffer(payloadBuffer.Count + MaxMessageHeaderLength); - - // Write the message header data to the buffer. - int headerLength; - int? maskOffset = null; - if (_isServer) - { - // The server doesn't send a mask, so the mask offset returned by WriteHeader - // is actually the end of the header. - headerLength = WriteHeader(opcode, _sendBuffer, payloadBuffer, endOfMessage, useMask: false); - } - else - { - // We need to know where the mask starts so that we can use the mask to manipulate the payload data, - // and we need to know the total length for sending it on the wire. - maskOffset = WriteHeader(opcode, _sendBuffer, payloadBuffer, endOfMessage, useMask: true); - headerLength = maskOffset.GetValueOrDefault() + MaskLength; - } - - // Write the payload - if (payloadBuffer.Count > 0) - { - Buffer.BlockCopy(payloadBuffer.Array, payloadBuffer.Offset, _sendBuffer, headerLength, payloadBuffer.Count); - - // If we added a mask to the header, XOR the payload with the mask. We do the manipulation in the send buffer so as to avoid - // changing the data in the caller-supplied payload buffer. - if (maskOffset.HasValue) - { - ApplyMask(_sendBuffer, headerLength, _sendBuffer, maskOffset.Value, 0, payloadBuffer.Count); - } - } - - // Return the number of bytes in the send buffer - return headerLength + payloadBuffer.Count; - } - - private void SendKeepAliveFrameAsync() - { - bool acquiredLock = _sendFrameAsyncLock.Wait(0); - if (acquiredLock) - { - // This exists purely to keep the connection alive; don't wait for the result, and ignore any failures. - // The call will handle releasing the lock. - SendFrameLockAcquiredNonCancelableAsync(MessageOpcode.Ping, true, new ArraySegment(CompatHelpers.Empty())); - } - else - { - // If the lock is already held, something is already getting sent, - // so there's no need to send a keep-alive ping. - } - } - - private static int WriteHeader(MessageOpcode opcode, byte[] sendBuffer, ArraySegment payload, bool endOfMessage, bool useMask) - { - // Client header format: - // 1 bit - FIN - 1 if this is the final fragment in the message (it could be the only fragment), otherwise 0 - // 1 bit - RSV1 - Reserved - 0 - // 1 bit - RSV2 - Reserved - 0 - // 1 bit - RSV3 - Reserved - 0 - // 4 bits - Opcode - How to interpret the payload - // - 0x0 - continuation - // - 0x1 - text - // - 0x2 - binary - // - 0x8 - connection close - // - 0x9 - ping - // - 0xA - pong - // - (0x3 to 0x7, 0xB-0xF - reserved) - // 1 bit - Masked - 1 if the payload is masked, 0 if it's not. Must be 1 for the client - // 7 bits, 7+16 bits, or 7+64 bits - Payload length - // - For length 0 through 125, 7 bits storing the length - // - For lengths 126 through 2^16, 7 bits storing the value 126, followed by 16 bits storing the length - // - For lengths 2^16+1 through 2^64, 7 bits storing the value 127, followed by 64 bytes storing the length - // 0 or 4 bytes - Mask, if Masked is 1 - random value XOR'd with each 4 bytes of the payload, round-robin - // Length bytes - Payload data - - Debug.Assert(sendBuffer.Length >= MaxMessageHeaderLength, $"Expected sendBuffer to be at least {MaxMessageHeaderLength}, got {sendBuffer.Length}"); - - sendBuffer[0] = (byte)opcode; // 4 bits for the opcode - if (endOfMessage) - { - sendBuffer[0] |= 0x80; // 1 bit for FIN - } - - // Store the payload length. - int maskOffset; - if (payload.Count <= 125) - { - sendBuffer[1] = (byte)payload.Count; - maskOffset = 2; // no additional payload length - } - else if (payload.Count <= ushort.MaxValue) - { - sendBuffer[1] = 126; - sendBuffer[2] = (byte)(payload.Count / 256); - sendBuffer[3] = unchecked((byte)payload.Count); - maskOffset = 2 + sizeof(ushort); // additional 2 bytes for 16-bit length - } - else - { - sendBuffer[1] = 127; - int length = payload.Count; - for (int i = 9; i >= 2; i--) - { - sendBuffer[i] = unchecked((byte)length); - length = length / 256; - } - maskOffset = 2 + sizeof(ulong); // additional 8 bytes for 64-bit length - } - - if (useMask) - { - // Generate the mask. - sendBuffer[1] |= 0x80; - WriteRandomMask(sendBuffer, maskOffset); - } - - // Return the position of the mask. - return maskOffset; - } - - /// Writes a 4-byte random mask to the specified buffer at the specified offset. - /// The buffer to which to write the mask. - /// The offset into the buffer at which to write the mask. - private static void WriteRandomMask(byte[] buffer, int offset) - { - byte[] mask = t_headerMask ?? (t_headerMask = new byte[MaskLength]); - Debug.Assert(mask.Length == MaskLength, $"Expected mask of length {MaskLength}, got {mask.Length}"); - s_random.GetBytes(mask); - Buffer.BlockCopy(mask, 0, buffer, offset, MaskLength); - } - - /// - /// Receive the next text, binary, continuation, or close message, returning information about it and - /// writing its payload into the supplied buffer. Other control messages may be consumed and processed - /// as part of this operation, but data about them will not be returned. - /// - /// The buffer into which payload data should be written. - /// The CancellationToken used to cancel the websocket. - /// Information about the received message. - private async Task ReceiveAsyncPrivate(ArraySegment payloadBuffer, CancellationToken cancellationToken) - { - // This is a long method. While splitting it up into pieces would arguably help with readability, doing so would - // also result in more allocations, as each async method that yields ends up with multiple allocations. The impact - // of those allocations is amortized across all of the awaits in the method, and since we generally expect a receive - // operation to require at most a single yield (while waiting for data to arrive), it's more efficient to have - // everything in the one method. We do separate out pieces for handling close and ping/pong messages, as we expect - // those to be much less frequent (e.g. we should only get one close per websocket), and thus we can afford to pay - // a bit more for readability and maintainability. - - CancellationTokenRegistration registration = cancellationToken.Register(s => ((ManagedWebSocket)s).Abort(), this); - try - { - while (true) // in case we get control frames that should be ignored from the user's perspective - { - // Get the last received header. If its payload length is non-zero, that means we previously - // received the header but were only able to read a part of the fragment, so we should skip - // reading another header and just proceed to use that same header and read more data associated - // with it. If instead its payload length is zero, then we've completed the processing of - // thta message, and we should read the next header. - MessageHeader header = _lastReceiveHeader; - if (header.PayloadLength == 0) - { - if (_receiveBufferCount < (_isServer ? (MaxMessageHeaderLength - MaskLength) : MaxMessageHeaderLength)) - { - // Make sure we have the first two bytes, which includes the start of the payload length. - if (_receiveBufferCount < 2) - { - await EnsureBufferContainsAsync(2, cancellationToken, throwOnPrematureClosure: true).ConfigureAwait(false); - } - - // Then make sure we have the full header based on the payload length. - // If this is the server, we also need room for the received mask. - long payloadLength = _receiveBuffer[_receiveBufferOffset + 1] & 0x7F; - if (_isServer || payloadLength > 125) - { - int minNeeded = - 2 + - (_isServer ? MaskLength : 0) + - (payloadLength <= 125 ? 0 : payloadLength == 126 ? sizeof(ushort) : sizeof(ulong)); // additional 2 or 8 bytes for 16-bit or 64-bit length - await EnsureBufferContainsAsync(minNeeded, cancellationToken).ConfigureAwait(false); - } - } - - if (!TryParseMessageHeaderFromReceiveBuffer(out header)) - { - await CloseWithReceiveErrorAndThrowAsync(WebSocketCloseStatus.ProtocolError, WebSocketError.Faulted, cancellationToken).ConfigureAwait(false); - } - _receivedMaskOffsetOffset = 0; - } - - // If the header represents a ping or a pong, it's a control message meant - // to be transparent to the user, so handle it and then loop around to read again. - // Alternatively, if it's a close message, handle it and exit. - if (header.Opcode == MessageOpcode.Ping || header.Opcode == MessageOpcode.Pong) - { - await HandleReceivedPingPongAsync(header, cancellationToken).ConfigureAwait(false); - continue; - } - else if (header.Opcode == MessageOpcode.Close) - { - return await HandleReceivedCloseAsync(header, cancellationToken).ConfigureAwait(false); - } - - // If this is a continuation, replace the opcode with the one of the message it's continuing - if (header.Opcode == MessageOpcode.Continuation) - { - header.Opcode = _lastReceiveHeader.Opcode; - } - - // The message should now be a binary or text message. Handle it by reading the payload and returning the contents. - Debug.Assert(header.Opcode == MessageOpcode.Binary || header.Opcode == MessageOpcode.Text, $"Unexpected opcode {header.Opcode}"); - - // If there's no data to read, return an appropriate result. - int bytesToRead = (int)Math.Min(payloadBuffer.Count, header.PayloadLength); - if (bytesToRead == 0) - { - _lastReceiveHeader = header; - return new WebSocketReceiveResult( - 0, - header.Opcode == MessageOpcode.Text ? WebSocketMessageType.Text : WebSocketMessageType.Binary, - header.PayloadLength == 0 ? header.Fin : false); - } - - // Otherwise, read as much of the payload as we can efficiently, and upate the header to reflect how much data - // remains for future reads. - - if (_receiveBufferCount == 0) - { - await EnsureBufferContainsAsync(1, cancellationToken, throwOnPrematureClosure: false).ConfigureAwait(false); - } - - int bytesToCopy = Math.Min(bytesToRead, _receiveBufferCount); - if (_isServer) - { - _receivedMaskOffsetOffset = ApplyMask(_receiveBuffer, _receiveBufferOffset, header.Mask, _receivedMaskOffsetOffset, bytesToCopy); - } - Buffer.BlockCopy(_receiveBuffer, _receiveBufferOffset, payloadBuffer.Array, payloadBuffer.Offset, bytesToCopy); - ConsumeFromBuffer(bytesToCopy); - header.PayloadLength -= bytesToCopy; - - // If this a text message, validate that it contains valid UTF8. - if (header.Opcode == MessageOpcode.Text && - !TryValidateUtf8(new ArraySegment(payloadBuffer.Array, payloadBuffer.Offset, bytesToCopy), header.Fin, _utf8TextState)) - { - await CloseWithReceiveErrorAndThrowAsync(WebSocketCloseStatus.InvalidPayloadData, WebSocketError.Faulted, cancellationToken).ConfigureAwait(false); - } - - _lastReceiveHeader = header; - return new WebSocketReceiveResult( - bytesToCopy, - header.Opcode == MessageOpcode.Text ? WebSocketMessageType.Text : WebSocketMessageType.Binary, - bytesToCopy == 0 || (header.Fin && header.PayloadLength == 0)); - } - } - catch (Exception exc) - { - if (_state == WebSocketState.Aborted) - { - throw new OperationCanceledException(nameof(WebSocketState.Aborted), exc); - } - throw new WebSocketException(WebSocketError.ConnectionClosedPrematurely, exc); - } - finally - { - registration.Dispose(); - } - } - - /// Processes a received close message. - /// The message header. - /// The cancellation token to use to cancel the websocket. - /// The received result message. - private async Task HandleReceivedCloseAsync( - MessageHeader header, CancellationToken cancellationToken) - { - lock (StateUpdateLock) - { - _receivedCloseFrame = true; - if (_state < WebSocketState.CloseReceived) - { - _state = WebSocketState.CloseReceived; - } - } - - WebSocketCloseStatus closeStatus = WebSocketCloseStatus.NormalClosure; - string closeStatusDescription = string.Empty; - - // Handle any payload by parsing it into the close status and description. - if (header.PayloadLength == 1) - { - // The close payload length can be 0 or >= 2, but not 1. - await CloseWithReceiveErrorAndThrowAsync(WebSocketCloseStatus.ProtocolError, WebSocketError.Faulted, cancellationToken).ConfigureAwait(false); - } - else if (header.PayloadLength >= 2) - { - if (_receiveBufferCount < header.PayloadLength) - { - await EnsureBufferContainsAsync((int)header.PayloadLength, cancellationToken).ConfigureAwait(false); - } - - if (_isServer) - { - ApplyMask(_receiveBuffer, _receiveBufferOffset, header.Mask, 0, header.PayloadLength); - } - - closeStatus = (WebSocketCloseStatus)(_receiveBuffer[_receiveBufferOffset] << 8 | _receiveBuffer[_receiveBufferOffset + 1]); - if (!IsValidCloseStatus(closeStatus)) - { - await CloseWithReceiveErrorAndThrowAsync(WebSocketCloseStatus.ProtocolError, WebSocketError.Faulted, cancellationToken).ConfigureAwait(false); - } - - if (header.PayloadLength > 2) - { - try - { - closeStatusDescription = s_textEncoding.GetString(_receiveBuffer, _receiveBufferOffset + 2, (int)header.PayloadLength - 2); - } - catch (DecoderFallbackException exc) - { - await CloseWithReceiveErrorAndThrowAsync(WebSocketCloseStatus.ProtocolError, WebSocketError.Faulted, cancellationToken, exc).ConfigureAwait(false); - } - } - ConsumeFromBuffer((int)header.PayloadLength); - } - - // Store the close status and description onto the instance. - _closeStatus = closeStatus; - _closeStatusDescription = closeStatusDescription; - - // And return them as part of the result message. - return new WebSocketReceiveResult(0, WebSocketMessageType.Close, true, closeStatus, closeStatusDescription); - } - - /// Processes a received ping or pong message. - /// The message header. - /// The cancellation token to use to cancel the websocket. - private async Task HandleReceivedPingPongAsync(MessageHeader header, CancellationToken cancellationToken) - { - // Consume any (optional) payload associated with the ping/pong. - if (header.PayloadLength > 0 && _receiveBufferCount < header.PayloadLength) - { - await EnsureBufferContainsAsync((int)header.PayloadLength, cancellationToken).ConfigureAwait(false); - } - - // If this was a ping, send back a pong response. - if (header.Opcode == MessageOpcode.Ping) - { - if (_isServer) - { - ApplyMask(_receiveBuffer, _receiveBufferOffset, header.Mask, 0, header.PayloadLength); - } - - await SendFrameAsync( - MessageOpcode.Pong, true, - new ArraySegment(_receiveBuffer, _receiveBufferOffset, (int)header.PayloadLength), cancellationToken).ConfigureAwait(false); - } - - // Regardless of whether it was a ping or pong, we no longer need the payload. - if (header.PayloadLength > 0) - { - ConsumeFromBuffer((int)header.PayloadLength); - } - } - - /// Check whether a close status is valid according to the RFC. - /// The status to validate. - /// true if the status if valid; otherwise, false. - private static bool IsValidCloseStatus(WebSocketCloseStatus closeStatus) - { - // 0-999: "not used" - // 1000-2999: reserved for the protocol; we need to check individual codes manually - // 3000-3999: reserved for use by higher-level code - // 4000-4999: reserved for private use - // 5000-: not mentioned in RFC - - if (closeStatus < (WebSocketCloseStatus)1000 || closeStatus >= (WebSocketCloseStatus)5000) - { - return false; - } - - if (closeStatus >= (WebSocketCloseStatus)3000) - { - return true; - } - - switch (closeStatus) // check for the 1000-2999 range known codes - { - case WebSocketCloseStatus.EndpointUnavailable: - case WebSocketCloseStatus.InternalServerError: - case WebSocketCloseStatus.InvalidMessageType: - case WebSocketCloseStatus.InvalidPayloadData: - case WebSocketCloseStatus.MandatoryExtension: - case WebSocketCloseStatus.MessageTooBig: - case WebSocketCloseStatus.NormalClosure: - case WebSocketCloseStatus.PolicyViolation: - case WebSocketCloseStatus.ProtocolError: - return true; - - default: - return false; - } - } - - /// Send a close message to the server and throw an exception, in response to getting bad data from the server. - /// The close status code to use. - /// The error reason. - /// The CancellationToken used to cancel the websocket. - /// An optional inner exception to include in the thrown exception. - private async Task CloseWithReceiveErrorAndThrowAsync( - WebSocketCloseStatus closeStatus, WebSocketError error, CancellationToken cancellationToken, Exception innerException = null) - { - // Close the connection if it hasn't already been closed - if (!_sentCloseFrame) - { - await CloseOutputAsync(closeStatus, string.Empty, cancellationToken).ConfigureAwait(false); - } - - // Dump our receive buffer; we're in a bad state to do any further processing - _receiveBufferCount = 0; - - // Let the caller know we've failed - throw new WebSocketException(error, innerException); - } - - /// Parses a message header from the buffer. This assumes the header is in the buffer. - /// The read header. - /// true if a header was read; false if the header was invalid. - private bool TryParseMessageHeaderFromReceiveBuffer(out MessageHeader resultHeader) - { - Debug.Assert(_receiveBufferCount >= 2, $"Expected to at least have the first two bytes of the header."); - - var header = new MessageHeader(); - - header.Fin = (_receiveBuffer[_receiveBufferOffset] & 0x80) != 0; - bool reservedSet = (_receiveBuffer[_receiveBufferOffset] & 0x70) != 0; - header.Opcode = (MessageOpcode)(_receiveBuffer[_receiveBufferOffset] & 0xF); - - bool masked = (_receiveBuffer[_receiveBufferOffset + 1] & 0x80) != 0; - header.PayloadLength = _receiveBuffer[_receiveBufferOffset + 1] & 0x7F; - - ConsumeFromBuffer(2); - - // Read the remainder of the payload length, if necessary - if (header.PayloadLength == 126) - { - Debug.Assert(_receiveBufferCount >= 2, $"Expected to have two bytes for the payload length."); - header.PayloadLength = (_receiveBuffer[_receiveBufferOffset] << 8) | _receiveBuffer[_receiveBufferOffset + 1]; - ConsumeFromBuffer(2); - } - else if (header.PayloadLength == 127) - { - Debug.Assert(_receiveBufferCount >= 8, $"Expected to have eight bytes for the payload length."); - header.PayloadLength = 0; - for (int i = 0; i < 8; i++) - { - header.PayloadLength = (header.PayloadLength << 8) | _receiveBuffer[_receiveBufferOffset + i]; - } - ConsumeFromBuffer(8); - } - - bool shouldFail = reservedSet; - if (masked) - { - if (!_isServer) - { - shouldFail = true; - } - header.Mask = CombineMaskBytes(_receiveBuffer, _receiveBufferOffset); - - // Consume the mask bytes - ConsumeFromBuffer(4); - } - - // Do basic validation of the header - switch (header.Opcode) - { - case MessageOpcode.Continuation: - if (_lastReceiveHeader.Fin) - { - // Can't continue from a final message - shouldFail = true; - } - break; - - case MessageOpcode.Binary: - case MessageOpcode.Text: - if (!_lastReceiveHeader.Fin) - { - // Must continue from a non-final message - shouldFail = true; - } - break; - - case MessageOpcode.Close: - case MessageOpcode.Ping: - case MessageOpcode.Pong: - if (header.PayloadLength > MaxControlPayloadLength || !header.Fin) - { - // Invalid control messgae - shouldFail = true; - } - break; - - default: - // Unknown opcode - shouldFail = true; - break; - } - - // Return the read header - resultHeader = header; - return !shouldFail; - } - - /// Send a close message, then receive until we get a close response message. - /// The close status to send. - /// The close status description to send. - /// The CancellationToken to use to cancel the websocket. - private async Task CloseAsyncPrivate(WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken) - { - // Send the close message. Skip sending a close frame if we're currently in a CloseSent state, - // for example having just done a CloseOutputAsync. - if (!_sentCloseFrame) - { - await SendCloseFrameAsync(closeStatus, statusDescription, cancellationToken).ConfigureAwait(false); - } - - // We should now either be in a CloseSent case (because we just sent one), or in a CloseReceived state, in case - // there was a concurrent receive that ended up handling an immediate close frame response from the server. - // Of course it could also be Aborted if something happened concurrently to cause things to blow up. - Debug.Assert( - State == WebSocketState.CloseSent || - State == WebSocketState.CloseReceived || - State == WebSocketState.Aborted, - $"Unexpected state {State}."); - - // Wait until we've received a close response - byte[] closeBuffer = ArrayPool.Shared.Rent(MaxMessageHeaderLength + MaxControlPayloadLength); - try - { - while (!_receivedCloseFrame) - { - Debug.Assert(!Monitor.IsEntered(StateUpdateLock), $"{nameof(StateUpdateLock)} must never be held when acquiring {nameof(ReceiveAsyncLock)}"); - Task receiveTask; - lock (ReceiveAsyncLock) - { - // Now that we're holding the ReceiveAsyncLock, double-check that we've not yet received the close frame. - // It could have been received between our check above and now due to a concurrent receive completing. - if (_receivedCloseFrame) - { - break; - } - - // We've not yet processed a received close frame, which means we need to wait for a received close to complete. - // There may already be one in flight, in which case we want to just wait for that one rather than kicking off - // another (we don't support concurrent receive operations). We need to kick off a new receive if either we've - // never issued a receive or if the last issued receive completed for reasons other than a close frame. There is - // a race condition here, e.g. if there's a in-flight receive that completes after we check, but that's fine: worst - // case is we then await it, find that it's not what we need, and try again. - receiveTask = _lastReceiveAsync; - if (receiveTask == null || - (receiveTask.Status == TaskStatus.RanToCompletion && receiveTask.Result.MessageType != WebSocketMessageType.Close)) - { - _lastReceiveAsync = receiveTask = ReceiveAsyncPrivate(new ArraySegment(closeBuffer), cancellationToken); - } - } - - // Wait for whatever receive task we have. We'll then loop around again to re-check our state. - Debug.Assert(receiveTask != null); - await receiveTask.ConfigureAwait(false); - } - } - finally - { - ArrayPool.Shared.Return(closeBuffer); - } - - // We're closed. Close the connection and update the status. - lock (StateUpdateLock) - { - DisposeCore(); - if (_state < WebSocketState.Closed) - { - _state = WebSocketState.Closed; - } - } - } - - /// Sends a close message to the server. - /// The close status to send. - /// The close status description to send. - /// The CancellationToken to use to cancel the websocket. - private async Task SendCloseFrameAsync(WebSocketCloseStatus closeStatus, string closeStatusDescription, CancellationToken cancellationToken) - { - // Close payload is two bytes containing the close status followed by a UTF8-encoding of the status description, if it exists. - - byte[] buffer = null; - try - { - int count = 2; - if (string.IsNullOrEmpty(closeStatusDescription)) - { - buffer = ArrayPool.Shared.Rent(count); - } - else - { - count += s_textEncoding.GetByteCount(closeStatusDescription); - buffer = ArrayPool.Shared.Rent(count); - int encodedLength = s_textEncoding.GetBytes(closeStatusDescription, 0, closeStatusDescription.Length, buffer, 2); - Debug.Assert(count - 2 == encodedLength, $"GetByteCount and GetBytes encoded count didn't match"); - } - - ushort closeStatusValue = (ushort)closeStatus; - buffer[0] = (byte)(closeStatusValue >> 8); - buffer[1] = (byte)(closeStatusValue & 0xFF); - - await SendFrameAsync(MessageOpcode.Close, true, new ArraySegment(buffer, 0, count), cancellationToken).ConfigureAwait(false); - } - finally - { - if (buffer != null) - { - ArrayPool.Shared.Return(buffer); - } - } - - lock (StateUpdateLock) - { - _sentCloseFrame = true; - if (_state <= WebSocketState.CloseReceived) - { - _state = WebSocketState.CloseSent; - } - } - } - - private void ConsumeFromBuffer(int count) - { - Debug.Assert(count >= 0, $"Expected non-negative count, got {count}"); - Debug.Assert(count <= _receiveBufferCount, $"Trying to consume {count}, which is more than exists {_receiveBufferCount}"); - _receiveBufferCount -= count; - _receiveBufferOffset += count; - } - - private async Task EnsureBufferContainsAsync(int minimumRequiredBytes, CancellationToken cancellationToken, bool throwOnPrematureClosure = true) - { - Debug.Assert(minimumRequiredBytes <= _receiveBuffer.Length, $"Requested number of bytes {minimumRequiredBytes} must not exceed {_receiveBuffer.Length}"); - - // If we don't have enough data in the buffer to satisfy the minimum required, read some more. - if (_receiveBufferCount < minimumRequiredBytes) - { - // If there's any data in the buffer, shift it down. - if (_receiveBufferCount > 0) - { - Buffer.BlockCopy(_receiveBuffer, _receiveBufferOffset, _receiveBuffer, 0, _receiveBufferCount); - } - _receiveBufferOffset = 0; - - // While we don't have enough data, read more. - while (_receiveBufferCount < minimumRequiredBytes) - { - int numRead = await _stream.ReadAsync(_receiveBuffer, _receiveBufferCount, _receiveBuffer.Length - _receiveBufferCount, cancellationToken).ConfigureAwait(false); - Debug.Assert(numRead >= 0, $"Expected non-negative bytes read, got {numRead}"); - _receiveBufferCount += numRead; - if (numRead == 0) - { - // The connection closed before we were able to read everything we needed. - // If it was due to use being disposed, fail. If it was due to the connection - // being closed and it wasn't expected, fail. If it was due to the connection - // being closed and that was expected, exit gracefully. - if (_disposed) - { - throw new ObjectDisposedException("ClientWebSocket"); - } - else if (throwOnPrematureClosure) - { - throw new WebSocketException(WebSocketError.ConnectionClosedPrematurely); - } - break; - } - } - } - } - - /// Gets a send buffer from the pool. - private void AllocateSendBuffer(int minLength) - { - Debug.Assert(_sendBuffer == null); // would only fail if had some catastrophic error previously that prevented cleaning up - _sendBuffer = ArrayPool.Shared.Rent(minLength); - } - - /// Releases the send buffer to the pool. - private void ReleaseSendBuffer() - { - byte[] old = _sendBuffer; - if (old != null) - { - _sendBuffer = null; - ArrayPool.Shared.Return(old); - } - } - - private static unsafe int CombineMaskBytes(byte[] buffer, int maskOffset) => - BitConverter.ToInt32(buffer, maskOffset); - - /// Applies a mask to a portion of a byte array. - /// The buffer to which the mask should be applied. - /// The offset into at which the mask should start to be applied. - /// The array containing the mask to apply. - /// The offset into of the mask to apply of length . - /// The next position offset from of which by to apply next from the mask. - /// The number of bytes starting from to which the mask should be applied. - /// The updated maskOffsetOffset value. - private static int ApplyMask(byte[] toMask, int toMaskOffset, byte[] mask, int maskOffset, int maskOffsetIndex, long count) - { - Debug.Assert(maskOffsetIndex < MaskLength, $"Unexpected {nameof(maskOffsetIndex)}: {maskOffsetIndex}"); - Debug.Assert(mask.Length >= MaskLength + maskOffset, $"Unexpected inputs: {mask.Length}, {maskOffset}"); - return ApplyMask(toMask, toMaskOffset, CombineMaskBytes(mask, maskOffset), maskOffsetIndex, count); - } - - /// Applies a mask to a portion of a byte array. - /// The buffer to which the mask should be applied. - /// The offset into at which the mask should start to be applied. - /// The four-byte mask, stored as an Int32. - /// The index into the mask. - /// The number of bytes to mask. - /// The next index into the mask to be used for future applications of the mask. - private static unsafe int ApplyMask(byte[] toMask, int toMaskOffset, int mask, int maskIndex, long count) - { - int maskShift = maskIndex * 8; - int shiftedMask = (int)(((uint)mask >> maskShift) | ((uint)mask << (32 - maskShift))); - - // Try to use SIMD. We can if the number of bytes we're trying to mask is at least as much - // as the width of a vector and if the width is an even multiple of the mask. - if (Vector.IsHardwareAccelerated && - Vector.Count % sizeof(int) == 0 && - count >= Vector.Count) - { - // Mask bytes a vector at a time. - Vector maskVector = Vector.AsVectorByte(new Vector(shiftedMask)); - while (count >= Vector.Count) - { - count -= Vector.Count; - (maskVector ^ new Vector(toMask, toMaskOffset)).CopyTo(toMask, toMaskOffset); - toMaskOffset += Vector.Count; - } - - // Fall through to processing any remaining bytes that were less than a vector width. - // Since we processed full masks at a time, we don't need to update maskIndex, and - // toMaskOffset has already been updated to point to the correct location. - } - - // If there are any bytes remaining (either we couldn't use vectors, or the count wasn't - // an even multiple of the vector width), process them without vectors. - if (count > 0) - { - fixed (byte* toMaskPtr = toMask) - { - // Get the location in the target array to continue processing. - byte* p = toMaskPtr + toMaskOffset; - - // Try to go an int at a time if the remaining data is 4-byte aligned and there's enough remaining. - if (((long)p % sizeof(int)) == 0) - { - while (count >= sizeof(int)) - { - count -= sizeof(int); - *((int*)p) ^= shiftedMask; - p += sizeof(int); - } - - // We don't need to update the maskIndex, as its mod-4 value won't have changed. - // `p` points to the remainder. - } - - // Process any remaining data a byte at a time. - if (count > 0) - { - byte* maskPtr = (byte*)&mask; - byte* end = p + count; - while (p < end) - { - *p++ ^= maskPtr[maskIndex]; - maskIndex = (maskIndex + 1) & 3; - } - } - } - } - - // Return the updated index. - return maskIndex; - } - - /// Aborts the websocket and throws an exception if an existing operation is in progress. - private void ThrowIfOperationInProgress(Task operationTask, [CallerMemberName] string methodName = null) - { - if (operationTask != null && !operationTask.IsCompleted) - { - Abort(); - throw new InvalidOperationException(SR.Format(SR.net_Websockets_AlreadyOneOutstandingOperation, methodName)); - } - } - - /// Creates an OperationCanceledException instance, using a default message and the specified inner exception and token. - private static Exception CreateOperationCanceledException(Exception innerException, CancellationToken cancellationToken = default(CancellationToken)) - { - return new OperationCanceledException( - new OperationCanceledException().Message, - innerException, - cancellationToken); - } - - // From https://raw.githubusercontent.com/aspnet/WebSockets/dev/src/Microsoft.AspNetCore.WebSockets.Protocol/Utilities.cs - // Performs a stateful validation of UTF-8 bytes. - // It checks for valid formatting, overlong encodings, surrogates, and value ranges. - private static bool TryValidateUtf8(ArraySegment arraySegment, bool endOfMessage, Utf8MessageState state) - { - for (int i = arraySegment.Offset; i < arraySegment.Offset + arraySegment.Count;) - { - // Have we started a character sequence yet? - if (!state.SequenceInProgress) - { - // The first byte tells us how many bytes are in the sequence. - state.SequenceInProgress = true; - byte b = arraySegment.Array[i]; - i++; - if ((b & 0x80) == 0) // 0bbbbbbb, single byte - { - state.AdditionalBytesExpected = 0; - state.CurrentDecodeBits = b & 0x7F; - state.ExpectedValueMin = 0; - } - else if ((b & 0xC0) == 0x80) - { - // Misplaced 10bbbbbb continuation byte. This cannot be the first byte. - return false; - } - else if ((b & 0xE0) == 0xC0) // 110bbbbb 10bbbbbb - { - state.AdditionalBytesExpected = 1; - state.CurrentDecodeBits = b & 0x1F; - state.ExpectedValueMin = 0x80; - } - else if ((b & 0xF0) == 0xE0) // 1110bbbb 10bbbbbb 10bbbbbb - { - state.AdditionalBytesExpected = 2; - state.CurrentDecodeBits = b & 0xF; - state.ExpectedValueMin = 0x800; - } - else if ((b & 0xF8) == 0xF0) // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb - { - state.AdditionalBytesExpected = 3; - state.CurrentDecodeBits = b & 0x7; - state.ExpectedValueMin = 0x10000; - } - else // 111110bb & 1111110b & 11111110 && 11111111 are not valid - { - return false; - } - } - while (state.AdditionalBytesExpected > 0 && i < arraySegment.Offset + arraySegment.Count) - { - byte b = arraySegment.Array[i]; - if ((b & 0xC0) != 0x80) - { - return false; - } - - i++; - state.AdditionalBytesExpected--; - - // Each continuation byte carries 6 bits of data 0x10bbbbbb. - state.CurrentDecodeBits = (state.CurrentDecodeBits << 6) | (b & 0x3F); - - if (state.AdditionalBytesExpected == 1 && state.CurrentDecodeBits >= 0x360 && state.CurrentDecodeBits <= 0x37F) - { - // This is going to end up in the range of 0xD800-0xDFFF UTF-16 surrogates that are not allowed in UTF-8; - return false; - } - if (state.AdditionalBytesExpected == 2 && state.CurrentDecodeBits >= 0x110) - { - // This is going to be out of the upper Unicode bound 0x10FFFF. - return false; - } - } - if (state.AdditionalBytesExpected == 0) - { - state.SequenceInProgress = false; - if (state.CurrentDecodeBits < state.ExpectedValueMin) - { - // Overlong encoding (e.g. using 2 bytes to encode something that only needed 1). - return false; - } - } - } - if (endOfMessage && state.SequenceInProgress) - { - return false; - } - return true; - } - - private sealed class Utf8MessageState - { - internal bool SequenceInProgress; - internal int AdditionalBytesExpected; - internal int ExpectedValueMin; - internal int CurrentDecodeBits; - } - - private enum MessageOpcode : byte - { - Continuation = 0x0, - Text = 0x1, - Binary = 0x2, - Close = 0x8, - Ping = 0x9, - Pong = 0xA - } - - [StructLayout(LayoutKind.Auto)] - private struct MessageHeader - { - internal MessageOpcode Opcode; - internal bool Fin; - internal long PayloadLength; - internal int Mask; - } - } -} diff --git a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs b/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs deleted file mode 100644 index 4a1018610e..0000000000 --- a/src/Microsoft.AspNetCore.WebSockets/Internal/fx/src/Common/src/System/Net/WebSockets/WebSocketValidate.cs +++ /dev/null @@ -1,150 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Globalization; -using System.Text; - -namespace System.Net.WebSockets -{ - internal static partial class WebSocketValidate - { - internal const int MaxControlFramePayloadLength = 123; - private const int CloseStatusCodeAbort = 1006; - private const int CloseStatusCodeFailedTLSHandshake = 1015; - private const int InvalidCloseStatusCodesFrom = 0; - private const int InvalidCloseStatusCodesTo = 999; - private const string Separators = "()<>@,;:\\\"/[]?={} "; - - internal static void ThrowIfInvalidState(WebSocketState currentState, bool isDisposed, WebSocketState[] validStates) - { - string validStatesText = string.Empty; - - if (validStates != null && validStates.Length > 0) - { - foreach (WebSocketState validState in validStates) - { - if (currentState == validState) - { - // Ordering is important to maintain .NET 4.5 WebSocket implementation exception behavior. - if (isDisposed) - { - throw new ObjectDisposedException("ClientWebSocket"); - } - - return; - } - } - - validStatesText = string.Join(", ", validStates); - } - - throw new WebSocketException( - WebSocketError.InvalidState, - SR.Format(SR.net_WebSockets_InvalidState, currentState, validStatesText)); - } - - internal static void ValidateSubprotocol(string subProtocol) - { - if (string.IsNullOrWhiteSpace(subProtocol)) - { - throw new ArgumentException(SR.net_WebSockets_InvalidEmptySubProtocol, nameof(subProtocol)); - } - - string invalidChar = null; - int i = 0; - while (i < subProtocol.Length) - { - char ch = subProtocol[i]; - if (ch < 0x21 || ch > 0x7e) - { - invalidChar = string.Format(CultureInfo.InvariantCulture, "[{0}]", (int)ch); - break; - } - - if (!char.IsLetterOrDigit(ch) && - Separators.IndexOf(ch) >= 0) - { - invalidChar = ch.ToString(); - break; - } - - i++; - } - - if (invalidChar != null) - { - throw new ArgumentException(SR.Format(SR.net_WebSockets_InvalidCharInProtocolString, subProtocol, invalidChar), nameof(subProtocol)); - } - } - - internal static void ValidateCloseStatus(WebSocketCloseStatus closeStatus, string statusDescription) - { - if (closeStatus == WebSocketCloseStatus.Empty && !string.IsNullOrEmpty(statusDescription)) - { - throw new ArgumentException(SR.Format(SR.net_WebSockets_ReasonNotNull, - statusDescription, - WebSocketCloseStatus.Empty), - nameof(statusDescription)); - } - - int closeStatusCode = (int)closeStatus; - - if ((closeStatusCode >= InvalidCloseStatusCodesFrom && - closeStatusCode <= InvalidCloseStatusCodesTo) || - closeStatusCode == CloseStatusCodeAbort || - closeStatusCode == CloseStatusCodeFailedTLSHandshake) - { - // CloseStatus 1006 means Aborted - this will never appear on the wire and is reflected by calling WebSocket.Abort - throw new ArgumentException(SR.Format(SR.net_WebSockets_InvalidCloseStatusCode, - closeStatusCode), - nameof(closeStatus)); - } - - int length = 0; - if (!string.IsNullOrEmpty(statusDescription)) - { - length = Encoding.UTF8.GetByteCount(statusDescription); - } - - if (length > MaxControlFramePayloadLength) - { - throw new ArgumentException(SR.Format(SR.net_WebSockets_InvalidCloseStatusDescription, - statusDescription, - MaxControlFramePayloadLength), - nameof(statusDescription)); - } - } - - internal static void ThrowPlatformNotSupportedException() - { - throw new PlatformNotSupportedException(SR.net_WebSockets_UnsupportedPlatform); - } - - internal static void ValidateArraySegment(ArraySegment arraySegment, string parameterName) - { - if (arraySegment.Array == null) - { - throw new ArgumentNullException(parameterName + ".Array"); - } - } - - internal static void ValidateBuffer(byte[] buffer, int offset, int count) - { - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - if (offset < 0 || offset > buffer.Length) - { - throw new ArgumentOutOfRangeException(nameof(offset)); - } - - if (count < 0 || count > (buffer.Length - offset)) - { - throw new ArgumentOutOfRangeException(nameof(count)); - } - } - } -} diff --git a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj index 56d06497f5..c5c5c8fbfb 100644 --- a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj +++ b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs b/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs index cc61b1414d..d9653c1051 100644 --- a/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs +++ b/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs @@ -118,7 +118,7 @@ namespace Microsoft.AspNetCore.WebSockets } Stream opaqueTransport = await _upgradeFeature.UpgradeAsync(); // Sets status code to 101 - return WebSocketFactory.CreateServerWebSocket(opaqueTransport, subProtocol, keepAliveInterval, receiveBufferSize); + return WebSocketProtocol.CreateFromStream(opaqueTransport, isServer: true, subProtocol: subProtocol, keepAliveInterval: keepAliveInterval); } } } diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketPair.cs b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketPair.cs index aded688e42..4a43250566 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketPair.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketPair.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Net.WebSockets; using Microsoft.AspNetCore.WebSockets.Internal; @@ -28,8 +28,8 @@ namespace Microsoft.AspNetCore.WebSockets.Test return new WebSocketPair( serverStream, clientStream, - clientSocket: WebSocketFactory.CreateClientWebSocket(clientStream, null, TimeSpan.FromMinutes(2), 1024), - serverSocket: WebSocketFactory.CreateServerWebSocket(serverStream, null, TimeSpan.FromMinutes(2), 1024)); + clientSocket: WebSocketProtocol.CreateFromStream(clientStream, isServer: false, subProtocol: null, keepAliveInterval: TimeSpan.FromMinutes(2)), + serverSocket: WebSocketProtocol.CreateFromStream(serverStream, isServer: true, subProtocol: null, keepAliveInterval: TimeSpan.FromMinutes(2))); } } -} \ No newline at end of file +} From 48b951661a5e689a7f41b50ede8a109fd9cfc65a Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Wed, 24 Jan 2018 15:52:05 -0800 Subject: [PATCH 359/453] Preview2 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 5c4a7c32d1..370d5ababd 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.1.0 - preview1 + preview2 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 5b18df55cbe1230dca759ffead9acbe31b425799 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 25 Jan 2018 15:29:57 -0800 Subject: [PATCH 360/453] upgrade deps to resolve build failures (#225) --- build/dependencies.props | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 5ba8e54c2c..2de3e02327 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,22 +4,22 @@ 2.1.0-preview1-15679 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 0.5.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 + 2.1.0-preview1-28172 + 2.1.0-preview1-28172 + 2.1.0-preview1-28172 + 2.1.0-preview1-28172 + 2.1.0-preview1-28172 + 0.5.0-preview1-28172 + 2.1.0-preview1-28172 + 2.1.0-preview1-28172 + 2.1.0-preview1-28172 + 2.1.0-preview1-28172 + 2.1.0-preview1-28172 + 2.1.0-preview1-28172 + 2.1.0-preview1-28172 + 2.1.0-preview1-28172 2.0.0 - 2.1.0-preview1-26115-03 + 2.1.0-preview1-26122-01 15.3.0 4.5.0-preview1-26119-06 2.3.1 From a6fc4776dab12d97f6b99acc0e575e2c1d80e6c3 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Fri, 26 Jan 2018 12:27:41 -0800 Subject: [PATCH 361/453] fix Kestrel version to fix build (#227) --- build/dependencies.props | 33 +- korebuild-lock.txt | 4 +- .../EchoApp/Properties/launchSettings.json | 2 +- .../WebSocketMiddleware.cs | 1 + .../KestrelWebSocketHelpers.cs | 5 +- ...icrosoft.AspNetCore.WebSockets.Test.csproj | 1 + .../WebSocketMiddlewareTests.cs | 700 ++++++++++-------- 7 files changed, 403 insertions(+), 343 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 9037161b08..831c3b89e8 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,23 +3,24 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15651 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 0.5.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 + 2.1.0-preview2-15684 + 2.1.0-preview2-28183 + 2.1.0-preview2-28183 + 2.1.0-preview2-28183 + 2.1.0-preview2-28183 + 2.1.0-preview2-28183 + 0.5.0-preview2-28183 + 2.1.0-preview2-28183 + 2.1.0-preview2-28183 + 2.1.0-preview2-28183 + 2.1.0-preview2-28183 + 2.1.0-preview2-28183 + 2.1.0-preview2-28183 + 2.1.0-preview2-28183 + 2.1.0-preview2-28183 + 2.1.0-preview2-28183 2.0.0 - 2.1.0-preview1-26016-05 + 2.1.0-preview1-26122-01 15.3.0 4.5.0-preview1-26119-06 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 2146d006d7..1ae5d69845 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15661 -commithash:c9349d4c8a495d3085d9b879214d80f2f45e2193 +version:2.1.0-preview2-15684 +commithash:308af8e3279892aad7f189ffbddd3ff9a60970d3 diff --git a/samples/EchoApp/Properties/launchSettings.json b/samples/EchoApp/Properties/launchSettings.json index a9b371ff56..fba441af3d 100644 --- a/samples/EchoApp/Properties/launchSettings.json +++ b/samples/EchoApp/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:3159/", + "applicationUrl": "http://localhost:62225/", "sslPort": 0 } }, diff --git a/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs b/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs index d9653c1051..eba9597cd5 100644 --- a/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs +++ b/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs @@ -116,6 +116,7 @@ namespace Microsoft.AspNetCore.WebSockets { _context.Response.Headers[headerPair.Key] = headerPair.Value; } + Stream opaqueTransport = await _upgradeFeature.UpgradeAsync(); // Sets status code to 101 return WebSocketProtocol.CreateFromStream(opaqueTransport, isServer: true, subProtocol: subProtocol, keepAliveInterval: keepAliveInterval); diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs index 646286183a..77ec387c10 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs @@ -7,12 +7,14 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.DependencyInjection; namespace Microsoft.AspNetCore.WebSockets.Test { public class KestrelWebSocketHelpers { - public static IDisposable CreateServer(Func app) + public static IDisposable CreateServer(ILoggerFactory loggerFactory, Func app) { Action startup = builder => { @@ -46,6 +48,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test config["server.urls"] = "http://localhost:54321"; var host = new WebHostBuilder() + .ConfigureServices(s => s.AddSingleton(loggerFactory)) .UseConfiguration(config) .UseKestrel() .Configure(startup) diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj index c85c41eb0e..5e7f2eb67e 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj @@ -9,6 +9,7 @@ + diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs index cb0d8ec052..0f60b1d90d 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs @@ -7,27 +7,36 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Testing.xunit; +using Microsoft.Extensions.Logging.Testing; using Xunit; +using Xunit.Abstractions; namespace Microsoft.AspNetCore.WebSockets.Test { - public class WebSocketMiddlewareTests + public class WebSocketMiddlewareTests : LoggedTest { private static string ClientAddress = "ws://localhost:54321/"; + public WebSocketMiddlewareTests(ITestOutputHelper output) : base(output) + { + } + [ConditionalFact] [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task Connect_Success() { - using (var server = KestrelWebSocketHelpers.CreateServer(async context => + using (StartLog(out var loggerFactory)) { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - })) - { - using (var client = new ClientWebSocket()) + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + } } } } @@ -36,27 +45,30 @@ namespace Microsoft.AspNetCore.WebSockets.Test [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task NegotiateSubProtocol_Success() { - using (var server = KestrelWebSocketHelpers.CreateServer(async context => + using (StartLog(out var loggerFactory)) { - Assert.True(context.WebSockets.IsWebSocketRequest); - Assert.Equal("alpha, bravo, charlie", context.Request.Headers["Sec-WebSocket-Protocol"]); - var webSocket = await context.WebSockets.AcceptWebSocketAsync("Bravo"); - })) - { - using (var client = new ClientWebSocket()) + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => { - client.Options.AddSubProtocol("alpha"); - client.Options.AddSubProtocol("bravo"); - client.Options.AddSubProtocol("charlie"); - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - - // The Windows version of ClientWebSocket uses the casing from the header (Bravo) - // However, the Managed version seems match the header against the list generated by - // the AddSubProtocol calls (case-insensitively) and then use the version from - // that list as the value for SubProtocol. This is fine, but means we need to ignore case here. - // We could update our AddSubProtocols above to the same case but I think it's better to - // ensure this behavior is codified by this test. - Assert.Equal("Bravo", client.SubProtocol, ignoreCase: true); + Assert.True(context.WebSockets.IsWebSocketRequest); + Assert.Equal("alpha, bravo, charlie", context.Request.Headers["Sec-WebSocket-Protocol"]); + var webSocket = await context.WebSockets.AcceptWebSocketAsync("Bravo"); + })) + { + using (var client = new ClientWebSocket()) + { + client.Options.AddSubProtocol("alpha"); + client.Options.AddSubProtocol("bravo"); + client.Options.AddSubProtocol("charlie"); + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + + // The Windows version of ClientWebSocket uses the casing from the header (Bravo) + // However, the Managed version seems match the header against the list generated by + // the AddSubProtocol calls (case-insensitively) and then use the version from + // that list as the value for SubProtocol. This is fine, but means we need to ignore case here. + // We could update our AddSubProtocols above to the same case but I think it's better to + // ensure this behavior is codified by this test. + Assert.Equal("Bravo", client.SubProtocol, ignoreCase: true); + } } } } @@ -65,23 +77,26 @@ namespace Microsoft.AspNetCore.WebSockets.Test [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task SendEmptyData_Success() { - using (var server = KestrelWebSocketHelpers.CreateServer(async context => + using (StartLog(out var loggerFactory)) { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - var serverBuffer = new byte[0]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - })) - { - using (var client = new ClientWebSocket()) + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - var orriginalData = new byte[0]; - await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + var serverBuffer = new byte[0]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var orriginalData = new byte[0]; + await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + } } } } @@ -90,24 +105,27 @@ namespace Microsoft.AspNetCore.WebSockets.Test [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task SendShortData_Success() { - var orriginalData = Encoding.UTF8.GetBytes("Hello World"); - using (var server = KestrelWebSocketHelpers.CreateServer(async context => + using (StartLog(out var loggerFactory)) { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - var serverBuffer = new byte[orriginalData.Length]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(orriginalData.Length, result.Count); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - Assert.Equal(orriginalData, serverBuffer); - })) - { - using (var client = new ClientWebSocket()) + var orriginalData = Encoding.UTF8.GetBytes("Hello World"); + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + var serverBuffer = new byte[orriginalData.Length]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, serverBuffer); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + } } } } @@ -116,24 +134,27 @@ namespace Microsoft.AspNetCore.WebSockets.Test [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task SendMediumData_Success() { - var orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); - using (var server = KestrelWebSocketHelpers.CreateServer(async context => + using (StartLog(out var loggerFactory)) { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - var serverBuffer = new byte[orriginalData.Length]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(orriginalData.Length, result.Count); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - Assert.Equal(orriginalData, serverBuffer); - })) - { - using (var client = new ClientWebSocket()) + var orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + var serverBuffer = new byte[orriginalData.Length]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, serverBuffer); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + } } } } @@ -142,36 +163,39 @@ namespace Microsoft.AspNetCore.WebSockets.Test [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task SendLongData_Success() { - var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); - using (var server = KestrelWebSocketHelpers.CreateServer(async context => + using (StartLog(out var loggerFactory)) { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - var serverBuffer = new byte[orriginalData.Length]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - int intermediateCount = result.Count; - Assert.False(result.EndOfMessage); - Assert.Equal(WebSocketMessageType.Text, result.MessageType); - - result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer, intermediateCount, orriginalData.Length - intermediateCount), CancellationToken.None); - intermediateCount += result.Count; - Assert.False(result.EndOfMessage); - Assert.Equal(WebSocketMessageType.Text, result.MessageType); - - result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer, intermediateCount, orriginalData.Length - intermediateCount), CancellationToken.None); - intermediateCount += result.Count; - Assert.True(result.EndOfMessage); - Assert.Equal(orriginalData.Length, intermediateCount); - Assert.Equal(WebSocketMessageType.Text, result.MessageType); - - Assert.Equal(orriginalData, serverBuffer); - })) - { - using (var client = new ClientWebSocket()) + var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + var serverBuffer = new byte[orriginalData.Length]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + int intermediateCount = result.Count; + Assert.False(result.EndOfMessage); + Assert.Equal(WebSocketMessageType.Text, result.MessageType); + + result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer, intermediateCount, orriginalData.Length - intermediateCount), CancellationToken.None); + intermediateCount += result.Count; + Assert.False(result.EndOfMessage); + Assert.Equal(WebSocketMessageType.Text, result.MessageType); + + result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer, intermediateCount, orriginalData.Length - intermediateCount), CancellationToken.None); + intermediateCount += result.Count; + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, intermediateCount); + Assert.Equal(WebSocketMessageType.Text, result.MessageType); + + Assert.Equal(orriginalData, serverBuffer); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + } } } } @@ -180,42 +204,45 @@ namespace Microsoft.AspNetCore.WebSockets.Test [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task SendFragmentedData_Success() { - var orriginalData = Encoding.UTF8.GetBytes("Hello World"); - using (var server = KestrelWebSocketHelpers.CreateServer(async context => + using (StartLog(out var loggerFactory)) { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - var serverBuffer = new byte[orriginalData.Length]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.False(result.EndOfMessage); - Assert.Equal(2, result.Count); - int totalReceived = result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - - result = await webSocket.ReceiveAsync( - new ArraySegment(serverBuffer, totalReceived, serverBuffer.Length - totalReceived), CancellationToken.None); - Assert.False(result.EndOfMessage); - Assert.Equal(2, result.Count); - totalReceived += result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - - result = await webSocket.ReceiveAsync( - new ArraySegment(serverBuffer, totalReceived, serverBuffer.Length - totalReceived), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(7, result.Count); - totalReceived += result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - - Assert.Equal(orriginalData, serverBuffer); - })) - { - using (var client = new ClientWebSocket()) + var orriginalData = Encoding.UTF8.GetBytes("Hello World"); + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - await client.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); - await client.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); - await client.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + var serverBuffer = new byte[orriginalData.Length]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.False(result.EndOfMessage); + Assert.Equal(2, result.Count); + int totalReceived = result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + result = await webSocket.ReceiveAsync( + new ArraySegment(serverBuffer, totalReceived, serverBuffer.Length - totalReceived), CancellationToken.None); + Assert.False(result.EndOfMessage); + Assert.Equal(2, result.Count); + totalReceived += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + result = await webSocket.ReceiveAsync( + new ArraySegment(serverBuffer, totalReceived, serverBuffer.Length - totalReceived), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(7, result.Count); + totalReceived += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + Assert.Equal(orriginalData, serverBuffer); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); + await client.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); + await client.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); + } } } } @@ -224,24 +251,27 @@ namespace Microsoft.AspNetCore.WebSockets.Test [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task ReceiveShortData_Success() { - var orriginalData = Encoding.UTF8.GetBytes("Hello World"); - using (var server = KestrelWebSocketHelpers.CreateServer(async context => + using (StartLog(out var loggerFactory)) { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - })) - { - using (var client = new ClientWebSocket()) + var orriginalData = Encoding.UTF8.GetBytes("Hello World"); + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - var clientBuffer = new byte[orriginalData.Length]; - var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(orriginalData.Length, result.Count); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - Assert.Equal(orriginalData, clientBuffer); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var clientBuffer = new byte[orriginalData.Length]; + var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, clientBuffer); + } } } } @@ -250,24 +280,27 @@ namespace Microsoft.AspNetCore.WebSockets.Test [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task ReceiveMediumData_Success() { - var orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); - using (var server = KestrelWebSocketHelpers.CreateServer(async context => + using (StartLog(out var loggerFactory)) { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - })) - { - using (var client = new ClientWebSocket()) + var orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - var clientBuffer = new byte[orriginalData.Length]; - var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(orriginalData.Length, result.Count); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - Assert.Equal(orriginalData, clientBuffer); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var clientBuffer = new byte[orriginalData.Length]; + var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, clientBuffer); + } } } } @@ -276,32 +309,35 @@ namespace Microsoft.AspNetCore.WebSockets.Test [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task ReceiveLongData() { - var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); - using (var server = KestrelWebSocketHelpers.CreateServer(async context => + using (StartLog(out var loggerFactory)) { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - })) - { - using (var client = new ClientWebSocket()) + var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - var clientBuffer = new byte[orriginalData.Length]; - WebSocketReceiveResult result; - int receivedCount = 0; - do - { - result = await client.ReceiveAsync(new ArraySegment(clientBuffer, receivedCount, clientBuffer.Length - receivedCount), CancellationToken.None); - receivedCount += result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - } - while (!result.EndOfMessage); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - Assert.Equal(orriginalData.Length, receivedCount); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - Assert.Equal(orriginalData, clientBuffer); + await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var clientBuffer = new byte[orriginalData.Length]; + WebSocketReceiveResult result; + int receivedCount = 0; + do + { + result = await client.ReceiveAsync(new ArraySegment(clientBuffer, receivedCount, clientBuffer.Length - receivedCount), CancellationToken.None); + receivedCount += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + } + while (!result.EndOfMessage); + + Assert.Equal(orriginalData.Length, receivedCount); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, clientBuffer); + } } } } @@ -310,42 +346,45 @@ namespace Microsoft.AspNetCore.WebSockets.Test [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task ReceiveFragmentedData_Success() { - var orriginalData = Encoding.UTF8.GetBytes("Hello World"); - using (var server = KestrelWebSocketHelpers.CreateServer(async context => + using (StartLog(out var loggerFactory)) { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - await webSocket.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); - await webSocket.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); - await webSocket.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); - })) - { - using (var client = new ClientWebSocket()) + var orriginalData = Encoding.UTF8.GetBytes("Hello World"); + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - var clientBuffer = new byte[orriginalData.Length]; - var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); - Assert.False(result.EndOfMessage); - Assert.Equal(2, result.Count); - int totalReceived = result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - result = await client.ReceiveAsync( - new ArraySegment(clientBuffer, totalReceived, clientBuffer.Length - totalReceived), CancellationToken.None); - Assert.False(result.EndOfMessage); - Assert.Equal(2, result.Count); - totalReceived += result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + await webSocket.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); + await webSocket.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); + await webSocket.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var clientBuffer = new byte[orriginalData.Length]; + var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.False(result.EndOfMessage); + Assert.Equal(2, result.Count); + int totalReceived = result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - result = await client.ReceiveAsync( - new ArraySegment(clientBuffer, totalReceived, clientBuffer.Length - totalReceived), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(7, result.Count); - totalReceived += result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + result = await client.ReceiveAsync( + new ArraySegment(clientBuffer, totalReceived, clientBuffer.Length - totalReceived), CancellationToken.None); + Assert.False(result.EndOfMessage); + Assert.Equal(2, result.Count); + totalReceived += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - Assert.Equal(orriginalData, clientBuffer); + result = await client.ReceiveAsync( + new ArraySegment(clientBuffer, totalReceived, clientBuffer.Length - totalReceived), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(7, result.Count); + totalReceived += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + Assert.Equal(orriginalData, clientBuffer); + } } } } @@ -354,27 +393,30 @@ namespace Microsoft.AspNetCore.WebSockets.Test [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task SendClose_Success() { - string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(async context => + using (StartLog(out var loggerFactory)) { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - var serverBuffer = new byte[1024]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Close, result.MessageType); - Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); - Assert.Equal(closeDescription, result.CloseStatusDescription); - })) - { - using (var client = new ClientWebSocket()) + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - await client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - Assert.Equal(WebSocketState.CloseSent, client.State); + var serverBuffer = new byte[1024]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + + Assert.Equal(WebSocketState.CloseSent, client.State); + } } } } @@ -383,27 +425,30 @@ namespace Microsoft.AspNetCore.WebSockets.Test [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task ReceiveClose_Success() { - string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(async context => + using (StartLog(out var loggerFactory)) { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - })) - { - using (var client = new ClientWebSocket()) + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - var clientBuffer = new byte[1024]; - var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Close, result.MessageType); - Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); - Assert.Equal(closeDescription, result.CloseStatusDescription); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - Assert.Equal(WebSocketState.CloseReceived, client.State); + await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var clientBuffer = new byte[1024]; + var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + + Assert.Equal(WebSocketState.CloseReceived, client.State); + } } } } @@ -412,29 +457,32 @@ namespace Microsoft.AspNetCore.WebSockets.Test [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task CloseFromOpen_Success() { - string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(async context => + using (StartLog(out var loggerFactory)) { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - var serverBuffer = new byte[1024]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Close, result.MessageType); - Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); - Assert.Equal(closeDescription, result.CloseStatusDescription); - - await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); - })) - { - using (var client = new ClientWebSocket()) + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - await client.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - Assert.Equal(WebSocketState.Closed, client.State); + var serverBuffer = new byte[1024]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + + await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + + Assert.Equal(WebSocketState.Closed, client.State); + } } } } @@ -443,31 +491,34 @@ namespace Microsoft.AspNetCore.WebSockets.Test [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task CloseFromCloseSent_Success() { - string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(async context => + using (StartLog(out var loggerFactory)) { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - var serverBuffer = new byte[1024]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Close, result.MessageType); - Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); - Assert.Equal(closeDescription, result.CloseStatusDescription); - - await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); - })) - { - using (var client = new ClientWebSocket()) + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - await client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - Assert.Equal(WebSocketState.CloseSent, client.State); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - await client.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - Assert.Equal(WebSocketState.Closed, client.State); + var serverBuffer = new byte[1024]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + + await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + Assert.Equal(WebSocketState.CloseSent, client.State); + + await client.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + Assert.Equal(WebSocketState.Closed, client.State); + } } } } @@ -476,39 +527,42 @@ namespace Microsoft.AspNetCore.WebSockets.Test [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task CloseFromCloseReceived_Success() { - string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(async context => + using (StartLog(out var loggerFactory)) { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - - var serverBuffer = new byte[1024]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Close, result.MessageType); - Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); - Assert.Equal(closeDescription, result.CloseStatusDescription); - })) - { - using (var client = new ClientWebSocket()) + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - var clientBuffer = new byte[1024]; - var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + + var serverBuffer = new byte[1024]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); Assert.True(result.EndOfMessage); Assert.Equal(0, result.Count); Assert.Equal(WebSocketMessageType.Close, result.MessageType); Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); Assert.Equal(closeDescription, result.CloseStatusDescription); + })) + { + using (var client = new ClientWebSocket()) + { + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var clientBuffer = new byte[1024]; + var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); - Assert.Equal(WebSocketState.CloseReceived, client.State); + Assert.Equal(WebSocketState.CloseReceived, client.State); - await client.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + await client.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); - Assert.Equal(WebSocketState.Closed, client.State); + Assert.Equal(WebSocketState.Closed, client.State); + } } } } From f173f3f08f45da0f353656cf0dc585fec65d5353 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 31 Jan 2018 15:01:14 -0800 Subject: [PATCH 362/453] Update dependencies.props to 2.1.0-preview-28193, build tools to 2.1.0-preview1-1010 [ci skip] Scripted changes: - updated travis and appveyor.yml files to only build dev, ci, and release branches - updated dependencies.props - updated korebuild-lock.txt - updated korebuild.json to release/2.1 channel --- .appveyor.yml | 15 +++++++-------- .travis.yml | 27 +++++++++++++-------------- build/dependencies.props | 30 +++++++++++++++--------------- korebuild-lock.txt | 4 ++-- korebuild.json | 4 ++-- 5 files changed, 39 insertions(+), 41 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 7ca6d1770f..212f42583e 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,5 +1,5 @@ init: - - git config --global core.autocrlf true +- git config --global core.autocrlf true environment: AUTOBAHN_SUITES_LOG: 1 global: @@ -7,13 +7,12 @@ environment: DOTNET_CLI_TELEMETRY_OPTOUT: 1 branches: only: - - master - - /release\/.*/ - - dev - - /^(.*\/)?ci-.*$/ + - dev + - /^release\/.*$/ + - /^(.*\/)?ci-.*$/ build_script: - - ps: .\run.ps1 default-build +- ps: .\run.ps1 default-build clone_depth: 1 -test: off -deploy: off +test: 'off' +deploy: 'off' os: Visual Studio 2017 diff --git a/.travis.yml b/.travis.yml index 1a8a676d38..81bf8af485 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,28 +3,27 @@ sudo: false dist: trusty env: global: - - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - - AUTOBAHN_SUITES_LOG: 1 - - ASPNETCORE_WSTEST_PATH: "$TRAVIS_BUILD_DIR/.virtualenv/bin/wstest" + - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + - DOTNET_CLI_TELEMETRY_OPTOUT: 1 + - AUTOBAHN_SUITES_LOG: 1 + - ASPNETCORE_WSTEST_PATH: $TRAVIS_BUILD_DIR/.virtualenv/bin/wstest mono: none python: - - pypy +- pypy os: - - linux - - osx +- linux +- osx osx_image: xcode8.2 addons: apt: packages: - - libunwind8 + - libunwind8 branches: only: - - master - - /release\/.*/ - - dev - - /^(.*\/)?ci-.*$/ + - dev + - /^release\/.*$/ + - /^(.*\/)?ci-.*$/ install: - - ./build/setup-wstest.sh +- ./build/setup-wstest.sh script: - - ./build.sh +- ./build.sh diff --git a/build/dependencies.props b/build/dependencies.props index 2de3e02327..c437c86eb8 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,21 +3,21 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15679 - 2.1.0-preview1-28172 - 2.1.0-preview1-28172 - 2.1.0-preview1-28172 - 2.1.0-preview1-28172 - 2.1.0-preview1-28172 - 0.5.0-preview1-28172 - 2.1.0-preview1-28172 - 2.1.0-preview1-28172 - 2.1.0-preview1-28172 - 2.1.0-preview1-28172 - 2.1.0-preview1-28172 - 2.1.0-preview1-28172 - 2.1.0-preview1-28172 - 2.1.0-preview1-28172 + 2.1.0-preview1-1010 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 0.5.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 2.0.0 2.1.0-preview1-26122-01 15.3.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index a474bc0e35..851bfbf203 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15679 -commithash:5347461137cb45a77ddcc0b55b2478092de43338 +version:2.1.0-preview1-1010 +commithash:75ca924dfbd673c38841025b04c4dcd93b84f56d diff --git a/korebuild.json b/korebuild.json index bd5d51a51b..678d8bb948 100644 --- a/korebuild.json +++ b/korebuild.json @@ -1,4 +1,4 @@ { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev" + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json", + "channel": "release/2.1" } From c7c4bd6ebc3b0a3c523d60f63b122c1eb994bad7 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 1 Feb 2018 04:51:45 +0000 Subject: [PATCH 363/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 36 ++++++++++++++++++------------------ korebuild-lock.txt | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 831c3b89e8..1c52133acf 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,26 +3,26 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15684 - 2.1.0-preview2-28183 - 2.1.0-preview2-28183 - 2.1.0-preview2-28183 - 2.1.0-preview2-28183 - 2.1.0-preview2-28183 - 0.5.0-preview2-28183 - 2.1.0-preview2-28183 - 2.1.0-preview2-28183 - 2.1.0-preview2-28183 - 2.1.0-preview2-28183 - 2.1.0-preview2-28183 - 2.1.0-preview2-28183 - 2.1.0-preview2-28183 - 2.1.0-preview2-28183 - 2.1.0-preview2-28183 + 2.1.0-preview2-15692 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 0.5.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 2.0.0 - 2.1.0-preview1-26122-01 + 2.1.0-preview2-26130-04 15.3.0 - 4.5.0-preview1-26119-06 + 4.5.0-preview2-26130-01 2.3.1 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 1ae5d69845..232cb858c2 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15684 -commithash:308af8e3279892aad7f189ffbddd3ff9a60970d3 +version:2.1.0-preview2-15692 +commithash:5d9f445ce3f8492451a6f461df7e739bbed6a7f8 From 1df5a51d8da430b476513884b0fecdb72a1fad15 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sat, 3 Feb 2018 03:08:50 +0000 Subject: [PATCH 364/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 32 ++++++++++++++++---------------- korebuild-lock.txt | 4 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 1c52133acf..c282295a81 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,22 +3,22 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15692 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 0.5.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 + 2.1.0-preview2-15694 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 0.5.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 2.0.0 2.1.0-preview2-26130-04 15.3.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 232cb858c2..6f294ef0e6 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15692 -commithash:5d9f445ce3f8492451a6f461df7e739bbed6a7f8 +version:2.1.0-preview2-15694 +commithash:f61af02b48e89592c9aadb7ebaebe84228666c3b From b369d335dd1fe39eaf3292d5f10eaa363aae2697 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Fri, 9 Feb 2018 12:06:10 -0800 Subject: [PATCH 365/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 32 ++++++++++++++++---------------- korebuild-lock.txt | 4 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index c282295a81..cd73d4564b 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,22 +3,22 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15694 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 0.5.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 + 2.1.0-preview2-15698 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 0.5.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 2.0.0 2.1.0-preview2-26130-04 15.3.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 6f294ef0e6..3e2b56b91b 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15694 -commithash:f61af02b48e89592c9aadb7ebaebe84228666c3b +version:2.1.0-preview2-15698 +commithash:7216e5068cb1957e09d45fcbe58a744dd5c2de73 From 40fb71f6ddbbcff0d902736b6dfe8eaf44e81e24 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 11 Feb 2018 12:46:42 -0800 Subject: [PATCH 366/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index cd73d4564b..7018c53971 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,27 +4,27 @@ 2.1.0-preview2-15698 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 0.5.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 0.5.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 2.0.0 2.1.0-preview2-26130-04 15.3.0 4.5.0-preview2-26130-01 2.3.1 - 2.3.1 + 2.4.0-beta.1.build3945 From f89427ec98428421f79d5fed4cd4264ff968f56c Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 18 Feb 2018 12:36:07 -0800 Subject: [PATCH 367/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 32 ++++++++++++++++---------------- korebuild-lock.txt | 4 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 7018c53971..93c5e36dc4 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,22 +3,22 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15698 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 0.5.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 + 2.1.0-preview2-15707 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 0.5.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 2.0.0 2.1.0-preview2-26130-04 15.3.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 3e2b56b91b..89d0ad3d15 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15698 -commithash:7216e5068cb1957e09d45fcbe58a744dd5c2de73 +version:2.1.0-preview2-15707 +commithash:e74e53f129ab34332947fea7ac7b7591b027cb22 From 3ca7c0365ad9355f5f67ddeb6a00b42e267d42b8 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Tue, 20 Feb 2018 08:58:01 -0800 Subject: [PATCH 368/453] Force conformance tests to run on the CI (#228) --- .appveyor.yml | 5 ++ build/setup-wstest.ps1 | 52 +++++++++++++++++++ .../Autobahn/Executable.cs | 2 +- .../Autobahn/Wstest.cs | 15 +++++- .../AutobahnTests.cs | 6 +++ .../SkipIfWsTestNotPresentAttribute.cs | 11 ++-- 6 files changed, 85 insertions(+), 6 deletions(-) create mode 100644 build/setup-wstest.ps1 diff --git a/.appveyor.yml b/.appveyor.yml index 7ca6d1770f..32d4013879 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -5,12 +5,17 @@ environment: global: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true DOTNET_CLI_TELEMETRY_OPTOUT: 1 + ASPNETCORE_WSTEST_PATH: "$(APPVEYOR_BUILD_FOLDER)/vendor/virtualenv/Scripts/wstest.exe" +cache: + - vendor\VCForPython27.msi branches: only: - master - /release\/.*/ - dev - /^(.*\/)?ci-.*$/ +install: + - ps: .\build\setup-wstest.ps1 build_script: - ps: .\run.ps1 default-build clone_depth: 1 diff --git a/build/setup-wstest.ps1 b/build/setup-wstest.ps1 new file mode 100644 index 0000000000..8571e77055 --- /dev/null +++ b/build/setup-wstest.ps1 @@ -0,0 +1,52 @@ +function has($cmd) { !!(Get-Command $cmd -ErrorAction SilentlyContinue) } + +# Download VCForPython27 if necessary +$VendorDir = Join-Path (Get-Location) "vendor" + +if(!(Test-Path $VendorDir)) { + mkdir $VendorDir +} + +$VirtualEnvDir = Join-Path $VendorDir "virtualenv"; +$ScriptsDir = Join-Path $VirtualEnvDir "Scripts" +$WsTest = Join-Path $ScriptsDir "wstest.exe" + +$VCPythonMsi = Join-Path $VendorDir "VCForPython27.msi" +if(!(Test-Path $VCPythonMsi)) { + Write-Host "Downloading VCForPython27.msi" + Invoke-WebRequest -Uri https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-B59FBF6D907B/VCForPython27.msi -OutFile "$VCPythonMsi" +} +else { + Write-Host "Using VCForPython27.msi from Cache" +} + +# Install VCForPython27 +Write-Host "Installing VCForPython27" + +# Launch this way to ensure we wait for msiexec to complete. It's a Windows app so it won't block the console by default. +Start-Process msiexec "/i","$VCPythonMsi","/qn","/quiet","/norestart" -Wait + +Write-Host "Installed VCForPython27" + +# Install Python +if(!(has python)) { + choco install python2 +} + +if(!(has python)) { + throw "Failed to install python2" +} + +# Install virtualenv +pip install virtualenv + +# Make a virtualenv in .virtualenv +virtualenv $VirtualEnvDir + +& "$ScriptsDir\python" --version +& "$ScriptsDir\pip" --version + +# Install autobahn into the virtualenv +& "$ScriptsDir\pip" install autobahntestsuite + +Write-Host "Using wstest from: '$WsTest'" \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs index 097b600d5a..cdd753bf3e 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs index a60a91e7c7..775b00d4ab 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs @@ -1,4 +1,5 @@ -using System; +using System; +using System.IO; namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { @@ -9,18 +10,28 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { private static Lazy _instance = new Lazy(Create); + public static readonly string DefaultLocation = LocateWstest(); + public static Wstest Default => _instance.Value; public Wstest(string path) : base(path) { } private static Wstest Create() + { + var location = LocateWstest(); + + return (location == null || !File.Exists(location)) ? null : new Wstest(location); + } + + private static string LocateWstest() { var location = Environment.GetEnvironmentVariable("ASPNETCORE_WSTEST_PATH"); if (string.IsNullOrEmpty(location)) { location = Locate("wstest"); } - return location == null ? null : new Wstest(location); + + return location; } } } diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs index 6ef652be4f..897bf3f1e6 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs @@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Testing.xunit; using Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Testing; +using Xunit; using Xunit.Abstractions; namespace Microsoft.AspNetCore.WebSockets.ConformanceTest @@ -27,6 +28,11 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest [SkipIfWsTestNotPresent] public async Task AutobahnTestSuite() { + // If we're on CI, we want to actually fail if WsTest isn't installed, rather than just skipping the test + // The SkipIfWsTestNotPresent attribute ensures that this test isn't skipped on CI, so we just need to check that Wstest is present + // And we use Assert.True to provide an error message + Assert.True(Wstest.Default != null, $"The 'wstest' executable (Autobahn WebSockets Test Suite) could not be found at '{Wstest.DefaultLocation}'. Run the Build Agent setup scripts to install it or see https://github.com/crossbario/autobahn-testsuite for instructions on manual installation."); + using (StartLog(out var loggerFactory)) { var logger = loggerFactory.CreateLogger(); diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs index ea6b1cc824..be2d7729a2 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs @@ -1,4 +1,4 @@ -using System; +using System; using Microsoft.AspNetCore.Testing.xunit; using Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn; @@ -7,7 +7,12 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public class SkipIfWsTestNotPresentAttribute : Attribute, ITestCondition { - public bool IsMet => Wstest.Default != null; + public bool IsMet => IsOnCi || Wstest.Default != null; public string SkipReason => "Autobahn Test Suite is not installed on the host machine."; + + private static bool IsOnCi => + !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("TEAMCITY_VERSION")) || + string.Equals(Environment.GetEnvironmentVariable("TRAVIS"), "true", StringComparison.OrdinalIgnoreCase) || + string.Equals(Environment.GetEnvironmentVariable("APPVEYOR"), "true", StringComparison.OrdinalIgnoreCase); } -} \ No newline at end of file +} From 57622cab6b1be13771d9f44b5dab436f4fae3d31 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Tue, 20 Feb 2018 16:51:22 -0800 Subject: [PATCH 369/453] Revert "Force conformance tests to run on the CI (#228)" This reverts commit 3ca7c0365ad9355f5f67ddeb6a00b42e267d42b8. --- .appveyor.yml | 5 -- build/setup-wstest.ps1 | 52 ------------------- .../Autobahn/Executable.cs | 2 +- .../Autobahn/Wstest.cs | 15 +----- .../AutobahnTests.cs | 6 --- .../SkipIfWsTestNotPresentAttribute.cs | 11 ++-- 6 files changed, 6 insertions(+), 85 deletions(-) delete mode 100644 build/setup-wstest.ps1 diff --git a/.appveyor.yml b/.appveyor.yml index 32d4013879..7ca6d1770f 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -5,17 +5,12 @@ environment: global: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true DOTNET_CLI_TELEMETRY_OPTOUT: 1 - ASPNETCORE_WSTEST_PATH: "$(APPVEYOR_BUILD_FOLDER)/vendor/virtualenv/Scripts/wstest.exe" -cache: - - vendor\VCForPython27.msi branches: only: - master - /release\/.*/ - dev - /^(.*\/)?ci-.*$/ -install: - - ps: .\build\setup-wstest.ps1 build_script: - ps: .\run.ps1 default-build clone_depth: 1 diff --git a/build/setup-wstest.ps1 b/build/setup-wstest.ps1 deleted file mode 100644 index 8571e77055..0000000000 --- a/build/setup-wstest.ps1 +++ /dev/null @@ -1,52 +0,0 @@ -function has($cmd) { !!(Get-Command $cmd -ErrorAction SilentlyContinue) } - -# Download VCForPython27 if necessary -$VendorDir = Join-Path (Get-Location) "vendor" - -if(!(Test-Path $VendorDir)) { - mkdir $VendorDir -} - -$VirtualEnvDir = Join-Path $VendorDir "virtualenv"; -$ScriptsDir = Join-Path $VirtualEnvDir "Scripts" -$WsTest = Join-Path $ScriptsDir "wstest.exe" - -$VCPythonMsi = Join-Path $VendorDir "VCForPython27.msi" -if(!(Test-Path $VCPythonMsi)) { - Write-Host "Downloading VCForPython27.msi" - Invoke-WebRequest -Uri https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-B59FBF6D907B/VCForPython27.msi -OutFile "$VCPythonMsi" -} -else { - Write-Host "Using VCForPython27.msi from Cache" -} - -# Install VCForPython27 -Write-Host "Installing VCForPython27" - -# Launch this way to ensure we wait for msiexec to complete. It's a Windows app so it won't block the console by default. -Start-Process msiexec "/i","$VCPythonMsi","/qn","/quiet","/norestart" -Wait - -Write-Host "Installed VCForPython27" - -# Install Python -if(!(has python)) { - choco install python2 -} - -if(!(has python)) { - throw "Failed to install python2" -} - -# Install virtualenv -pip install virtualenv - -# Make a virtualenv in .virtualenv -virtualenv $VirtualEnvDir - -& "$ScriptsDir\python" --version -& "$ScriptsDir\pip" --version - -# Install autobahn into the virtualenv -& "$ScriptsDir\pip" install autobahntestsuite - -Write-Host "Using wstest from: '$WsTest'" \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs index cdd753bf3e..097b600d5a 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs index 775b00d4ab..a60a91e7c7 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System; namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { @@ -10,28 +9,18 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { private static Lazy _instance = new Lazy(Create); - public static readonly string DefaultLocation = LocateWstest(); - public static Wstest Default => _instance.Value; public Wstest(string path) : base(path) { } private static Wstest Create() - { - var location = LocateWstest(); - - return (location == null || !File.Exists(location)) ? null : new Wstest(location); - } - - private static string LocateWstest() { var location = Environment.GetEnvironmentVariable("ASPNETCORE_WSTEST_PATH"); if (string.IsNullOrEmpty(location)) { location = Locate("wstest"); } - - return location; + return location == null ? null : new Wstest(location); } } } diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs index 897bf3f1e6..6ef652be4f 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs @@ -9,7 +9,6 @@ using Microsoft.AspNetCore.Testing.xunit; using Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Testing; -using Xunit; using Xunit.Abstractions; namespace Microsoft.AspNetCore.WebSockets.ConformanceTest @@ -28,11 +27,6 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest [SkipIfWsTestNotPresent] public async Task AutobahnTestSuite() { - // If we're on CI, we want to actually fail if WsTest isn't installed, rather than just skipping the test - // The SkipIfWsTestNotPresent attribute ensures that this test isn't skipped on CI, so we just need to check that Wstest is present - // And we use Assert.True to provide an error message - Assert.True(Wstest.Default != null, $"The 'wstest' executable (Autobahn WebSockets Test Suite) could not be found at '{Wstest.DefaultLocation}'. Run the Build Agent setup scripts to install it or see https://github.com/crossbario/autobahn-testsuite for instructions on manual installation."); - using (StartLog(out var loggerFactory)) { var logger = loggerFactory.CreateLogger(); diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs index be2d7729a2..ea6b1cc824 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs @@ -1,4 +1,4 @@ -using System; +using System; using Microsoft.AspNetCore.Testing.xunit; using Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn; @@ -7,12 +7,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public class SkipIfWsTestNotPresentAttribute : Attribute, ITestCondition { - public bool IsMet => IsOnCi || Wstest.Default != null; + public bool IsMet => Wstest.Default != null; public string SkipReason => "Autobahn Test Suite is not installed on the host machine."; - - private static bool IsOnCi => - !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("TEAMCITY_VERSION")) || - string.Equals(Environment.GetEnvironmentVariable("TRAVIS"), "true", StringComparison.OrdinalIgnoreCase) || - string.Equals(Environment.GetEnvironmentVariable("APPVEYOR"), "true", StringComparison.OrdinalIgnoreCase); } -} +} \ No newline at end of file From 7a764bf8426e2d9628795d9f2e40e271d5bd673d Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 21 Feb 2018 18:27:19 -0800 Subject: [PATCH 370/453] Use FeatureBranchVersionSuffix when generating VersionSuffix --- version.props | 1 + 1 file changed, 1 insertion(+) diff --git a/version.props b/version.props index 370d5ababd..65c8a07e37 100644 --- a/version.props +++ b/version.props @@ -5,6 +5,7 @@ $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 + $(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-')) $(VersionSuffix)-$(BuildNumber) From 9cefe7c5968290b25be5504a1dc3f7fec4fe450c Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Mon, 26 Feb 2018 11:20:07 -0800 Subject: [PATCH 371/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 34 +++++++++++++++++----------------- korebuild-lock.txt | 4 ++-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 93c5e36dc4..bfb2bc5979 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,25 +3,25 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15707 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 0.5.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 + 2.1.0-preview2-15721 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 0.5.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 2.0.0 2.1.0-preview2-26130-04 - 15.3.0 + 15.6.0 4.5.0-preview2-26130-01 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 89d0ad3d15..e6c7fddffa 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15707 -commithash:e74e53f129ab34332947fea7ac7b7591b027cb22 +version:2.1.0-preview2-15721 +commithash:f9bb4be59e39938ec59a6975257e26099b0d03c1 From 4a49d6dd7590c5dfcfa3aa32bef420769f4859c5 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Mon, 26 Feb 2018 11:39:18 -0800 Subject: [PATCH 372/453] Restore "Force conformance tests to run on the CI (#228)" (#229) This reverts commit 57622cab6b1be13771d9f44b5dab436f4fae3d31. --- .appveyor.yml | 5 ++ build/setup-wstest.ps1 | 52 +++++++++++++++++++ .../Autobahn/Executable.cs | 2 +- .../Autobahn/Wstest.cs | 15 +++++- .../AutobahnTests.cs | 6 +++ .../SkipIfWsTestNotPresentAttribute.cs | 11 ++-- 6 files changed, 85 insertions(+), 6 deletions(-) create mode 100644 build/setup-wstest.ps1 diff --git a/.appveyor.yml b/.appveyor.yml index 7ca6d1770f..32d4013879 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -5,12 +5,17 @@ environment: global: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true DOTNET_CLI_TELEMETRY_OPTOUT: 1 + ASPNETCORE_WSTEST_PATH: "$(APPVEYOR_BUILD_FOLDER)/vendor/virtualenv/Scripts/wstest.exe" +cache: + - vendor\VCForPython27.msi branches: only: - master - /release\/.*/ - dev - /^(.*\/)?ci-.*$/ +install: + - ps: .\build\setup-wstest.ps1 build_script: - ps: .\run.ps1 default-build clone_depth: 1 diff --git a/build/setup-wstest.ps1 b/build/setup-wstest.ps1 new file mode 100644 index 0000000000..8571e77055 --- /dev/null +++ b/build/setup-wstest.ps1 @@ -0,0 +1,52 @@ +function has($cmd) { !!(Get-Command $cmd -ErrorAction SilentlyContinue) } + +# Download VCForPython27 if necessary +$VendorDir = Join-Path (Get-Location) "vendor" + +if(!(Test-Path $VendorDir)) { + mkdir $VendorDir +} + +$VirtualEnvDir = Join-Path $VendorDir "virtualenv"; +$ScriptsDir = Join-Path $VirtualEnvDir "Scripts" +$WsTest = Join-Path $ScriptsDir "wstest.exe" + +$VCPythonMsi = Join-Path $VendorDir "VCForPython27.msi" +if(!(Test-Path $VCPythonMsi)) { + Write-Host "Downloading VCForPython27.msi" + Invoke-WebRequest -Uri https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-B59FBF6D907B/VCForPython27.msi -OutFile "$VCPythonMsi" +} +else { + Write-Host "Using VCForPython27.msi from Cache" +} + +# Install VCForPython27 +Write-Host "Installing VCForPython27" + +# Launch this way to ensure we wait for msiexec to complete. It's a Windows app so it won't block the console by default. +Start-Process msiexec "/i","$VCPythonMsi","/qn","/quiet","/norestart" -Wait + +Write-Host "Installed VCForPython27" + +# Install Python +if(!(has python)) { + choco install python2 +} + +if(!(has python)) { + throw "Failed to install python2" +} + +# Install virtualenv +pip install virtualenv + +# Make a virtualenv in .virtualenv +virtualenv $VirtualEnvDir + +& "$ScriptsDir\python" --version +& "$ScriptsDir\pip" --version + +# Install autobahn into the virtualenv +& "$ScriptsDir\pip" install autobahntestsuite + +Write-Host "Using wstest from: '$WsTest'" \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs index 097b600d5a..cdd753bf3e 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs index a60a91e7c7..775b00d4ab 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs @@ -1,4 +1,5 @@ -using System; +using System; +using System.IO; namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { @@ -9,18 +10,28 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { private static Lazy _instance = new Lazy(Create); + public static readonly string DefaultLocation = LocateWstest(); + public static Wstest Default => _instance.Value; public Wstest(string path) : base(path) { } private static Wstest Create() + { + var location = LocateWstest(); + + return (location == null || !File.Exists(location)) ? null : new Wstest(location); + } + + private static string LocateWstest() { var location = Environment.GetEnvironmentVariable("ASPNETCORE_WSTEST_PATH"); if (string.IsNullOrEmpty(location)) { location = Locate("wstest"); } - return location == null ? null : new Wstest(location); + + return location; } } } diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs index 6ef652be4f..897bf3f1e6 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs @@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Testing.xunit; using Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Testing; +using Xunit; using Xunit.Abstractions; namespace Microsoft.AspNetCore.WebSockets.ConformanceTest @@ -27,6 +28,11 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest [SkipIfWsTestNotPresent] public async Task AutobahnTestSuite() { + // If we're on CI, we want to actually fail if WsTest isn't installed, rather than just skipping the test + // The SkipIfWsTestNotPresent attribute ensures that this test isn't skipped on CI, so we just need to check that Wstest is present + // And we use Assert.True to provide an error message + Assert.True(Wstest.Default != null, $"The 'wstest' executable (Autobahn WebSockets Test Suite) could not be found at '{Wstest.DefaultLocation}'. Run the Build Agent setup scripts to install it or see https://github.com/crossbario/autobahn-testsuite for instructions on manual installation."); + using (StartLog(out var loggerFactory)) { var logger = loggerFactory.CreateLogger(); diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs index ea6b1cc824..be2d7729a2 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs @@ -1,4 +1,4 @@ -using System; +using System; using Microsoft.AspNetCore.Testing.xunit; using Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn; @@ -7,7 +7,12 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public class SkipIfWsTestNotPresentAttribute : Attribute, ITestCondition { - public bool IsMet => Wstest.Default != null; + public bool IsMet => IsOnCi || Wstest.Default != null; public string SkipReason => "Autobahn Test Suite is not installed on the host machine."; + + private static bool IsOnCi => + !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("TEAMCITY_VERSION")) || + string.Equals(Environment.GetEnvironmentVariable("TRAVIS"), "true", StringComparison.OrdinalIgnoreCase) || + string.Equals(Environment.GetEnvironmentVariable("APPVEYOR"), "true", StringComparison.OrdinalIgnoreCase); } -} \ No newline at end of file +} From 9307746a20a20c0adad9f39431ccda67ec1af183 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 6 Mar 2018 10:06:47 -0800 Subject: [PATCH 373/453] Use dotnet-core feed in repos --- build/sources.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/sources.props b/build/sources.props index 9feff29d09..9215df9751 100644 --- a/build/sources.props +++ b/build/sources.props @@ -1,10 +1,11 @@ - + $(DotNetRestoreSources) $(RestoreSources); + https://dotnet.myget.org/F/dotnet-core/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; From d350e4508cf6a8f45c3d647867b837ecf3e3c8f2 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 6 Mar 2018 10:06:48 -0800 Subject: [PATCH 374/453] Prepend FeatureBranchVersionPrefix if FeatureBranchVersionSuffix is specified --- version.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/version.props b/version.props index 65c8a07e37..a11ea1ed52 100644 --- a/version.props +++ b/version.props @@ -5,7 +5,8 @@ $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 - $(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-')) + a- + $(FeatureBranchVersionPrefix)$(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-')) $(VersionSuffix)-$(BuildNumber) From e879cf7a57b87758670f861484e172cd98caa80c Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 8 Mar 2018 13:18:35 -0800 Subject: [PATCH 375/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 36 ++++++++++++++++++------------------ korebuild-lock.txt | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index bfb2bc5979..0ff09ada17 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,26 +3,26 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15721 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 0.5.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 + 2.1.0-preview2-15728 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 0.5.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 2.0.0 - 2.1.0-preview2-26130-04 + 2.1.0-preview2-26225-03 15.6.0 - 4.5.0-preview2-26130-01 + 4.5.0-preview2-26224-02 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index e6c7fddffa..138d848db1 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15721 -commithash:f9bb4be59e39938ec59a6975257e26099b0d03c1 +version:2.1.0-preview2-15728 +commithash:393377068ddcf51dfee0536536d455f57a828b06 From 6de76c5e69bd74b8d5742642e1e90a2a39874323 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Wed, 14 Mar 2018 08:48:45 -0700 Subject: [PATCH 376/453] Respect the buffer size arguments on options (#230) * Respect the buffer size arguments on options - Allocate a buffer for receives and pass into CreateFromStream. --- build/dependencies.props | 36 +++++++++---------- korebuild-lock.txt | 4 +-- .../WebSocketMiddleware.cs | 5 ++- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 0ff09ada17..26152a24c1 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,26 +3,26 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15728 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 0.5.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 + 2.1.0-preview2-15739 + 2.1.0-preview2-30319 + 2.1.0-preview2-30319 + 2.1.0-preview2-30319 + 2.1.0-preview2-30319 + 2.1.0-preview2-30319 + 0.5.0-preview2-30319 + 2.1.0-preview2-30319 + 2.1.0-preview2-30319 + 2.1.0-preview2-30319 + 2.1.0-preview2-30319 + 2.1.0-preview2-30319 + 2.1.0-preview2-30319 + 2.1.0-preview2-30319 + 2.1.0-preview2-30319 + 2.1.0-preview2-30319 2.0.0 - 2.1.0-preview2-26225-03 + 2.1.0-preview2-26308-01 15.6.0 - 4.5.0-preview2-26224-02 + 4.5.0-preview2-26308-02 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 138d848db1..2c06ab4184 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15728 -commithash:393377068ddcf51dfee0536536d455f57a828b06 +version:2.1.0-preview2-15739 +commithash:d8c238a4ac822c643d707d9cf44d2dbc93c59a68 diff --git a/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs b/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs index eba9597cd5..a583bccd2b 100644 --- a/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs +++ b/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs @@ -119,7 +119,10 @@ namespace Microsoft.AspNetCore.WebSockets Stream opaqueTransport = await _upgradeFeature.UpgradeAsync(); // Sets status code to 101 - return WebSocketProtocol.CreateFromStream(opaqueTransport, isServer: true, subProtocol: subProtocol, keepAliveInterval: keepAliveInterval); + // Allocate a buffer for receive (default is 4k) + var buffer = new byte[receiveBufferSize]; + + return WebSocketProtocol.CreateFromStream(opaqueTransport, isServer: true, subProtocol: subProtocol, keepAliveInterval: keepAliveInterval, buffer: buffer); } } } From 4cf0b5d033e445153f8ed6bf40bcd8e7b959fd2d Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Wed, 14 Mar 2018 15:35:35 -0700 Subject: [PATCH 377/453] Set 2.0 baselines --- .../baseline.netcore.json | 231 ++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 src/Microsoft.AspNetCore.WebSockets/baseline.netcore.json diff --git a/src/Microsoft.AspNetCore.WebSockets/baseline.netcore.json b/src/Microsoft.AspNetCore.WebSockets/baseline.netcore.json new file mode 100644 index 0000000000..6bddb5de96 --- /dev/null +++ b/src/Microsoft.AspNetCore.WebSockets/baseline.netcore.json @@ -0,0 +1,231 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.WebSockets, Version=2.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Builder.WebSocketMiddlewareExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseWebSockets", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseWebSockets", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.WebSocketOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.WebSocketOptions", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_KeepAliveInterval", + "Parameters": [], + "ReturnType": "System.TimeSpan", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_KeepAliveInterval", + "Parameters": [ + { + "Name": "value", + "Type": "System.TimeSpan" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ReceiveBufferSize", + "Parameters": [], + "ReturnType": "System.Int32", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ReceiveBufferSize", + "Parameters": [ + { + "Name": "value", + "Type": "System.Int32" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.WebSockets.ExtendedWebSocketAcceptContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Http.WebSocketAcceptContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_SubProtocol", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SubProtocol", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ReceiveBufferSize", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ReceiveBufferSize", + "Parameters": [ + { + "Name": "value", + "Type": "System.Nullable" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_KeepAliveInterval", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_KeepAliveInterval", + "Parameters": [ + { + "Name": "value", + "Type": "System.Nullable" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.WebSockets.WebSocketMiddleware", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Invoke", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ] +} \ No newline at end of file From 6514b883783c248a9e954a3bf467be430bf53d0b Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 16 Mar 2018 11:17:50 -0700 Subject: [PATCH 378/453] Branching for 2.1.0-preview2 --- build/dependencies.props | 36 ++++++++++++++++++------------------ build/repo.props | 4 ++-- build/sources.props | 2 +- korebuild-lock.txt | 4 ++-- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 26152a24c1..791b1cbeeb 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,26 +3,26 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15739 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 - 0.5.0-preview2-30319 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 + 2.1.0-preview2-15742 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 0.5.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 2.0.0 - 2.1.0-preview2-26308-01 + 2.1.0-preview2-26314-02 15.6.0 - 4.5.0-preview2-26308-02 + 4.5.0-preview2-26313-01 2.3.1 2.4.0-beta.1.build3945 diff --git a/build/repo.props b/build/repo.props index a7ce27ecb1..cc5826a085 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,4 +1,4 @@ - + @@ -7,7 +7,7 @@ Internal.AspNetCore.Universe.Lineup - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json + https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json diff --git a/build/sources.props b/build/sources.props index 9215df9751..36045f12b5 100644 --- a/build/sources.props +++ b/build/sources.props @@ -6,7 +6,7 @@ $(RestoreSources); https://dotnet.myget.org/F/dotnet-core/api/v3/index.json; - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; + https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 2c06ab4184..e761020952 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15739 -commithash:d8c238a4ac822c643d707d9cf44d2dbc93c59a68 +version:2.1.0-preview2-15742 +commithash:21fbb0f2c3fe4a9216e2d59632b98cfd7d685962 From 95fd58968e719d193bde26501086fb2611f32516 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 16 Mar 2018 11:28:55 -0700 Subject: [PATCH 379/453] Update version prefix to preview3 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index a11ea1ed52..24f2b00a0a 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.1.0 - preview2 + preview3 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 8916330692b0b24d197dcf691df6b43c44e7a59c Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 16 Mar 2018 12:35:08 -0700 Subject: [PATCH 380/453] Update KoreBuild channel --- korebuild.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/korebuild.json b/korebuild.json index bd5d51a51b..678d8bb948 100644 --- a/korebuild.json +++ b/korebuild.json @@ -1,4 +1,4 @@ { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev" + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json", + "channel": "release/2.1" } From a81320f69926d5ddd98a05f55ccb2995b579f4ef Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 25 Mar 2018 15:59:49 -0700 Subject: [PATCH 381/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 38 +++++++++++++++++++------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 26152a24c1..4e52e83a95 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,26 +3,26 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15739 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 - 0.5.0-preview2-30319 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 - 2.1.0-preview2-30319 + 2.1.0-preview3-17001 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 0.5.0-preview2-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 2.0.0 - 2.1.0-preview2-26308-01 - 15.6.0 - 4.5.0-preview2-26308-02 + 2.1.0-preview2-26314-02 + 15.6.1 + 4.5.0-preview2-26313-01 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 2c06ab4184..50ba1b5737 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15739 -commithash:d8c238a4ac822c643d707d9cf44d2dbc93c59a68 +version:2.1.0-preview3-17001 +commithash:dda68c56abf0d3b911fe6a2315872c446b314585 From a8f9832ca543ea07f594bff28555607a9186c78c Mon Sep 17 00:00:00 2001 From: "Nate McMaster (automated)" Date: Wed, 28 Mar 2018 11:09:44 -0700 Subject: [PATCH 382/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 38 +++++++++++++++++++------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 791b1cbeeb..1d2deea50a 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,26 +3,26 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15742 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 0.5.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 + 2.1.0-preview2-15749 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 0.5.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 2.0.0 - 2.1.0-preview2-26314-02 - 15.6.0 - 4.5.0-preview2-26313-01 + 2.1.0-preview2-26326-03 + 15.6.1 + 4.5.0-preview2-26326-04 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index e761020952..76d2c851ca 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15742 -commithash:21fbb0f2c3fe4a9216e2d59632b98cfd7d685962 +version:2.1.0-preview2-15749 +commithash:5544c9ab20fa5e24b9e155d8958a3c3b6f5f9df9 From 9eb41ca5710c18b31144daf74bc070372c7bd299 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Fri, 30 Mar 2018 10:47:12 -0700 Subject: [PATCH 383/453] Remove buffer size argument (#232) - We're removing the buffer arugment from the API as a result of a mini review. This is a pre-emptive reaction to avoid breakage when the change comes in. --- src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs b/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs index a583bccd2b..eba9597cd5 100644 --- a/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs +++ b/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs @@ -119,10 +119,7 @@ namespace Microsoft.AspNetCore.WebSockets Stream opaqueTransport = await _upgradeFeature.UpgradeAsync(); // Sets status code to 101 - // Allocate a buffer for receive (default is 4k) - var buffer = new byte[receiveBufferSize]; - - return WebSocketProtocol.CreateFromStream(opaqueTransport, isServer: true, subProtocol: subProtocol, keepAliveInterval: keepAliveInterval, buffer: buffer); + return WebSocketProtocol.CreateFromStream(opaqueTransport, isServer: true, subProtocol: subProtocol, keepAliveInterval: keepAliveInterval); } } } From ba87a293f9dd4121a063cecb61aec39e57a0c0e4 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Mon, 2 Apr 2018 09:46:21 -0700 Subject: [PATCH 384/453] Remove obsolete workaround --- .../Program.cs | 20 ------------------- 1 file changed, 20 deletions(-) delete mode 100644 test/Microsoft.AspNetCore.WebSockets.Test/Program.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Program.cs b/test/Microsoft.AspNetCore.WebSockets.Test/Program.cs deleted file mode 100644 index 7f9f5d0035..0000000000 --- a/test/Microsoft.AspNetCore.WebSockets.Test/Program.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -#if NET461 -using System; - -namespace Microsoft.AspNetCore.WebSockets.Test -{ - public class Program - { - public static void Main(string[] args) - { - Console.WriteLine("This Program.Main is only here to work around https://github.com/dotnet/sdk/issues/909"); - } - } -} -#elif NETCOREAPP2_0 || NETCOREAPP2_1 -#else -#error Target frameworks need to be updated -#endif From 0ed396db0b310e9d05fb36caf69b44b33b9df366 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Mon, 2 Apr 2018 09:46:49 -0700 Subject: [PATCH 385/453] Enable tests on 2.1 for Win7 --- .../WebSocketMiddlewareTests.cs | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs index 0f60b1d90d..3e8b512e8d 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs @@ -13,6 +13,14 @@ using Xunit.Abstractions; namespace Microsoft.AspNetCore.WebSockets.Test { +#if NET461 || NETCOREAPP2_0 + // ClientWebSocket does not support WebSockets on these platforms and OS. Kestrel does support it. + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] +#elif NETCOREAPP2_1 + // ClientWebSocket has added support for WebSockets on Win7. +#else + Unknown TFM +#endif public class WebSocketMiddlewareTests : LoggedTest { private static string ClientAddress = "ws://localhost:54321/"; @@ -22,7 +30,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task Connect_Success() { using (StartLog(out var loggerFactory)) @@ -42,7 +49,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task NegotiateSubProtocol_Success() { using (StartLog(out var loggerFactory)) @@ -74,7 +80,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task SendEmptyData_Success() { using (StartLog(out var loggerFactory)) @@ -102,7 +107,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task SendShortData_Success() { using (StartLog(out var loggerFactory)) @@ -131,7 +135,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task SendMediumData_Success() { using (StartLog(out var loggerFactory)) @@ -160,7 +163,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task SendLongData_Success() { using (StartLog(out var loggerFactory)) @@ -201,7 +203,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task SendFragmentedData_Success() { using (StartLog(out var loggerFactory)) @@ -248,7 +249,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task ReceiveShortData_Success() { using (StartLog(out var loggerFactory)) @@ -277,7 +277,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task ReceiveMediumData_Success() { using (StartLog(out var loggerFactory)) @@ -306,7 +305,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task ReceiveLongData() { using (StartLog(out var loggerFactory)) @@ -343,7 +341,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task ReceiveFragmentedData_Success() { using (StartLog(out var loggerFactory)) @@ -390,7 +387,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task SendClose_Success() { using (StartLog(out var loggerFactory)) @@ -422,7 +418,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task ReceiveClose_Success() { using (StartLog(out var loggerFactory)) @@ -454,7 +449,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task CloseFromOpen_Success() { using (StartLog(out var loggerFactory)) @@ -488,7 +482,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task CloseFromCloseSent_Success() { using (StartLog(out var loggerFactory)) @@ -524,7 +517,6 @@ namespace Microsoft.AspNetCore.WebSockets.Test } [ConditionalFact] - [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] public async Task CloseFromCloseReceived_Success() { using (StartLog(out var loggerFactory)) From 852a5b31be321f3fe5f948c943ea741f3259f8a5 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Mon, 2 Apr 2018 09:46:49 -0700 Subject: [PATCH 386/453] Fix bad rebase --- .../WebSocketMiddlewareTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs index 3e8b512e8d..e966aea6b4 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs @@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test #elif NETCOREAPP2_1 // ClientWebSocket has added support for WebSockets on Win7. #else - Unknown TFM +#error Unknown TFM #endif public class WebSocketMiddlewareTests : LoggedTest { From 9930499ee10fb5ad739c36ad313965d2254da032 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Mon, 2 Apr 2018 14:56:41 -0700 Subject: [PATCH 387/453] Work around HttpClient TLS regression --- .../Autobahn/AutobahnTester.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index bc629e759b..1b253e1627 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Net.Http; +using System.Security.Authentication; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -160,6 +161,8 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn cancellationToken.ThrowIfCancellationRequested(); var handler = new HttpClientHandler(); + // Win7 HttpClient on NetCoreApp2.1 defaults to TLS 1.0 and won't connect to Kestrel. https://github.com/dotnet/corefx/issues/28733 + handler.SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11; if (ssl) { // Don't take this out of the "if(ssl)". If we set it on some platforms, it crashes From c222a398dbaea64012573abdcf6374813aa880da Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Tue, 3 Apr 2018 09:17:52 -0700 Subject: [PATCH 388/453] Fix TLS versions for Mac --- .../Autobahn/AutobahnTester.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index 1b253e1627..4c08a43c32 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -162,7 +162,9 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn var handler = new HttpClientHandler(); // Win7 HttpClient on NetCoreApp2.1 defaults to TLS 1.0 and won't connect to Kestrel. https://github.com/dotnet/corefx/issues/28733 - handler.SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11; + // Mac HttpClient on NetCoreApp2.0 doesn't alow you to set some combinations. + // https://github.com/dotnet/corefx/blob/586cffcdfdf23ad6c193a4bf37fce88a1bf69508/src/System.Net.Http/src/System/Net/Http/CurlHandler/CurlHandler.SslProvider.OSX.cs#L104-L106 + handler.SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; if (ssl) { // Don't take this out of the "if(ssl)". If we set it on some platforms, it crashes From 612db427725b3bdac3d6851288c93051bfe69621 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Mon, 2 Apr 2018 10:40:12 -0700 Subject: [PATCH 389/453] Re-enable SSL tests cross plat Home/#2477 --- .../Autobahn/AutobahnTester.cs | 8 +------- .../AutobahnTests.cs | 5 ++--- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index 4c08a43c32..770ad04659 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -165,13 +165,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn // Mac HttpClient on NetCoreApp2.0 doesn't alow you to set some combinations. // https://github.com/dotnet/corefx/blob/586cffcdfdf23ad6c193a4bf37fce88a1bf69508/src/System.Net.Http/src/System/Net/Http/CurlHandler/CurlHandler.SslProvider.OSX.cs#L104-L106 handler.SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; - if (ssl) - { - // Don't take this out of the "if(ssl)". If we set it on some platforms, it crashes - // So we avoid running SSL tests on those platforms (for now). - // See https://github.com/dotnet/corefx/issues/9728 - handler.ServerCertificateCustomValidationCallback = (_, __, ___, ____) => true; - } + handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator; var client = result.CreateHttpClient(handler); // Make sure the server works diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs index 897bf3f1e6..08c798a52c 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs @@ -62,12 +62,11 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest using (var tester = new AutobahnTester(loggerFactory, spec)) { await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token); + await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: true, environment: "ManagedSockets", cancellationToken: cts.Token); - // Windows-only WebListener tests, and Kestrel SSL tests (due to: https://github.com/aspnet/WebSockets/issues/102) + // Windows-only WebListener tests if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: true, environment: "ManagedSockets", cancellationToken: cts.Token); - if (IsWindows8OrHigher()) { // WebListener occasionally gives a non-strict response on 3.2. IIS Express seems to have the same behavior. Wonder if it's related to HttpSys? From 54a0536e3f66eaddb604f1df607942f8070abdac Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 3 Apr 2018 22:46:58 +0000 Subject: [PATCH 390/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 36 ++++++++++++++++++------------------ korebuild-lock.txt | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 4e52e83a95..22aa3cd005 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,26 +3,26 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview3-17001 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 0.5.0-preview2-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 + 2.1.0-preview3-17002 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 0.5.0-preview2-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 2.0.0 - 2.1.0-preview2-26314-02 + 2.1.0-preview3-26331-01 15.6.1 - 4.5.0-preview2-26313-01 + 4.5.0-preview3-26331-02 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 50ba1b5737..c879a84a90 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview3-17001 -commithash:dda68c56abf0d3b911fe6a2315872c446b314585 +version:2.1.0-preview3-17002 +commithash:b8e4e6ab104adc94c0719bb74229870e9b584a7f From 2ef84e6b9ae03a0d229e0c3af5e141189feda539 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 15 Apr 2018 14:30:55 -0700 Subject: [PATCH 391/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 36 ++++++++++++++++++------------------ korebuild-lock.txt | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 22aa3cd005..7ea76d3b65 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,26 +3,26 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview3-17002 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 0.5.0-preview2-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 + 2.1.0-preview3-17018 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 0.5.0-preview2-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 2.0.0 - 2.1.0-preview3-26331-01 + 2.1.0-preview3-26413-05 15.6.1 - 4.5.0-preview3-26331-02 + 4.5.0-preview3-26413-02 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index c879a84a90..ce2f277c53 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview3-17002 -commithash:b8e4e6ab104adc94c0719bb74229870e9b584a7f +version:2.1.0-preview3-17018 +commithash:af264ca131f212b5ba8aafbc5110fc0fc510a2be From 07dddce092708a216350aa6a7e95c104a3d03756 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 16 Apr 2018 17:04:05 -0700 Subject: [PATCH 392/453] Branching for 2.1.0-rc1 --- build/repo.props | 3 ++- korebuild.json | 4 ++-- version.props | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/build/repo.props b/build/repo.props index a7ce27ecb1..de99df697a 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,4 +1,4 @@ - + @@ -7,6 +7,7 @@ Internal.AspNetCore.Universe.Lineup + 2.1.0-rc1-* https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json diff --git a/korebuild.json b/korebuild.json index bd5d51a51b..678d8bb948 100644 --- a/korebuild.json +++ b/korebuild.json @@ -1,4 +1,4 @@ { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev" + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json", + "channel": "release/2.1" } diff --git a/version.props b/version.props index 24f2b00a0a..e27532787e 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.1.0 - preview3 + rc1 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 4db62c5786e06b511a5433af32cd8279584fe6f1 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 16 Apr 2018 17:04:10 -0700 Subject: [PATCH 393/453] Update version number to 2.2.0 --- version.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.props b/version.props index 24f2b00a0a..44985cedb3 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ - 2.1.0 - preview3 + 2.2.0 + preview1 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From ac0ee35362d18b0a77873a87b3e75f454e17624a Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Wed, 18 Apr 2018 15:19:24 -0700 Subject: [PATCH 394/453] Change AutobahnTester to use dynamic ports with Kestrel (#238) - Depends on https://github.com/aspnet/Hosting/pull/1388 - Addresses https://github.com/aspnet/Home/issues/3062 --- build/dependencies.props | 2 +- .../Autobahn/AutobahnTester.cs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 7ea76d3b65..eb1afb016f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -9,7 +9,7 @@ 2.1.0-preview3-32233 2.1.0-preview3-32233 2.1.0-preview3-32233 - 0.5.0-preview2-32233 + 0.5.0-a-preview3-deployment-parameters-scheme-16978 2.1.0-preview3-32233 2.1.0-preview3-32233 2.1.0-preview3-32233 diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index 770ad04659..752573f9fc 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -129,7 +129,6 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn public async Task DeployTestAndAddToSpec(ServerType server, bool ssl, string environment, CancellationToken cancellationToken, Action expectationConfig = null) { - var baseUrl = ssl ? "https://localhost:0" : "http://localhost:0"; var sslNamePart = ssl ? "SSL" : "NoSSL"; var name = $"{server}|{sslNamePart}|{environment}"; var logger = _loggerFactory.CreateLogger($"AutobahnTestApp:{server}:{sslNamePart}:{environment}"); @@ -146,7 +145,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn #endif var parameters = new DeploymentParameters(appPath, server, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64) { - ApplicationBaseUriHint = baseUrl, + Scheme = (ssl ? Uri.UriSchemeHttps : Uri.UriSchemeHttp), ApplicationType = ApplicationType.Portable, TargetFramework = targetFramework, EnvironmentName = environment, From a6e2dcc640b69cff6241e5b255f27caae3b56afe Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 19 Apr 2018 16:45:53 -0700 Subject: [PATCH 395/453] Set NETStandardImplicitPackageVersion via dependencies.props --- Directory.Build.targets | 1 + build/dependencies.props | 1 + 2 files changed, 2 insertions(+) diff --git a/Directory.Build.targets b/Directory.Build.targets index 894b1d0cf8..53b3f6e1da 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -2,5 +2,6 @@ $(MicrosoftNETCoreApp20PackageVersion) $(MicrosoftNETCoreApp21PackageVersion) + $(NETStandardLibrary20PackageVersion) diff --git a/build/dependencies.props b/build/dependencies.props index 7ea76d3b65..052517c4c9 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -22,6 +22,7 @@ 2.0.0 2.1.0-preview3-26413-05 15.6.1 + 2.0.1 4.5.0-preview3-26413-02 2.3.1 2.4.0-beta.1.build3945 From 1b6ded26cfc9fd3a955ff81cc4964092e2748d01 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 19 Apr 2018 22:39:59 -0700 Subject: [PATCH 396/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 36 ++++++++++++++++++------------------ korebuild-lock.txt | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 052517c4c9..02ed1edf55 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,27 +3,27 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview3-17018 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 0.5.0-preview2-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 + 2.1.0-rc1-15774 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 0.5.0-preview2-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 2.0.0 - 2.1.0-preview3-26413-05 + 2.1.0-rc1-26419-02 15.6.1 2.0.1 - 4.5.0-preview3-26413-02 + 4.5.0-rc1-26419-03 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index ce2f277c53..d35f5d62cf 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview3-17018 -commithash:af264ca131f212b5ba8aafbc5110fc0fc510a2be +version:2.1.0-rc1-15774 +commithash:ed5ca9de3c652347dbb0158a9a65eff3471d2114 From e32e585d5689d959b86f801da1e95f69830995bf Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Fri, 20 Apr 2018 16:45:52 -0700 Subject: [PATCH 397/453] Fix bad merge from release/2.1 --- build/dependencies.props | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 943d558ecb..97b3e3abea 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,29 +1,29 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-rc1-15774 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 0.5.0-preview2-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 + 2.1.0-preview3-17018 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 0.5.0-a-preview3-deployment-parameters-scheme-16978 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 2.0.0 - 2.1.0-rc1-26419-02 + 2.1.0-preview3-26413-05 15.6.1 2.0.1 - 4.5.0-rc1-26419-03 + 4.5.0-preview3-26413-02 2.3.1 2.4.0-beta.1.build3945 From 358b6f146769e17be5ac5786d1d797b0123c7536 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Mon, 23 Apr 2018 12:30:28 -0700 Subject: [PATCH 398/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 32 ++++++++++++++++---------------- korebuild-lock.txt | 4 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 97b3e3abea..73232108fb 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,22 +3,22 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview3-17018 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 0.5.0-a-preview3-deployment-parameters-scheme-16978 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 + 2.2.0-preview1-17037 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 0.5.0-preview3-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 2.0.0 2.1.0-preview3-26413-05 15.6.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index ce2f277c53..790ae84e6d 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview3-17018 -commithash:af264ca131f212b5ba8aafbc5110fc0fc510a2be +version:2.2.0-preview1-17037 +commithash:557055a86cbdc359c97d4fb1c2d23a3dc7ae731e From 8324ecedb3cb383412f95ac30378e3c90e201f64 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 29 Apr 2018 12:36:23 -0700 Subject: [PATCH 399/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 38 +++++++++++++++++++------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 73232108fb..568c29e9d0 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,27 +3,27 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17037 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 0.5.0-preview3-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 + 2.2.0-preview1-17042 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 0.5.0-preview3-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 2.0.0 - 2.1.0-preview3-26413-05 + 2.2.0-preview1-26424-04 15.6.1 - 2.0.1 - 4.5.0-preview3-26413-02 + 2.0.3 + 4.5.0-preview3-26423-04 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 790ae84e6d..5a9689541e 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17037 -commithash:557055a86cbdc359c97d4fb1c2d23a3dc7ae731e +version:2.2.0-preview1-17042 +commithash:edf0705d014293c260de763543784330514db9a3 From d141ea5788834a3805dd44de9e3b612cc56a7c33 Mon Sep 17 00:00:00 2001 From: "Nate McMaster (automated)" Date: Mon, 30 Apr 2018 14:51:47 -0700 Subject: [PATCH 400/453] Bump version to 2.1.0-rtm --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index e27532787e..b9552451d8 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.1.0 - rc1 + rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From b3356b90b20e1fdea3c49cef8f4bbbe0b991e731 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Fri, 4 May 2018 07:55:07 -0700 Subject: [PATCH 401/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 38 +++++++++++++++++++------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 02ed1edf55..432abe92ce 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,27 +3,27 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-rc1-15774 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 0.5.0-preview2-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 + 2.1.0-rtm-15783 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 0.5.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 2.0.0 - 2.1.0-rc1-26419-02 + 2.1.0-rtm-26502-02 15.6.1 - 2.0.1 - 4.5.0-rc1-26419-03 + 2.0.3 + 4.5.0-rtm-26502-02 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index d35f5d62cf..27e94579a9 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-rc1-15774 -commithash:ed5ca9de3c652347dbb0158a9a65eff3471d2114 +version:2.1.0-rtm-15783 +commithash:5fc2b2f607f542a2ffde11c19825e786fc1a3774 From bd7b951df75794af1afbf5baa0880c8a228a4103 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 6 May 2018 12:35:20 -0700 Subject: [PATCH 402/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 32 ++++++++++++++++---------------- korebuild-lock.txt | 4 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 568c29e9d0..575dc9b6e6 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,22 +3,22 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17042 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 0.5.0-preview3-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 + 2.2.0-preview1-17047 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 0.6.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 2.0.0 2.2.0-preview1-26424-04 15.6.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 5a9689541e..18df6940ae 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17042 -commithash:edf0705d014293c260de763543784330514db9a3 +version:2.2.0-preview1-17047 +commithash:e1957b52ddc8b62bd39c5c400322fccb5364624c From 3095b86da1ad05a25459c9c2a6e08c0dffccb6fd Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 7 May 2018 15:16:36 -0700 Subject: [PATCH 403/453] Upgrade to netcoreapp22 --- Directory.Build.targets | 5 ++- build/dependencies.props | 35 ++++++++++--------- build/repo.props | 3 +- korebuild-lock.txt | 4 +-- samples/EchoApp/EchoApp.csproj | 4 +-- test/AutobahnTestApp/AutobahnTestApp.csproj | 5 ++- test/Directory.Build.props | 6 ++-- ...pNetCore.WebSockets.ConformanceTest.csproj | 5 ++- 8 files changed, 35 insertions(+), 32 deletions(-) diff --git a/Directory.Build.targets b/Directory.Build.targets index 53b3f6e1da..78626b773e 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,7 +1,10 @@ - + $(MicrosoftNETCoreApp20PackageVersion) $(MicrosoftNETCoreApp21PackageVersion) + $(MicrosoftNETCoreApp22PackageVersion) $(NETStandardLibrary20PackageVersion) + + 99.9 diff --git a/build/dependencies.props b/build/dependencies.props index 575dc9b6e6..d02bc0b83a 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,26 +1,27 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17047 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 0.6.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 + 2.2.0-preview1-17048 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 0.6.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 2.0.0 2.2.0-preview1-26424-04 + 2.2.0-preview1-26502-01 15.6.1 2.0.3 4.5.0-preview3-26423-04 diff --git a/build/repo.props b/build/repo.props index a7ce27ecb1..dbb6943347 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,4 +1,4 @@ - + @@ -13,5 +13,6 @@ + diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 18df6940ae..da5dcd1202 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17047 -commithash:e1957b52ddc8b62bd39c5c400322fccb5364624c +version:2.2.0-preview1-17048 +commithash:de14a0ee5fb48508ee8a29c14280a2928f8dabf8 diff --git a/samples/EchoApp/EchoApp.csproj b/samples/EchoApp/EchoApp.csproj index f5696ccf03..fc19ef1f0c 100644 --- a/samples/EchoApp/EchoApp.csproj +++ b/samples/EchoApp/EchoApp.csproj @@ -1,7 +1,7 @@ - + - netcoreapp2.1;net461 + netcoreapp2.2;net461 diff --git a/test/AutobahnTestApp/AutobahnTestApp.csproj b/test/AutobahnTestApp/AutobahnTestApp.csproj index 175f724c74..8f470696bc 100644 --- a/test/AutobahnTestApp/AutobahnTestApp.csproj +++ b/test/AutobahnTestApp/AutobahnTestApp.csproj @@ -1,8 +1,7 @@ - + - netcoreapp2.1 - $(TargetFrameworks);netcoreapp2.0 + netcoreapp2.2 diff --git a/test/Directory.Build.props b/test/Directory.Build.props index be781a6b15..a84a332640 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -1,10 +1,10 @@ - + - netcoreapp2.1 + netcoreapp2.2 $(DeveloperBuildTestTfms) - netcoreapp2.1;netcoreapp2.0 + $(StandardTestTfms);net461 diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj index 79e3839b12..539a46f002 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj @@ -1,8 +1,7 @@ - + - netcoreapp2.1 - $(TargetFrameworks);netcoreapp2.0 + netcoreapp2.2 From bb70e7077f5749608994b2d590c5df7ef7258a7c Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Tue, 8 May 2018 12:00:27 -0700 Subject: [PATCH 404/453] Handle ifdefs --- .../Autobahn/AutobahnTester.cs | 8 +++----- .../WebSocketMiddlewareTests.cs | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index 752573f9fc..b6775db4e4 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -136,10 +136,8 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn var appPath = Helpers.GetApplicationPath("AutobahnTestApp"); var configPath = Path.Combine(Directory.GetCurrentDirectory(), "..", "..", "..", "Http.config"); var targetFramework = -#if NETCOREAPP2_1 - "netcoreapp2.1"; -#elif NETCOREAPP2_0 - "netcoreapp2.0"; +#if NETCOREAPP2_2 + "netcoreapp2.2"; #else #error Target frameworks need to be updated #endif @@ -160,7 +158,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn cancellationToken.ThrowIfCancellationRequested(); var handler = new HttpClientHandler(); - // Win7 HttpClient on NetCoreApp2.1 defaults to TLS 1.0 and won't connect to Kestrel. https://github.com/dotnet/corefx/issues/28733 + // Win7 HttpClient on NetCoreApp2.2 defaults to TLS 1.0 and won't connect to Kestrel. https://github.com/dotnet/corefx/issues/28733 // Mac HttpClient on NetCoreApp2.0 doesn't alow you to set some combinations. // https://github.com/dotnet/corefx/blob/586cffcdfdf23ad6c193a4bf37fce88a1bf69508/src/System.Net.Http/src/System/Net/Http/CurlHandler/CurlHandler.SslProvider.OSX.cs#L104-L106 handler.SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs index e966aea6b4..fd2fbc8d51 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs @@ -13,10 +13,10 @@ using Xunit.Abstractions; namespace Microsoft.AspNetCore.WebSockets.Test { -#if NET461 || NETCOREAPP2_0 +#if NET461 // ClientWebSocket does not support WebSockets on these platforms and OS. Kestrel does support it. [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, SkipReason = "No WebSockets Client for this platform")] -#elif NETCOREAPP2_1 +#elif NETCOREAPP2_2 // ClientWebSocket has added support for WebSockets on Win7. #else #error Unknown TFM From 01a8cb6e8c86ccb7dde47a557f708d56faf3b188 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 13 May 2018 14:27:43 -0700 Subject: [PATCH 405/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 40 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index d02bc0b83a..56ad3910ef 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,30 +1,30 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17048 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 0.6.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 + 2.2.0-preview1-17051 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 0.6.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 2.0.0 - 2.2.0-preview1-26424-04 - 2.2.0-preview1-26502-01 + 2.1.0-rc1 + 2.2.0-preview1-26509-06 15.6.1 2.0.3 - 4.5.0-preview3-26423-04 + 4.6.0-preview1-26508-04 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index da5dcd1202..56263a26fc 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17048 -commithash:de14a0ee5fb48508ee8a29c14280a2928f8dabf8 +version:2.2.0-preview1-17051 +commithash:253c3a480063bc3abaa5cde42f6e27b58457ef9b From 8513fc832943454c15e0138bb7b278f0b2c84c2c Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Mon, 14 May 2018 06:03:57 -0700 Subject: [PATCH 406/453] React to IntegrationTesting changes --- build/dependencies.props | 2 +- .../Autobahn/AutobahnTester.cs | 2 +- .../AutobahnTests.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 56ad3910ef..f0412eda16 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -9,7 +9,7 @@ 2.2.0-preview1-34184 2.2.0-preview1-34184 2.2.0-preview1-34184 - 0.6.0-preview1-34184 + 0.6.0-a-preview1-inttesting-17017 2.2.0-preview1-34184 2.2.0-preview1-34184 2.2.0-preview1-34184 diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index b6775db4e4..4eb5ee177e 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { public class AutobahnTester : IDisposable { - private readonly List _deployers = new List(); + private readonly List _deployers = new List(); private readonly List _deployments = new List(); private readonly List _expectations = new List(); private readonly ILoggerFactory _loggerFactory; diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs index 08c798a52c..e1e86143a6 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs @@ -71,7 +71,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest { // WebListener occasionally gives a non-strict response on 3.2. IIS Express seems to have the same behavior. Wonder if it's related to HttpSys? // For now, just allow the non-strict response, it's not a failure. - await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token); + await tester.DeployTestAndAddToSpec(ServerType.HttpSys, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token); } } From f479af8c944e567ad56b151594a7bd0ba0b798aa Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 20 May 2018 19:51:01 +0000 Subject: [PATCH 407/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 32 ++++++++++++++++---------------- korebuild-lock.txt | 4 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index f0412eda16..51a8cd897e 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,22 +3,22 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17051 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 0.6.0-a-preview1-inttesting-17017 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 + 2.2.0-preview1-17060 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 0.6.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 2.0.0 2.1.0-rc1 2.2.0-preview1-26509-06 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 56263a26fc..06fc8a13e4 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17051 -commithash:253c3a480063bc3abaa5cde42f6e27b58457ef9b +version:2.2.0-preview1-17060 +commithash:25b4b134d6f8f7b461928f0d495cfc695ccabb5b From aae8417e1ade794bead7af8b2ab26f81a0ecc2b5 Mon Sep 17 00:00:00 2001 From: "Nate McMaster (automated)" Date: Fri, 25 May 2018 16:17:50 -0700 Subject: [PATCH 408/453] Update bootstrapper scripts (automated commit) [ci skip] --- run.ps1 | 25 +++++++++++++++++++------ run.sh | 33 +++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/run.ps1 b/run.ps1 index 27dcf848f8..3b27382468 100644 --- a/run.ps1 +++ b/run.ps1 @@ -26,12 +26,18 @@ The base url where build tools can be downloaded. Overrides the value from the c .PARAMETER Update Updates KoreBuild to the latest version even if a lock file is present. +.PARAMETER Reinstall +Re-installs KoreBuild + .PARAMETER ConfigFile The path to the configuration file that stores values. Defaults to korebuild.json. .PARAMETER ToolsSourceSuffix The Suffix to append to the end of the ToolsSource. Useful for query strings in blob stores. +.PARAMETER CI +Sets up CI specific settings and variables. + .PARAMETER Arguments Arguments to be passed to the command @@ -65,8 +71,10 @@ param( [string]$ToolsSource, [Alias('u')] [switch]$Update, - [string]$ConfigFile, + [switch]$Reinstall, [string]$ToolsSourceSuffix, + [string]$ConfigFile = $null, + [switch]$CI, [Parameter(ValueFromRemainingArguments = $true)] [string[]]$Arguments ) @@ -93,6 +101,10 @@ function Get-KoreBuild { $version = $version.TrimStart('version:').Trim() $korebuildPath = Join-Paths $DotNetHome ('buildtools', 'korebuild', $version) + if ($Reinstall -and (Test-Path $korebuildPath)) { + Remove-Item -Force -Recurse $korebuildPath + } + if (!(Test-Path $korebuildPath)) { Write-Host -ForegroundColor Magenta "Downloading KoreBuild $version" New-Item -ItemType Directory -Path $korebuildPath | Out-Null @@ -101,9 +113,9 @@ function Get-KoreBuild { try { $tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip" Get-RemoteFile $remotePath $tmpfile $ToolsSourceSuffix - if (Get-Command -Name 'Expand-Archive' -ErrorAction Ignore) { + if (Get-Command -Name 'Microsoft.PowerShell.Archive\Expand-Archive' -ErrorAction Ignore) { # Use built-in commands where possible as they are cross-plat compatible - Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath + Microsoft.PowerShell.Archive\Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath } else { # Fallback to old approach for old installations of PowerShell @@ -167,8 +179,9 @@ if (Test-Path $ConfigFile) { } } catch { - Write-Warning "$ConfigFile could not be read. Its settings will be ignored." - Write-Warning $Error[0] + Write-Host -ForegroundColor Red $Error[0] + Write-Error "$ConfigFile contains invalid JSON." + exit 1 } } @@ -188,7 +201,7 @@ $korebuildPath = Get-KoreBuild Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') try { - Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile + Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile -CI:$CI Invoke-KoreBuildCommand $Command @Arguments } finally { diff --git a/run.sh b/run.sh index 834961fc3a..02aac15874 100755 --- a/run.sh +++ b/run.sh @@ -14,10 +14,12 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" [ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" verbose=false update=false +reinstall=false repo_path="$DIR" channel='' tools_source='' tools_source_suffix='' +ci=false # # Functions @@ -38,6 +40,8 @@ __usage() { echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." echo " --tools-source-suffix|-ToolsSourceSuffix The suffix to append to tools-source. Useful for query strings." echo " -u|--update Update to the latest KoreBuild even if the lock file is present." + echo " --reinstall Reinstall KoreBuild." + echo " --ci Apply CI specific settings and environment variables." echo "" echo "Description:" echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." @@ -62,6 +66,10 @@ get_korebuild() { version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" + if [ "$reinstall" = true ] && [ -d "$korebuild_path" ]; then + rm -rf "$korebuild_path" + fi + { if [ ! -d "$korebuild_path" ]; then mkdir -p "$korebuild_path" @@ -175,6 +183,12 @@ while [[ $# -gt 0 ]]; do -u|--update|-Update) update=true ;; + --reinstall|-[Rr]einstall) + reinstall=true + ;; + --ci|-[Cc][Ii]) + ci=true + ;; --verbose|-Verbose) verbose=true ;; @@ -206,17 +220,28 @@ if [ -f "$config_file" ]; then config_channel="$(jq -r 'select(.channel!=null) | .channel' "$config_file")" config_tools_source="$(jq -r 'select(.toolsSource!=null) | .toolsSource' "$config_file")" else - __warn "$config_file is invalid JSON. Its settings will be ignored." + _error "$config_file contains invalid JSON." + exit 1 fi elif __machine_has python ; then if python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then config_channel="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')")" config_tools_source="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")" else - __warn "$config_file is invalid JSON. Its settings will be ignored." + _error "$config_file contains invalid JSON." + exit 1 + fi + elif __machine_has python3 ; then + if python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then + config_channel="$(python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')")" + config_tools_source="$(python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")" + else + _error "$config_file contains invalid JSON." + exit 1 fi else - __warn 'Missing required command: jq or pyton. Could not parse the JSON file. Its settings will be ignored.' + _error 'Missing required command: jq or python. Could not parse the JSON file.' + exit 1 fi [ ! -z "${config_channel:-}" ] && channel="$config_channel" @@ -227,5 +252,5 @@ fi [ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' get_korebuild -set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" +set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" "$ci" invoke_korebuild_command "$command" "$@" From ee4fec48e72daeb22f668789cfd08e94cf4948d3 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 27 May 2018 19:33:52 +0000 Subject: [PATCH 409/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 36 ++++++++++++++++++------------------ korebuild-lock.txt | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 51a8cd897e..ec73e64835 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,28 +3,28 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17060 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 0.6.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 + 2.2.0-preview1-17064 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 0.6.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 2.0.0 2.1.0-rc1 - 2.2.0-preview1-26509-06 + 2.2.0-preview1-26526-03 15.6.1 2.0.3 - 4.6.0-preview1-26508-04 + 4.6.0-preview1-26525-01 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 06fc8a13e4..de5df64434 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17060 -commithash:25b4b134d6f8f7b461928f0d495cfc695ccabb5b +version:2.2.0-preview1-17064 +commithash:5380a2461b135b261646f31d1c919ab0a7b577a8 From 28aa2e38a953d3980cb2ef4675a8481b29d48f5d Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 29 May 2018 09:57:07 -0700 Subject: [PATCH 410/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 36 ++++++++++++++++++------------------ korebuild-lock.txt | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 432abe92ce..bf40a418c9 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,27 +3,27 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-rtm-15783 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 0.5.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 + 2.1.1-rtm-15790 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 0.5.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 2.0.0 - 2.1.0-rtm-26502-02 + 2.1.0 15.6.1 2.0.3 - 4.5.0-rtm-26502-02 + 4.5.0 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 27e94579a9..de0eb84cf3 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-rtm-15783 -commithash:5fc2b2f607f542a2ffde11c19825e786fc1a3774 +version:2.1.1-rtm-15790 +commithash:274c65868e735f29f4078c1884c61c4371ee1fc0 From a1085ed31cebed4d4fa1f10cd662a462a87d41f1 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 30 May 2018 09:50:07 -0700 Subject: [PATCH 411/453] Bumping version from 2.1.0 to 2.1.1 --- version.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.props b/version.props index b9552451d8..669c874829 100644 --- a/version.props +++ b/version.props @@ -1,6 +1,6 @@ - + - 2.1.0 + 2.1.1 rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final From a594b0bd134c79ebad61689081f58df58cbf9a5e Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 31 May 2018 10:17:50 -0700 Subject: [PATCH 412/453] fix wstest on travis (#242) --- .travis.yml | 2 +- build/setup-wstest.sh | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 81bf8af485..28a92bb1fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ python: os: - linux - osx -osx_image: xcode8.2 +osx_image: xcode9.3 addons: apt: packages: diff --git a/build/setup-wstest.sh b/build/setup-wstest.sh index 2fb19c5bf3..6c8800e23f 100755 --- a/build/setup-wstest.sh +++ b/build/setup-wstest.sh @@ -1,18 +1,12 @@ #!/usr/bin/env bash -if [ "$TRAVIS_OS_NAME" == "osx" ]; then - # Install python - brew update > /dev/null - brew install python -fi - type -p python python --version # Install local virtualenv mkdir .python cd .python -curl -O https://pypi.python.org/packages/d4/0c/9840c08189e030873387a73b90ada981885010dd9aea134d6de30cd24cb8/virtualenv-15.1.0.tar.gz +curl -OL https://pypi.python.org/packages/d4/0c/9840c08189e030873387a73b90ada981885010dd9aea134d6de30cd24cb8/virtualenv-15.1.0.tar.gz tar xf virtualenv-15.1.0.tar.gz cd .. From 89536c20812b63c3b9eebe3dc512efb9a6adabaa Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 3 Jun 2018 19:33:18 +0000 Subject: [PATCH 413/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 38 +++++++++++++++++++------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index ec73e64835..ef4360dbe4 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,28 +3,28 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17064 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 0.6.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 + 2.2.0-preview1-17067 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 0.6.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 2.0.0 - 2.1.0-rc1 - 2.2.0-preview1-26526-03 + 2.1.0 + 2.2.0-preview1-26531-03 15.6.1 2.0.3 - 4.6.0-preview1-26525-01 + 4.6.0-preview1-26531-03 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index de5df64434..34bf7eb808 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17064 -commithash:5380a2461b135b261646f31d1c919ab0a7b577a8 +version:2.2.0-preview1-17067 +commithash:2af0e2e3d02329b4f0290061ab9bd8c7ca1aa26f From 335135b148c7a091842521bc750a1e76e1e5fe89 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 5 Jun 2018 22:36:00 -0700 Subject: [PATCH 414/453] Add certificate names for code signing --- Directory.Build.props | 2 ++ korebuild-lock.txt | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 6c76a5608f..5a9460fb37 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -14,6 +14,8 @@ $(MSBuildThisFileDirectory) $(MSBuildThisFileDirectory)build\Key.snk true + Microsoft + MicrosoftNuGet true true diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 34bf7eb808..2dedb9dd4c 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17067 -commithash:2af0e2e3d02329b4f0290061ab9bd8c7ca1aa26f +version:2.2.0-preview1-17075 +commithash:d9f07c7f313a0af1d49f003f5424b4dbbdd3e09f From 42d99933a52647bc3b041f704370ab672139a156 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 7 Jun 2018 19:52:43 +0000 Subject: [PATCH 415/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 36 ++++++++++++++++++------------------ korebuild-lock.txt | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index ef4360dbe4..9cba45924e 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,28 +3,28 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17067 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 0.6.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 + 2.2.0-preview1-17081 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 0.6.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 2.0.0 2.1.0 - 2.2.0-preview1-26531-03 + 2.2.0-preview1-26606-01 15.6.1 2.0.3 - 4.6.0-preview1-26531-03 + 4.6.0-preview1-26605-01 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 2dedb9dd4c..9592880b2a 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17075 -commithash:d9f07c7f313a0af1d49f003f5424b4dbbdd3e09f +version:2.2.0-preview1-17081 +commithash:73f09c256e2a54270951562ecc0ef4a953926c36 From 81c94145c9272d6c5051fe36f382aeac19dca6d4 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Thu, 7 Jun 2018 15:48:59 -0700 Subject: [PATCH 416/453] Adding VSTS file --- .vsts-pipelines/builds/ci-internal.yml | 13 +++++++++++++ .vsts-pipelines/builds/ci-public.yml | 15 +++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 .vsts-pipelines/builds/ci-internal.yml create mode 100644 .vsts-pipelines/builds/ci-public.yml diff --git a/.vsts-pipelines/builds/ci-internal.yml b/.vsts-pipelines/builds/ci-internal.yml new file mode 100644 index 0000000000..d7ceb76378 --- /dev/null +++ b/.vsts-pipelines/builds/ci-internal.yml @@ -0,0 +1,13 @@ +trigger: +- dev +- release/* + +resources: + repositories: + - repository: buildtools + type: git + name: aspnet-BuildTools + ref: refs/heads/dev + +phases: +- template: .vsts-pipelines/templates/project-ci.yml@buildtools diff --git a/.vsts-pipelines/builds/ci-public.yml b/.vsts-pipelines/builds/ci-public.yml new file mode 100644 index 0000000000..b7f25723f8 --- /dev/null +++ b/.vsts-pipelines/builds/ci-public.yml @@ -0,0 +1,15 @@ +trigger: +- dev +- release/* + +# See https://github.com/aspnet/BuildTools +resources: + repositories: + - repository: buildtools + type: github + endpoint: DotNet-Bot GitHub Connection + name: aspnet/BuildTools + ref: refs/heads/dev + +phases: +- template: .vsts-pipelines/templates/project-ci.yml@buildtools From 76e31009e3f13c8deddd6c1829e05726924185cb Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 12 Jun 2018 19:38:16 +0000 Subject: [PATCH 417/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 34 +++++++++++++++++----------------- korebuild-lock.txt | 4 ++-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index bf40a418c9..286baea4a6 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,27 +3,27 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.1-rtm-15790 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 0.5.0 - 2.1.0 - 2.1.0 - 2.1.0 + 2.1.1-rtm-15793 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 0.5.1 + 2.1.1 + 2.1.1 + 2.1.1 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 2.0.0 - 2.1.0 + 2.1.1 15.6.1 2.0.3 - 4.5.0 + 4.5.1 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index de0eb84cf3..d2f4947bc8 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.1-rtm-15790 -commithash:274c65868e735f29f4078c1884c61c4371ee1fc0 +version:2.1.1-rtm-15793 +commithash:988313f4b064d6c69fc6f7b845b6384a6af3447a From 18d5ab85af885e4a72b6ad92560eac74a35ced94 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 30 May 2018 15:23:34 -0700 Subject: [PATCH 418/453] Bumping version from 2.1.1 to 2.1.2 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 669c874829..478dfd16ed 100644 --- a/version.props +++ b/version.props @@ -1,6 +1,6 @@  - 2.1.1 + 2.1.2 rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final From a927c7380577fc2390aeaef19d1403bc19e003bf Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Wed, 13 Jun 2018 11:00:31 -0700 Subject: [PATCH 419/453] Set 2.1 baselines --- src/Microsoft.AspNetCore.WebSockets/baseline.netcore.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.WebSockets/baseline.netcore.json b/src/Microsoft.AspNetCore.WebSockets/baseline.netcore.json index 6bddb5de96..4a3d74e18c 100644 --- a/src/Microsoft.AspNetCore.WebSockets/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.WebSockets/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.WebSockets, Version=2.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.WebSockets, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.AspNetCore.Builder.WebSocketMiddlewareExtensions", From 7922b27c65a94ba952aefc1306aaa1f7e5f5c58d Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Wed, 13 Jun 2018 11:00:31 -0700 Subject: [PATCH 420/453] Set 2.1 baselines --- src/Microsoft.AspNetCore.WebSockets/baseline.netcore.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.WebSockets/baseline.netcore.json b/src/Microsoft.AspNetCore.WebSockets/baseline.netcore.json index 6bddb5de96..4a3d74e18c 100644 --- a/src/Microsoft.AspNetCore.WebSockets/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.WebSockets/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.WebSockets, Version=2.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.WebSockets, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.AspNetCore.Builder.WebSocketMiddlewareExtensions", From d2b5a2c3dc7a1d85d0ee889786800096418843e1 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Mon, 25 Jun 2018 11:34:13 -0700 Subject: [PATCH 421/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 36 ++++++++++++++++++------------------ korebuild-lock.txt | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 9cba45924e..c2a89074c7 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,28 +3,28 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17081 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 0.6.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 + 2.2.0-preview1-17090 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 0.6.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 2.0.0 2.1.0 - 2.2.0-preview1-26606-01 + 2.2.0-preview1-26618-02 15.6.1 2.0.3 - 4.6.0-preview1-26605-01 + 4.6.0-preview1-26617-01 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 9592880b2a..3e694b2ed8 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17081 -commithash:73f09c256e2a54270951562ecc0ef4a953926c36 +version:2.2.0-preview1-17090 +commithash:b19e903e946579cd9482089bce7d917e8bacd765 From 519851627cd78bd1dcac564fba76b50933c6a85b Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 28 Jun 2018 16:22:21 -0700 Subject: [PATCH 422/453] Update infrastructure for the 2.2 release --- .vsts-pipelines/builds/ci-internal.yml | 4 ++-- .vsts-pipelines/builds/ci-public.yml | 6 +++--- build/repo.props | 1 + korebuild.json | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.vsts-pipelines/builds/ci-internal.yml b/.vsts-pipelines/builds/ci-internal.yml index d7ceb76378..dc7b8a3cb9 100644 --- a/.vsts-pipelines/builds/ci-internal.yml +++ b/.vsts-pipelines/builds/ci-internal.yml @@ -1,5 +1,5 @@ trigger: -- dev +- master - release/* resources: @@ -7,7 +7,7 @@ resources: - repository: buildtools type: git name: aspnet-BuildTools - ref: refs/heads/dev + ref: refs/heads/release/2.2 phases: - template: .vsts-pipelines/templates/project-ci.yml@buildtools diff --git a/.vsts-pipelines/builds/ci-public.yml b/.vsts-pipelines/builds/ci-public.yml index b7f25723f8..f5087d9c30 100644 --- a/.vsts-pipelines/builds/ci-public.yml +++ b/.vsts-pipelines/builds/ci-public.yml @@ -1,5 +1,5 @@ trigger: -- dev +- master - release/* # See https://github.com/aspnet/BuildTools @@ -9,7 +9,7 @@ resources: type: github endpoint: DotNet-Bot GitHub Connection name: aspnet/BuildTools - ref: refs/heads/dev - + ref: refs/heads/release/2.2 + phases: - template: .vsts-pipelines/templates/project-ci.yml@buildtools diff --git a/build/repo.props b/build/repo.props index dbb6943347..feea5ac9e6 100644 --- a/build/repo.props +++ b/build/repo.props @@ -7,6 +7,7 @@ Internal.AspNetCore.Universe.Lineup + 2.2.0-* https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json diff --git a/korebuild.json b/korebuild.json index bd5d51a51b..d217d06e3e 100644 --- a/korebuild.json +++ b/korebuild.json @@ -1,4 +1,4 @@ { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev" + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.2/tools/korebuild.schema.json", + "channel": "release/2.2" } From c48f2b953e74b9a999081c3d4f94ce53427947ff Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 8 Jul 2018 12:32:44 -0700 Subject: [PATCH 423/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 38 +++++++++++++++++++------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index c2a89074c7..a1477f9667 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,30 +3,30 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17090 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 0.6.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.0.0 - 2.1.0 + 2.2.0-preview1-17099 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 0.6.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.0.7 + 2.1.1 2.2.0-preview1-26618-02 15.6.1 2.0.3 4.6.0-preview1-26617-01 2.3.1 - 2.4.0-beta.1.build3945 + 2.4.0-rc.1.build4038 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 3e694b2ed8..8b9d17825f 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17090 -commithash:b19e903e946579cd9482089bce7d917e8bacd765 +version:2.2.0-preview1-17099 +commithash:263ed1db9866b6b419b1f5d5189a712aa218acb3 From d8b8e1a553dbae38370f925b02d009b1d13055b8 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 11 Jul 2018 15:06:44 -0700 Subject: [PATCH 424/453] Reverting version from 2.1.2 back to 2.1.1 As a result of changing the way we apply servicing updates to aspnet core, this repo did not need the version bump because there are no planned product changes in this repo. --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 478dfd16ed..669c874829 100644 --- a/version.props +++ b/version.props @@ -1,6 +1,6 @@  - 2.1.2 + 2.1.1 rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final From 4e1404a37b11b81f82b7abe7d3bff0d00a728364 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 11 Jul 2018 18:50:21 -0700 Subject: [PATCH 425/453] Updating dependencies to 2.1.2 and adding a section for pinned variable versions --- build/dependencies.props | 17 ++++++++++++----- korebuild-lock.txt | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 286baea4a6..0a3f17fb56 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -2,16 +2,18 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - - 2.1.1-rtm-15793 + + + + 2.1.3-rtm-15802 2.1.1 2.1.1 2.1.1 2.1.1 2.1.1 0.5.1 - 2.1.1 - 2.1.1 + 2.1.2 + 2.1.2 2.1.1 2.1.0 2.1.1 @@ -20,12 +22,17 @@ 2.1.1 2.1.1 2.0.0 - 2.1.1 + 2.1.2 15.6.1 2.0.3 4.5.1 2.3.1 2.4.0-beta.1.build3945 + + + + + diff --git a/korebuild-lock.txt b/korebuild-lock.txt index d2f4947bc8..1dfc352a0a 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.1-rtm-15793 -commithash:988313f4b064d6c69fc6f7b845b6384a6af3447a +version:2.1.3-rtm-15802 +commithash:a7c08b45b440a7d2058a0aa1eaa3eb6ba811976a From 9e7dfc4d150f728e911dae44890fe17ce4872239 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 12 Jul 2018 11:59:45 -0700 Subject: [PATCH 426/453] Pin version variables to the ASP.NET Core 2.1.2 baseline This reverts our previous policy of cascading versions on all servicing updates. This moves variables into the 'pinned' section, and points them to the latest stable release (versions that were used at the time of the 2.1.2 release). --- build/dependencies.props | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 0a3f17fb56..6d1c938c0c 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,8 +4,22 @@ - + 2.1.3-rtm-15802 + 2.0.0 + 2.1.2 + 15.6.1 + 2.0.3 + 4.5.1 + 2.3.1 + 2.4.0-beta.1.build3945 + + + + + + + 2.1.1 2.1.1 2.1.1 @@ -21,18 +35,5 @@ 2.1.1 2.1.1 2.1.1 - 2.0.0 - 2.1.2 - 15.6.1 - 2.0.3 - 4.5.1 - 2.3.1 - 2.4.0-beta.1.build3945 - - - - - - - + \ No newline at end of file From a1a972a70ec8874552021b7d150c2c841dadd82d Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 15 Jul 2018 12:31:58 -0700 Subject: [PATCH 427/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index a1477f9667..c859dd20c0 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,27 +4,27 @@ 2.2.0-preview1-17099 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 0.6.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.0.7 - 2.1.1 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 0.6.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.0.9 + 2.1.2 2.2.0-preview1-26618-02 15.6.1 2.0.3 - 4.6.0-preview1-26617-01 + 4.5.1 2.3.1 2.4.0-rc.1.build4038 From 227d52bf3bd00572648e2355243f71e3b82d0b71 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 22 Jul 2018 12:31:26 -0700 Subject: [PATCH 428/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index c859dd20c0..de6342af12 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,21 +4,21 @@ 2.2.0-preview1-17099 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 0.6.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 0.6.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 2.0.9 2.1.2 2.2.0-preview1-26618-02 From 5e074fec4e0b8817c5d79113965a8a279f6a540b Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 29 Jul 2018 12:29:38 -0700 Subject: [PATCH 429/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 35 ++++++++++++++++++----------------- korebuild-lock.txt | 4 ++-- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index de6342af12..36b1977681 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,22 +3,22 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17099 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 0.6.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 + 2.2.0-preview1-17102 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 0.6.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 2.0.9 2.1.2 2.2.0-preview1-26618-02 @@ -26,7 +26,8 @@ 2.0.3 4.5.1 2.3.1 - 2.4.0-rc.1.build4038 + 2.4.0 + diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 8b9d17825f..28cd6a5b03 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17099 -commithash:263ed1db9866b6b419b1f5d5189a712aa218acb3 +version:2.2.0-preview1-17102 +commithash:e7e2b5a97ca92cfc6acc4def534cb0901a6d1eb9 From 768d2a023e32c8530a4cda6a5a3c41fc5136b9a4 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Thu, 2 Aug 2018 14:43:11 -0700 Subject: [PATCH 430/453] Add Origin validation to WebSockets middleware (#252) --- build/dependencies.props | 1 + .../Microsoft.AspNetCore.WebSockets.csproj | 1 + .../WebSocketMiddleware.cs | 66 ++++++++++++--- .../WebSocketOptions.cs | 8 ++ ...WebSocketsDependencyInjectionExtensions.cs | 17 ++++ .../AddWebSocketsTests.cs | 33 ++++++++ .../KestrelWebSocketHelpers.cs | 9 +- .../WebSocketMiddlewareTests.cs | 84 +++++++++++++++++++ 8 files changed, 206 insertions(+), 13 deletions(-) create mode 100644 src/Microsoft.AspNetCore.WebSockets/WebSocketsDependencyInjectionExtensions.cs create mode 100644 test/Microsoft.AspNetCore.WebSockets.Test/AddWebSocketsTests.cs diff --git a/build/dependencies.props b/build/dependencies.props index 36b1977681..c1feca987e 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -17,6 +17,7 @@ 2.2.0-preview1-34823 2.2.0-preview1-34823 2.2.0-preview1-34823 + 2.2.0-preview1-34823 2.2.0-preview1-34823 2.2.0-preview1-34823 2.0.9 diff --git a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj index c5c5c8fbfb..277c0cc9fe 100644 --- a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj +++ b/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj @@ -11,6 +11,7 @@ + diff --git a/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs b/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs index eba9597cd5..74f1e4f7d8 100644 --- a/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs +++ b/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs @@ -4,13 +4,18 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Net.WebSockets; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.WebSockets.Internal; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Primitives; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.WebSockets { @@ -18,8 +23,11 @@ namespace Microsoft.AspNetCore.WebSockets { private readonly RequestDelegate _next; private readonly WebSocketOptions _options; + private readonly ILogger _logger; + private readonly bool _anyOriginAllowed; + private readonly List _allowedOrigins; - public WebSocketMiddleware(RequestDelegate next, IOptions options) + public WebSocketMiddleware(RequestDelegate next, IOptions options, ILoggerFactory loggerFactory) { if (next == null) { @@ -32,17 +40,45 @@ namespace Microsoft.AspNetCore.WebSockets _next = next; _options = options.Value; + _allowedOrigins = _options.AllowedOrigins.Select(o => o.ToLowerInvariant()).ToList(); + _anyOriginAllowed = _options.AllowedOrigins.Count == 0 || _options.AllowedOrigins.Contains("*", StringComparer.Ordinal); + + _logger = loggerFactory.CreateLogger(); // TODO: validate options. } + [Obsolete("This constructor has been replaced with an equivalent constructor which requires an ILoggerFactory.")] + public WebSocketMiddleware(RequestDelegate next, IOptions options) + : this(next, options, NullLoggerFactory.Instance) + { + } + public Task Invoke(HttpContext context) { // Detect if an opaque upgrade is available. If so, add a websocket upgrade. var upgradeFeature = context.Features.Get(); if (upgradeFeature != null && context.Features.Get() == null) { - context.Features.Set(new UpgradeHandshake(context, upgradeFeature, _options)); + var webSocketFeature = new UpgradeHandshake(context, upgradeFeature, _options); + context.Features.Set(webSocketFeature); + + if (!_anyOriginAllowed) + { + // Check for Origin header + var originHeader = context.Request.Headers[HeaderNames.Origin]; + + if (!StringValues.IsNullOrEmpty(originHeader) && webSocketFeature.IsWebSocketRequest) + { + // Check allowed origins to see if request is allowed + if (!_allowedOrigins.Contains(originHeader.ToString(), StringComparer.Ordinal)) + { + _logger.LogDebug("Request origin {Origin} is not in the list of allowed origins.", originHeader); + context.Response.StatusCode = StatusCodes.Status403Forbidden; + return Task.CompletedTask; + } + } + } } return _next(context); @@ -53,6 +89,7 @@ namespace Microsoft.AspNetCore.WebSockets private readonly HttpContext _context; private readonly IHttpUpgradeFeature _upgradeFeature; private readonly WebSocketOptions _options; + private bool? _isWebSocketRequest; public UpgradeHandshake(HttpContext context, IHttpUpgradeFeature upgradeFeature, WebSocketOptions options) { @@ -65,19 +102,26 @@ namespace Microsoft.AspNetCore.WebSockets { get { - if (!_upgradeFeature.IsUpgradableRequest) + if (_isWebSocketRequest == null) { - return false; - } - var headers = new List>(); - foreach (string headerName in HandshakeHelpers.NeededHeaders) - { - foreach (var value in _context.Request.Headers.GetCommaSeparatedValues(headerName)) + if (!_upgradeFeature.IsUpgradableRequest) { - headers.Add(new KeyValuePair(headerName, value)); + _isWebSocketRequest = false; + } + else + { + var headers = new List>(); + foreach (string headerName in HandshakeHelpers.NeededHeaders) + { + foreach (var value in _context.Request.Headers.GetCommaSeparatedValues(headerName)) + { + headers.Add(new KeyValuePair(headerName, value)); + } + } + _isWebSocketRequest = HandshakeHelpers.CheckSupportedWebSocketRequest(_context.Request.Method, headers); } } - return HandshakeHelpers.CheckSupportedWebSocketRequest(_context.Request.Method, headers); + return _isWebSocketRequest.Value; } } diff --git a/src/Microsoft.AspNetCore.WebSockets/WebSocketOptions.cs b/src/Microsoft.AspNetCore.WebSockets/WebSocketOptions.cs index 808cc86251..da5f630d62 100644 --- a/src/Microsoft.AspNetCore.WebSockets/WebSocketOptions.cs +++ b/src/Microsoft.AspNetCore.WebSockets/WebSocketOptions.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Collections.Generic; namespace Microsoft.AspNetCore.Builder { @@ -14,6 +15,7 @@ namespace Microsoft.AspNetCore.Builder { KeepAliveInterval = TimeSpan.FromMinutes(2); ReceiveBufferSize = 4 * 1024; + AllowedOrigins = new List(); } /// @@ -27,5 +29,11 @@ namespace Microsoft.AspNetCore.Builder /// The default is 4kb. /// public int ReceiveBufferSize { get; set; } + + /// + /// Set the Origin header values allowed for WebSocket requests to prevent Cross-Site WebSocket Hijacking. + /// By default all Origins are allowed. + /// + public IList AllowedOrigins { get; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.WebSockets/WebSocketsDependencyInjectionExtensions.cs b/src/Microsoft.AspNetCore.WebSockets/WebSocketsDependencyInjectionExtensions.cs new file mode 100644 index 0000000000..69b2da7eb0 --- /dev/null +++ b/src/Microsoft.AspNetCore.WebSockets/WebSocketsDependencyInjectionExtensions.cs @@ -0,0 +1,17 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; + +namespace Microsoft.AspNetCore.WebSockets +{ + public static class WebSocketsDependencyInjectionExtensions + { + public static IServiceCollection AddWebSockets(this IServiceCollection services, Action configure) + { + return services.Configure(configure); + } + } +} diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/AddWebSocketsTests.cs b/test/Microsoft.AspNetCore.WebSockets.Test/AddWebSocketsTests.cs new file mode 100644 index 0000000000..255d17f24f --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.Test/AddWebSocketsTests.cs @@ -0,0 +1,33 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using Xunit; + +namespace Microsoft.AspNetCore.WebSockets.Test +{ + public class AddWebSocketsTests + { + [Fact] + public void AddWebSocketsConfiguresOptions() + { + var serviceCollection = new ServiceCollection(); + + serviceCollection.AddWebSockets(o => + { + o.KeepAliveInterval = TimeSpan.FromSeconds(1000); + o.AllowedOrigins.Add("someString"); + }); + + var services = serviceCollection.BuildServiceProvider(); + var socketOptions = services.GetRequiredService>().Value; + + Assert.Equal(TimeSpan.FromSeconds(1000), socketOptions.KeepAliveInterval); + Assert.Single(socketOptions.AllowedOrigins); + Assert.Equal("someString", socketOptions.AllowedOrigins[0]); + } + } +} diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs index 77ec387c10..3e0b184f13 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs @@ -14,8 +14,9 @@ namespace Microsoft.AspNetCore.WebSockets.Test { public class KestrelWebSocketHelpers { - public static IDisposable CreateServer(ILoggerFactory loggerFactory, Func app) + public static IDisposable CreateServer(ILoggerFactory loggerFactory, Func app, Action configure = null) { + configure = configure ?? (o => { }); Action startup = builder => { builder.Use(async (ct, next) => @@ -48,7 +49,11 @@ namespace Microsoft.AspNetCore.WebSockets.Test config["server.urls"] = "http://localhost:54321"; var host = new WebHostBuilder() - .ConfigureServices(s => s.AddSingleton(loggerFactory)) + .ConfigureServices(s => + { + s.AddWebSockets(configure); + s.AddSingleton(loggerFactory); + }) .UseConfiguration(config) .UseKestrel() .Configure(startup) diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs index fd2fbc8d51..dc7ca9a79b 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs @@ -2,11 +2,15 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Net; +using System.Net.Http; using System.Net.WebSockets; using System.Text; using System.Threading; using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Testing.xunit; +using Microsoft.AspNetCore.WebSockets.Internal; using Microsoft.Extensions.Logging.Testing; using Xunit; using Xunit.Abstractions; @@ -558,5 +562,85 @@ namespace Microsoft.AspNetCore.WebSockets.Test } } } + + [Theory] + [InlineData(HttpStatusCode.OK, null)] + [InlineData(HttpStatusCode.Forbidden, "")] + [InlineData(HttpStatusCode.Forbidden, "http://e.com")] + [InlineData(HttpStatusCode.OK, "http://e.com", "http://example.com")] + [InlineData(HttpStatusCode.OK, "*")] + [InlineData(HttpStatusCode.OK, "http://e.com", "*")] + [InlineData(HttpStatusCode.OK, "http://ExAmPLE.cOm")] + public async Task OriginIsValidatedForWebSocketRequests(HttpStatusCode expectedCode, params string[] origins) + { + using (StartLog(out var loggerFactory)) + { + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, context => + { + Assert.True(context.WebSockets.IsWebSocketRequest); + return Task.CompletedTask; + }, o => + { + if (origins != null) + { + foreach (var origin in origins) + { + o.AllowedOrigins.Add(origin); + } + } + })) + { + using (var client = new HttpClient()) + { + var uri = new UriBuilder(ClientAddress); + uri.Scheme = "http"; + + // Craft a valid WebSocket Upgrade request + using (var request = new HttpRequestMessage(HttpMethod.Get, uri.ToString())) + { + request.Headers.Connection.Clear(); + request.Headers.Connection.Add("Upgrade"); + request.Headers.Upgrade.Add(new System.Net.Http.Headers.ProductHeaderValue("websocket")); + request.Headers.Add(Constants.Headers.SecWebSocketVersion, Constants.Headers.SupportedVersion); + // SecWebSocketKey required to be 16 bytes + request.Headers.Add(Constants.Headers.SecWebSocketKey, Convert.ToBase64String(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, Base64FormattingOptions.None)); + + request.Headers.Add("Origin", "http://example.com"); + + var response = await client.SendAsync(request); + Assert.Equal(expectedCode, response.StatusCode); + } + } + } + } + } + + [Fact] + public async Task OriginIsNotValidatedForNonWebSocketRequests() + { + using (StartLog(out var loggerFactory)) + { + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, context => + { + Assert.False(context.WebSockets.IsWebSocketRequest); + return Task.CompletedTask; + }, o => o.AllowedOrigins.Add("http://example.com"))) + { + using (var client = new HttpClient()) + { + var uri = new UriBuilder(ClientAddress); + uri.Scheme = "http"; + + using (var request = new HttpRequestMessage(HttpMethod.Get, uri.ToString())) + { + request.Headers.Add("Origin", "http://notexample.com"); + + var response = await client.SendAsync(request); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + } + } + } + } + } } } From bc13fd545050f972649c618e8cb6a8c5edcf1875 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Thu, 2 Aug 2018 16:45:29 -0700 Subject: [PATCH 431/453] Write websocket header directly to the repsonse headers (#253) --- .../Internal/HandshakeHelpers.cs | 11 ++++++----- .../WebSocketMiddleware.cs | 6 +----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.AspNetCore.WebSockets/Internal/HandshakeHelpers.cs b/src/Microsoft.AspNetCore.WebSockets/Internal/HandshakeHelpers.cs index a4bb0721ab..c001e9318e 100644 --- a/src/Microsoft.AspNetCore.WebSockets/Internal/HandshakeHelpers.cs +++ b/src/Microsoft.AspNetCore.WebSockets/Internal/HandshakeHelpers.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Security.Cryptography; using System.Text; +using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.WebSockets.Internal { @@ -63,14 +64,14 @@ namespace Microsoft.AspNetCore.WebSockets.Internal return validConnection && validUpgrade && validVersion && validKey; } - public static IEnumerable> GenerateResponseHeaders(string key, string subProtocol) + public static void GenerateResponseHeaders(string key, string subProtocol, IHeaderDictionary headers) { - yield return new KeyValuePair(Constants.Headers.Connection, Constants.Headers.ConnectionUpgrade); - yield return new KeyValuePair(Constants.Headers.Upgrade, Constants.Headers.UpgradeWebSocket); - yield return new KeyValuePair(Constants.Headers.SecWebSocketAccept, CreateResponseKey(key)); + headers[Constants.Headers.Connection] = Constants.Headers.ConnectionUpgrade; + headers[Constants.Headers.Upgrade] = Constants.Headers.UpgradeWebSocket; + headers[Constants.Headers.SecWebSocketAccept] = CreateResponseKey(key); if (!string.IsNullOrWhiteSpace(subProtocol)) { - yield return new KeyValuePair(Constants.Headers.SecWebSocketProtocol, subProtocol); + headers[Constants.Headers.SecWebSocketProtocol] = subProtocol; } } diff --git a/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs b/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs index 74f1e4f7d8..35e7f99019 100644 --- a/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs +++ b/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs @@ -155,11 +155,7 @@ namespace Microsoft.AspNetCore.WebSockets string key = string.Join(", ", _context.Request.Headers[Constants.Headers.SecWebSocketKey]); - var responseHeaders = HandshakeHelpers.GenerateResponseHeaders(key, subProtocol); - foreach (var headerPair in responseHeaders) - { - _context.Response.Headers[headerPair.Key] = headerPair.Value; - } + HandshakeHelpers.GenerateResponseHeaders(key, subProtocol, _context.Response.Headers); Stream opaqueTransport = await _upgradeFeature.UpgradeAsync(); // Sets status code to 101 From db35c4189b303f8c292b79bb0867ee4c9e8adf1c Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 5 Aug 2018 19:31:10 +0000 Subject: [PATCH 432/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 34 +++++++++++++++++----------------- korebuild-lock.txt | 4 ++-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index c1feca987e..38990621df 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,23 +3,23 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17102 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 0.6.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 + 2.2.0-preview1-20180731.1 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 0.6.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 2.0.9 2.1.2 2.2.0-preview1-26618-02 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 28cd6a5b03..b6efc7cfcb 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17102 -commithash:e7e2b5a97ca92cfc6acc4def534cb0901a6d1eb9 +version:2.2.0-preview1-20180731.1 +commithash:29fde58465439f4bb9df40830635ed758e063daf From 7e0ecf12e8cdb9c9457f5c76f76f35ba8ce9ee4a Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Mon, 6 Aug 2018 20:55:10 +0000 Subject: [PATCH 433/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 38990621df..a455254cf6 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,22 +4,22 @@ 2.2.0-preview1-20180731.1 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 0.6.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 0.6.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 2.0.9 2.1.2 2.2.0-preview1-26618-02 From ecadd7b7b1378f8722b868335cca0161e935d2ff Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 12 Aug 2018 19:34:18 +0000 Subject: [PATCH 434/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 34 +++++++++++++++++----------------- korebuild-lock.txt | 4 ++-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index a455254cf6..930f9c30d7 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,23 +3,23 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180731.1 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 0.6.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 + 2.2.0-preview1-20180807.2 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 0.6.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 2.0.9 2.1.2 2.2.0-preview1-26618-02 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index b6efc7cfcb..29a57027f1 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180731.1 -commithash:29fde58465439f4bb9df40830635ed758e063daf +version:2.2.0-preview1-20180807.2 +commithash:11495dbd236104434e08cb1152fcb58cf2a20923 From 42efbb40c4d39ebc26ebca876c6559d0354a6526 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 21 Aug 2018 13:32:34 -0700 Subject: [PATCH 435/453] Update package branding for 2.2.0-preview2 --- build/dependencies.props | 2 +- version.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 930f9c30d7..269f9d553f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -29,6 +29,6 @@ 2.3.1 2.4.0 - + diff --git a/version.props b/version.props index 44985cedb3..15637ba785 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.2.0 - preview1 + preview2 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 752f934a236e2e05b8ad985adfa540527643ae1a Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 23 Aug 2018 14:48:28 -0700 Subject: [PATCH 436/453] Fix flaky test Use dynamic port assignment to reduce address binding failures due to port collisions --- .../KestrelWebSocketHelpers.cs | 4 +- ...icrosoft.AspNetCore.WebSockets.Test.csproj | 1 + .../WebSocketMiddlewareTests.cs | 784 +++++++++--------- 3 files changed, 379 insertions(+), 410 deletions(-) diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs index 3e0b184f13..b41200f8b1 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs @@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test { public class KestrelWebSocketHelpers { - public static IDisposable CreateServer(ILoggerFactory loggerFactory, Func app, Action configure = null) + public static IDisposable CreateServer(ILoggerFactory loggerFactory, Func app, int clientPort, Action configure = null) { configure = configure ?? (o => { }); Action startup = builder => @@ -46,7 +46,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test var configBuilder = new ConfigurationBuilder(); configBuilder.AddInMemoryCollection(); var config = configBuilder.Build(); - config["server.urls"] = "http://localhost:54321"; + config["server.urls"] = $"http://localhost:{clientPort}"; var host = new WebHostBuilder() .ConfigureServices(s => diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj index 5e7f2eb67e..c906aa0f91 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj @@ -10,6 +10,7 @@ + diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs index dc7ca9a79b..1d179b34e2 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs @@ -8,12 +8,11 @@ using System.Net.WebSockets; using System.Text; using System.Threading; using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Server.IntegrationTesting.Common; using Microsoft.AspNetCore.Testing.xunit; using Microsoft.AspNetCore.WebSockets.Internal; using Microsoft.Extensions.Logging.Testing; using Xunit; -using Xunit.Abstractions; namespace Microsoft.AspNetCore.WebSockets.Test { @@ -27,27 +26,28 @@ namespace Microsoft.AspNetCore.WebSockets.Test #endif public class WebSocketMiddlewareTests : LoggedTest { - private static string ClientAddress = "ws://localhost:54321/"; + private readonly int ClientPort; + private readonly string ClientAddress; - public WebSocketMiddlewareTests(ITestOutputHelper output) : base(output) + public WebSocketMiddlewareTests() { + ClientPort = TestPortHelper.GetNextPort(); + ClientAddress = $"ws://localhost:{ClientPort}/"; } [ConditionalFact] public async Task Connect_Success() { - using (StartLog(out var loggerFactory)) + using (var server = KestrelWebSocketHelpers.CreateServer(LoggerFactory, async context => { - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + }, + ClientPort)) + { + using (var client = new ClientWebSocket()) { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - })) - { - using (var client = new ClientWebSocket()) - { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - } + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); } } } @@ -55,30 +55,28 @@ namespace Microsoft.AspNetCore.WebSockets.Test [ConditionalFact] public async Task NegotiateSubProtocol_Success() { - using (StartLog(out var loggerFactory)) + using (var server = KestrelWebSocketHelpers.CreateServer(LoggerFactory, async context => { - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + Assert.True(context.WebSockets.IsWebSocketRequest); + Assert.Equal("alpha, bravo, charlie", context.Request.Headers["Sec-WebSocket-Protocol"]); + var webSocket = await context.WebSockets.AcceptWebSocketAsync("Bravo"); + }, + ClientPort)) + { + using (var client = new ClientWebSocket()) { - Assert.True(context.WebSockets.IsWebSocketRequest); - Assert.Equal("alpha, bravo, charlie", context.Request.Headers["Sec-WebSocket-Protocol"]); - var webSocket = await context.WebSockets.AcceptWebSocketAsync("Bravo"); - })) - { - using (var client = new ClientWebSocket()) - { - client.Options.AddSubProtocol("alpha"); - client.Options.AddSubProtocol("bravo"); - client.Options.AddSubProtocol("charlie"); - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + client.Options.AddSubProtocol("alpha"); + client.Options.AddSubProtocol("bravo"); + client.Options.AddSubProtocol("charlie"); + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - // The Windows version of ClientWebSocket uses the casing from the header (Bravo) - // However, the Managed version seems match the header against the list generated by - // the AddSubProtocol calls (case-insensitively) and then use the version from - // that list as the value for SubProtocol. This is fine, but means we need to ignore case here. - // We could update our AddSubProtocols above to the same case but I think it's better to - // ensure this behavior is codified by this test. - Assert.Equal("Bravo", client.SubProtocol, ignoreCase: true); - } + // The Windows version of ClientWebSocket uses the casing from the header (Bravo) + // However, the Managed version seems match the header against the list generated by + // the AddSubProtocol calls (case-insensitively) and then use the version from + // that list as the value for SubProtocol. This is fine, but means we need to ignore case here. + // We could update our AddSubProtocols above to the same case but I think it's better to + // ensure this behavior is codified by this test. + Assert.Equal("Bravo", client.SubProtocol, ignoreCase: true); } } } @@ -86,26 +84,24 @@ namespace Microsoft.AspNetCore.WebSockets.Test [ConditionalFact] public async Task SendEmptyData_Success() { - using (StartLog(out var loggerFactory)) + using (var server = KestrelWebSocketHelpers.CreateServer(LoggerFactory, async context => { - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - var serverBuffer = new byte[0]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - })) + var serverBuffer = new byte[0]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + }, + ClientPort)) + { + using (var client = new ClientWebSocket()) { - using (var client = new ClientWebSocket()) - { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - var orriginalData = new byte[0]; - await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - } + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var orriginalData = new byte[0]; + await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); } } } @@ -113,27 +109,25 @@ namespace Microsoft.AspNetCore.WebSockets.Test [ConditionalFact] public async Task SendShortData_Success() { - using (StartLog(out var loggerFactory)) + var orriginalData = Encoding.UTF8.GetBytes("Hello World"); + using (var server = KestrelWebSocketHelpers.CreateServer(LoggerFactory, async context => { - var orriginalData = Encoding.UTF8.GetBytes("Hello World"); - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - var serverBuffer = new byte[orriginalData.Length]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(orriginalData.Length, result.Count); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - Assert.Equal(orriginalData, serverBuffer); - })) + var serverBuffer = new byte[orriginalData.Length]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, serverBuffer); + }, + ClientPort)) + { + using (var client = new ClientWebSocket()) { - using (var client = new ClientWebSocket()) - { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - } + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); } } } @@ -141,27 +135,25 @@ namespace Microsoft.AspNetCore.WebSockets.Test [ConditionalFact] public async Task SendMediumData_Success() { - using (StartLog(out var loggerFactory)) + var orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); + using (var server = KestrelWebSocketHelpers.CreateServer(LoggerFactory, async context => { - var orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - var serverBuffer = new byte[orriginalData.Length]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(orriginalData.Length, result.Count); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - Assert.Equal(orriginalData, serverBuffer); - })) + var serverBuffer = new byte[orriginalData.Length]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, serverBuffer); + }, + ClientPort)) + { + using (var client = new ClientWebSocket()) { - using (var client = new ClientWebSocket()) - { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - } + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); } } } @@ -169,39 +161,37 @@ namespace Microsoft.AspNetCore.WebSockets.Test [ConditionalFact] public async Task SendLongData_Success() { - using (StartLog(out var loggerFactory)) + var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); + using (var server = KestrelWebSocketHelpers.CreateServer(LoggerFactory, async context => { - var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + var serverBuffer = new byte[orriginalData.Length]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + int intermediateCount = result.Count; + Assert.False(result.EndOfMessage); + Assert.Equal(WebSocketMessageType.Text, result.MessageType); + + result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer, intermediateCount, orriginalData.Length - intermediateCount), CancellationToken.None); + intermediateCount += result.Count; + Assert.False(result.EndOfMessage); + Assert.Equal(WebSocketMessageType.Text, result.MessageType); + + result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer, intermediateCount, orriginalData.Length - intermediateCount), CancellationToken.None); + intermediateCount += result.Count; + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, intermediateCount); + Assert.Equal(WebSocketMessageType.Text, result.MessageType); + + Assert.Equal(orriginalData, serverBuffer); + }, + ClientPort)) + { + using (var client = new ClientWebSocket()) { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - var serverBuffer = new byte[orriginalData.Length]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - int intermediateCount = result.Count; - Assert.False(result.EndOfMessage); - Assert.Equal(WebSocketMessageType.Text, result.MessageType); - - result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer, intermediateCount, orriginalData.Length - intermediateCount), CancellationToken.None); - intermediateCount += result.Count; - Assert.False(result.EndOfMessage); - Assert.Equal(WebSocketMessageType.Text, result.MessageType); - - result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer, intermediateCount, orriginalData.Length - intermediateCount), CancellationToken.None); - intermediateCount += result.Count; - Assert.True(result.EndOfMessage); - Assert.Equal(orriginalData.Length, intermediateCount); - Assert.Equal(WebSocketMessageType.Text, result.MessageType); - - Assert.Equal(orriginalData, serverBuffer); - })) - { - using (var client = new ClientWebSocket()) - { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - } + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); } } } @@ -209,45 +199,43 @@ namespace Microsoft.AspNetCore.WebSockets.Test [ConditionalFact] public async Task SendFragmentedData_Success() { - using (StartLog(out var loggerFactory)) + var orriginalData = Encoding.UTF8.GetBytes("Hello World"); + using (var server = KestrelWebSocketHelpers.CreateServer(LoggerFactory, async context => { - var orriginalData = Encoding.UTF8.GetBytes("Hello World"); - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + var serverBuffer = new byte[orriginalData.Length]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.False(result.EndOfMessage); + Assert.Equal(2, result.Count); + int totalReceived = result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + result = await webSocket.ReceiveAsync( + new ArraySegment(serverBuffer, totalReceived, serverBuffer.Length - totalReceived), CancellationToken.None); + Assert.False(result.EndOfMessage); + Assert.Equal(2, result.Count); + totalReceived += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + result = await webSocket.ReceiveAsync( + new ArraySegment(serverBuffer, totalReceived, serverBuffer.Length - totalReceived), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(7, result.Count); + totalReceived += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + + Assert.Equal(orriginalData, serverBuffer); + }, + ClientPort)) + { + using (var client = new ClientWebSocket()) { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - var serverBuffer = new byte[orriginalData.Length]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.False(result.EndOfMessage); - Assert.Equal(2, result.Count); - int totalReceived = result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - - result = await webSocket.ReceiveAsync( - new ArraySegment(serverBuffer, totalReceived, serverBuffer.Length - totalReceived), CancellationToken.None); - Assert.False(result.EndOfMessage); - Assert.Equal(2, result.Count); - totalReceived += result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - - result = await webSocket.ReceiveAsync( - new ArraySegment(serverBuffer, totalReceived, serverBuffer.Length - totalReceived), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(7, result.Count); - totalReceived += result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - - Assert.Equal(orriginalData, serverBuffer); - })) - { - using (var client = new ClientWebSocket()) - { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - await client.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); - await client.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); - await client.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); - } + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); + await client.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); + await client.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); } } } @@ -255,27 +243,25 @@ namespace Microsoft.AspNetCore.WebSockets.Test [ConditionalFact] public async Task ReceiveShortData_Success() { - using (StartLog(out var loggerFactory)) + var orriginalData = Encoding.UTF8.GetBytes("Hello World"); + using (var server = KestrelWebSocketHelpers.CreateServer(LoggerFactory, async context => { - var orriginalData = Encoding.UTF8.GetBytes("Hello World"); - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - })) + await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + }, + ClientPort)) + { + using (var client = new ClientWebSocket()) { - using (var client = new ClientWebSocket()) - { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - var clientBuffer = new byte[orriginalData.Length]; - var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(orriginalData.Length, result.Count); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - Assert.Equal(orriginalData, clientBuffer); - } + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var clientBuffer = new byte[orriginalData.Length]; + var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, clientBuffer); } } } @@ -283,27 +269,25 @@ namespace Microsoft.AspNetCore.WebSockets.Test [ConditionalFact] public async Task ReceiveMediumData_Success() { - using (StartLog(out var loggerFactory)) + var orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); + using (var server = KestrelWebSocketHelpers.CreateServer(LoggerFactory, async context => { - var orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - })) + await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + }, + ClientPort)) + { + using (var client = new ClientWebSocket()) { - using (var client = new ClientWebSocket()) - { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - var clientBuffer = new byte[orriginalData.Length]; - var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(orriginalData.Length, result.Count); - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - Assert.Equal(orriginalData, clientBuffer); - } + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var clientBuffer = new byte[orriginalData.Length]; + var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(orriginalData.Length, result.Count); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, clientBuffer); } } } @@ -311,35 +295,33 @@ namespace Microsoft.AspNetCore.WebSockets.Test [ConditionalFact] public async Task ReceiveLongData() { - using (StartLog(out var loggerFactory)) + var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); + using (var server = KestrelWebSocketHelpers.CreateServer(LoggerFactory, async context => { - var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - })) + await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); + }, + ClientPort)) + { + using (var client = new ClientWebSocket()) { - using (var client = new ClientWebSocket()) + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var clientBuffer = new byte[orriginalData.Length]; + WebSocketReceiveResult result; + int receivedCount = 0; + do { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - var clientBuffer = new byte[orriginalData.Length]; - WebSocketReceiveResult result; - int receivedCount = 0; - do - { - result = await client.ReceiveAsync(new ArraySegment(clientBuffer, receivedCount, clientBuffer.Length - receivedCount), CancellationToken.None); - receivedCount += result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - } - while (!result.EndOfMessage); - - Assert.Equal(orriginalData.Length, receivedCount); + result = await client.ReceiveAsync(new ArraySegment(clientBuffer, receivedCount, clientBuffer.Length - receivedCount), CancellationToken.None); + receivedCount += result.Count; Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - Assert.Equal(orriginalData, clientBuffer); } + while (!result.EndOfMessage); + + Assert.Equal(orriginalData.Length, receivedCount); + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + Assert.Equal(orriginalData, clientBuffer); } } } @@ -347,45 +329,43 @@ namespace Microsoft.AspNetCore.WebSockets.Test [ConditionalFact] public async Task ReceiveFragmentedData_Success() { - using (StartLog(out var loggerFactory)) + var orriginalData = Encoding.UTF8.GetBytes("Hello World"); + using (var server = KestrelWebSocketHelpers.CreateServer(LoggerFactory, async context => { - var orriginalData = Encoding.UTF8.GetBytes("Hello World"); - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + await webSocket.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); + await webSocket.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); + await webSocket.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); + }, + ClientPort)) + { + using (var client = new ClientWebSocket()) { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var clientBuffer = new byte[orriginalData.Length]; + var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.False(result.EndOfMessage); + Assert.Equal(2, result.Count); + int totalReceived = result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - await webSocket.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); - await webSocket.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); - await webSocket.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); - })) - { - using (var client = new ClientWebSocket()) - { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - var clientBuffer = new byte[orriginalData.Length]; - var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); - Assert.False(result.EndOfMessage); - Assert.Equal(2, result.Count); - int totalReceived = result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + result = await client.ReceiveAsync( + new ArraySegment(clientBuffer, totalReceived, clientBuffer.Length - totalReceived), CancellationToken.None); + Assert.False(result.EndOfMessage); + Assert.Equal(2, result.Count); + totalReceived += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - result = await client.ReceiveAsync( - new ArraySegment(clientBuffer, totalReceived, clientBuffer.Length - totalReceived), CancellationToken.None); - Assert.False(result.EndOfMessage); - Assert.Equal(2, result.Count); - totalReceived += result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); + result = await client.ReceiveAsync( + new ArraySegment(clientBuffer, totalReceived, clientBuffer.Length - totalReceived), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(7, result.Count); + totalReceived += result.Count; + Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - result = await client.ReceiveAsync( - new ArraySegment(clientBuffer, totalReceived, clientBuffer.Length - totalReceived), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(7, result.Count); - totalReceived += result.Count; - Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - - Assert.Equal(orriginalData, clientBuffer); - } + Assert.Equal(orriginalData, clientBuffer); } } } @@ -393,30 +373,28 @@ namespace Microsoft.AspNetCore.WebSockets.Test [ConditionalFact] public async Task SendClose_Success() { - using (StartLog(out var loggerFactory)) + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(LoggerFactory, async context => { - string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - var serverBuffer = new byte[1024]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Close, result.MessageType); - Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); - Assert.Equal(closeDescription, result.CloseStatusDescription); - })) + var serverBuffer = new byte[1024]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + }, + ClientPort)) + { + using (var client = new ClientWebSocket()) { - using (var client = new ClientWebSocket()) - { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - await client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - Assert.Equal(WebSocketState.CloseSent, client.State); - } + Assert.Equal(WebSocketState.CloseSent, client.State); } } } @@ -424,30 +402,28 @@ namespace Microsoft.AspNetCore.WebSockets.Test [ConditionalFact] public async Task ReceiveClose_Success() { - using (StartLog(out var loggerFactory)) + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(LoggerFactory, async context => { - string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => - { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - })) + await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + }, + ClientPort)) + { + using (var client = new ClientWebSocket()) { - using (var client = new ClientWebSocket()) - { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - var clientBuffer = new byte[1024]; - var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Close, result.MessageType); - Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); - Assert.Equal(closeDescription, result.CloseStatusDescription); + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var clientBuffer = new byte[1024]; + var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); - Assert.Equal(WebSocketState.CloseReceived, client.State); - } + Assert.Equal(WebSocketState.CloseReceived, client.State); } } } @@ -455,32 +431,30 @@ namespace Microsoft.AspNetCore.WebSockets.Test [ConditionalFact] public async Task CloseFromOpen_Success() { - using (StartLog(out var loggerFactory)) + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(LoggerFactory, async context => { - string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + var serverBuffer = new byte[1024]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + + await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + }, + ClientPort)) + { + using (var client = new ClientWebSocket()) { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - var serverBuffer = new byte[1024]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Close, result.MessageType); - Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); - Assert.Equal(closeDescription, result.CloseStatusDescription); - - await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); - })) - { - using (var client = new ClientWebSocket()) - { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - await client.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - - Assert.Equal(WebSocketState.Closed, client.State); - } + Assert.Equal(WebSocketState.Closed, client.State); } } } @@ -488,34 +462,32 @@ namespace Microsoft.AspNetCore.WebSockets.Test [ConditionalFact] public async Task CloseFromCloseSent_Success() { - using (StartLog(out var loggerFactory)) + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(LoggerFactory, async context => { - string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + var serverBuffer = new byte[1024]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + + await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + }, + ClientPort)) + { + using (var client = new ClientWebSocket()) { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + Assert.Equal(WebSocketState.CloseSent, client.State); - var serverBuffer = new byte[1024]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Close, result.MessageType); - Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); - Assert.Equal(closeDescription, result.CloseStatusDescription); - - await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); - })) - { - using (var client = new ClientWebSocket()) - { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - await client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - Assert.Equal(WebSocketState.CloseSent, client.State); - - await client.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - Assert.Equal(WebSocketState.Closed, client.State); - } + await client.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + Assert.Equal(WebSocketState.Closed, client.State); } } } @@ -523,42 +495,40 @@ namespace Microsoft.AspNetCore.WebSockets.Test [ConditionalFact] public async Task CloseFromCloseReceived_Success() { - using (StartLog(out var loggerFactory)) + string closeDescription = "Test Closed"; + using (var server = KestrelWebSocketHelpers.CreateServer(LoggerFactory, async context => { - string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + Assert.True(context.WebSockets.IsWebSocketRequest); + var webSocket = await context.WebSockets.AcceptWebSocketAsync(); + + await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); + + var serverBuffer = new byte[1024]; + var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + Assert.True(result.EndOfMessage); + Assert.Equal(0, result.Count); + Assert.Equal(WebSocketMessageType.Close, result.MessageType); + Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); + Assert.Equal(closeDescription, result.CloseStatusDescription); + }, + ClientPort)) + { + using (var client = new ClientWebSocket()) { - Assert.True(context.WebSockets.IsWebSocketRequest); - var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - - await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - - var serverBuffer = new byte[1024]; - var result = await webSocket.ReceiveAsync(new ArraySegment(serverBuffer), CancellationToken.None); + await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + var clientBuffer = new byte[1024]; + var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); Assert.True(result.EndOfMessage); Assert.Equal(0, result.Count); Assert.Equal(WebSocketMessageType.Close, result.MessageType); Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); Assert.Equal(closeDescription, result.CloseStatusDescription); - })) - { - using (var client = new ClientWebSocket()) - { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); - var clientBuffer = new byte[1024]; - var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); - Assert.True(result.EndOfMessage); - Assert.Equal(0, result.Count); - Assert.Equal(WebSocketMessageType.Close, result.MessageType); - Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); - Assert.Equal(closeDescription, result.CloseStatusDescription); - Assert.Equal(WebSocketState.CloseReceived, client.State); + Assert.Equal(WebSocketState.CloseReceived, client.State); - await client.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + await client.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); - Assert.Equal(WebSocketState.Closed, client.State); - } + Assert.Equal(WebSocketState.Closed, client.State); } } } @@ -573,43 +543,42 @@ namespace Microsoft.AspNetCore.WebSockets.Test [InlineData(HttpStatusCode.OK, "http://ExAmPLE.cOm")] public async Task OriginIsValidatedForWebSocketRequests(HttpStatusCode expectedCode, params string[] origins) { - using (StartLog(out var loggerFactory)) + using (var server = KestrelWebSocketHelpers.CreateServer(LoggerFactory, context => { - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, context => + Assert.True(context.WebSockets.IsWebSocketRequest); + return Task.CompletedTask; + }, + ClientPort, + o => + { + if (origins != null) { - Assert.True(context.WebSockets.IsWebSocketRequest); - return Task.CompletedTask; - }, o => - { - if (origins != null) + foreach (var origin in origins) { - foreach (var origin in origins) - { - o.AllowedOrigins.Add(origin); - } + o.AllowedOrigins.Add(origin); } - })) + } + })) + { + using (var client = new HttpClient()) { - using (var client = new HttpClient()) + var uri = new UriBuilder(ClientAddress); + uri.Scheme = "http"; + + // Craft a valid WebSocket Upgrade request + using (var request = new HttpRequestMessage(HttpMethod.Get, uri.ToString())) { - var uri = new UriBuilder(ClientAddress); - uri.Scheme = "http"; + request.Headers.Connection.Clear(); + request.Headers.Connection.Add("Upgrade"); + request.Headers.Upgrade.Add(new System.Net.Http.Headers.ProductHeaderValue("websocket")); + request.Headers.Add(Constants.Headers.SecWebSocketVersion, Constants.Headers.SupportedVersion); + // SecWebSocketKey required to be 16 bytes + request.Headers.Add(Constants.Headers.SecWebSocketKey, Convert.ToBase64String(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, Base64FormattingOptions.None)); - // Craft a valid WebSocket Upgrade request - using (var request = new HttpRequestMessage(HttpMethod.Get, uri.ToString())) - { - request.Headers.Connection.Clear(); - request.Headers.Connection.Add("Upgrade"); - request.Headers.Upgrade.Add(new System.Net.Http.Headers.ProductHeaderValue("websocket")); - request.Headers.Add(Constants.Headers.SecWebSocketVersion, Constants.Headers.SupportedVersion); - // SecWebSocketKey required to be 16 bytes - request.Headers.Add(Constants.Headers.SecWebSocketKey, Convert.ToBase64String(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, Base64FormattingOptions.None)); + request.Headers.Add("Origin", "http://example.com"); - request.Headers.Add("Origin", "http://example.com"); - - var response = await client.SendAsync(request); - Assert.Equal(expectedCode, response.StatusCode); - } + var response = await client.SendAsync(request); + Assert.Equal(expectedCode, response.StatusCode); } } } @@ -618,26 +587,25 @@ namespace Microsoft.AspNetCore.WebSockets.Test [Fact] public async Task OriginIsNotValidatedForNonWebSocketRequests() { - using (StartLog(out var loggerFactory)) + using (var server = KestrelWebSocketHelpers.CreateServer(LoggerFactory, context => { - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, context => + Assert.False(context.WebSockets.IsWebSocketRequest); + return Task.CompletedTask; + }, + ClientPort, + o => o.AllowedOrigins.Add("http://example.com"))) + { + using (var client = new HttpClient()) { - Assert.False(context.WebSockets.IsWebSocketRequest); - return Task.CompletedTask; - }, o => o.AllowedOrigins.Add("http://example.com"))) - { - using (var client = new HttpClient()) + var uri = new UriBuilder(ClientAddress); + uri.Scheme = "http"; + + using (var request = new HttpRequestMessage(HttpMethod.Get, uri.ToString())) { - var uri = new UriBuilder(ClientAddress); - uri.Scheme = "http"; + request.Headers.Add("Origin", "http://notexample.com"); - using (var request = new HttpRequestMessage(HttpMethod.Get, uri.ToString())) - { - request.Headers.Add("Origin", "http://notexample.com"); - - var response = await client.SendAsync(request); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - } + var response = await client.SendAsync(request); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); } } } From 6d565e3a8a6ab74d27ce2e1bbc64e58ad242cd99 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 2 Sep 2018 12:30:50 -0700 Subject: [PATCH 437/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 34 +++++++++++++++++----------------- korebuild-lock.txt | 4 ++-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 269f9d553f..9c6e768637 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,23 +3,23 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180807.2 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 0.6.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 + 2.2.0-preview1-20180821.1 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 0.6.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 2.0.9 2.1.2 2.2.0-preview1-26618-02 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 29a57027f1..524a2323d0 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180807.2 -commithash:11495dbd236104434e08cb1152fcb58cf2a20923 +version:2.2.0-preview1-20180821.1 +commithash:c8d0cc52cd1abb697be24e288ffd54f8fae8bf17 From c88e5147da35c47902b378eefc6b11bb5f7dd46b Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 23 Aug 2018 14:48:28 -0700 Subject: [PATCH 438/453] Use dynamically chosen ports to avoid address binding collisions --- build/setup-wstest.sh | 16 ++-- .../KestrelWebSocketHelpers.cs | 4 +- ...icrosoft.AspNetCore.WebSockets.Test.csproj | 1 + .../WebSocketMiddlewareTests.cs | 86 ++++++++++++------- 4 files changed, 67 insertions(+), 40 deletions(-) diff --git a/build/setup-wstest.sh b/build/setup-wstest.sh index 2fb19c5bf3..11056f927a 100755 --- a/build/setup-wstest.sh +++ b/build/setup-wstest.sh @@ -6,18 +6,24 @@ if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install python fi -type -p python -python --version +PYTHON_CMD=python +if type -p python2.7 > /dev/null; then + echo "Using 'python2.7' executable because it's available." + PYTHON_CMD=python2.7 +fi + +$PYTHON_CMD --version # Install local virtualenv mkdir .python cd .python -curl -O https://pypi.python.org/packages/d4/0c/9840c08189e030873387a73b90ada981885010dd9aea134d6de30cd24cb8/virtualenv-15.1.0.tar.gz +curl -OL https://pypi.python.org/packages/d4/0c/9840c08189e030873387a73b90ada981885010dd9aea134d6de30cd24cb8/virtualenv-15.1.0.tar.gz + tar xf virtualenv-15.1.0.tar.gz cd .. # Make a virtualenv -python ./.python/virtualenv-15.1.0/virtualenv.py .virtualenv +$PYTHON_CMD ./.python/virtualenv-15.1.0/virtualenv.py .virtualenv .virtualenv/bin/python --version .virtualenv/bin/pip --version @@ -27,4 +33,4 @@ python ./.python/virtualenv-15.1.0/virtualenv.py .virtualenv # We're done. The travis config has already established the path to WSTest should be within the virtualenv. ls -l .virtualenv/bin -.virtualenv/bin/wstest --version \ No newline at end of file +.virtualenv/bin/wstest --version diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs index 77ec387c10..5a1b988d0a 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs @@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test { public class KestrelWebSocketHelpers { - public static IDisposable CreateServer(ILoggerFactory loggerFactory, Func app) + public static IDisposable CreateServer(ILoggerFactory loggerFactory, Func app, int port) { Action startup = builder => { @@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test var configBuilder = new ConfigurationBuilder(); configBuilder.AddInMemoryCollection(); var config = configBuilder.Build(); - config["server.urls"] = "http://localhost:54321"; + config["server.urls"] = $"http://localhost:{port}"; var host = new WebHostBuilder() .ConfigureServices(s => s.AddSingleton(loggerFactory)) diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj index 5e7f2eb67e..c906aa0f91 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj +++ b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj @@ -10,6 +10,7 @@ + diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs index e966aea6b4..c976a69cec 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs @@ -6,6 +6,7 @@ using System.Net.WebSockets; using System.Text; using System.Threading; using System.Threading.Tasks; +using Microsoft.AspNetCore.Server.IntegrationTesting.Common; using Microsoft.AspNetCore.Testing.xunit; using Microsoft.Extensions.Logging.Testing; using Xunit; @@ -23,10 +24,13 @@ namespace Microsoft.AspNetCore.WebSockets.Test #endif public class WebSocketMiddlewareTests : LoggedTest { - private static string ClientAddress = "ws://localhost:54321/"; + private readonly int Port; + private readonly string Address; public WebSocketMiddlewareTests(ITestOutputHelper output) : base(output) { + Port = TestUriHelper.GetNextPort(); + Address = $"ws://localhost:{Port}/"; } [ConditionalFact] @@ -38,11 +42,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test { Assert.True(context.WebSockets.IsWebSocketRequest); var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - })) + }, + Port)) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.ConnectAsync(new Uri(Address), CancellationToken.None); } } } @@ -58,14 +63,15 @@ namespace Microsoft.AspNetCore.WebSockets.Test Assert.True(context.WebSockets.IsWebSocketRequest); Assert.Equal("alpha, bravo, charlie", context.Request.Headers["Sec-WebSocket-Protocol"]); var webSocket = await context.WebSockets.AcceptWebSocketAsync("Bravo"); - })) + }, + Port)) { using (var client = new ClientWebSocket()) { client.Options.AddSubProtocol("alpha"); client.Options.AddSubProtocol("bravo"); client.Options.AddSubProtocol("charlie"); - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.ConnectAsync(new Uri(Address), CancellationToken.None); // The Windows version of ClientWebSocket uses the casing from the header (Bravo) // However, the Managed version seems match the header against the list generated by @@ -94,11 +100,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test Assert.True(result.EndOfMessage); Assert.Equal(0, result.Count); Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - })) + }, + Port)) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.ConnectAsync(new Uri(Address), CancellationToken.None); var orriginalData = new byte[0]; await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); } @@ -123,11 +130,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test Assert.Equal(orriginalData.Length, result.Count); Assert.Equal(WebSocketMessageType.Binary, result.MessageType); Assert.Equal(orriginalData, serverBuffer); - })) + }, + Port)) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.ConnectAsync(new Uri(Address), CancellationToken.None); await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); } } @@ -151,11 +159,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test Assert.Equal(orriginalData.Length, result.Count); Assert.Equal(WebSocketMessageType.Binary, result.MessageType); Assert.Equal(orriginalData, serverBuffer); - })) + }, + Port)) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.ConnectAsync(new Uri(Address), CancellationToken.None); await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); } } @@ -191,11 +200,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test Assert.Equal(WebSocketMessageType.Text, result.MessageType); Assert.Equal(orriginalData, serverBuffer); - })) + }, + Port)) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.ConnectAsync(new Uri(Address), CancellationToken.None); await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); } } @@ -235,11 +245,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test Assert.Equal(WebSocketMessageType.Binary, result.MessageType); Assert.Equal(orriginalData, serverBuffer); - })) + }, + Port)) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.ConnectAsync(new Uri(Address), CancellationToken.None); await client.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); await client.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); await client.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); @@ -260,11 +271,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test var webSocket = await context.WebSockets.AcceptWebSocketAsync(); await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - })) + }, + Port)) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.ConnectAsync(new Uri(Address), CancellationToken.None); var clientBuffer = new byte[orriginalData.Length]; var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); Assert.True(result.EndOfMessage); @@ -288,11 +300,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test var webSocket = await context.WebSockets.AcceptWebSocketAsync(); await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - })) + }, + Port)) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.ConnectAsync(new Uri(Address), CancellationToken.None); var clientBuffer = new byte[orriginalData.Length]; var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); Assert.True(result.EndOfMessage); @@ -316,11 +329,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test var webSocket = await context.WebSockets.AcceptWebSocketAsync(); await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - })) + }, + Port)) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.ConnectAsync(new Uri(Address), CancellationToken.None); var clientBuffer = new byte[orriginalData.Length]; WebSocketReceiveResult result; int receivedCount = 0; @@ -354,11 +368,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test await webSocket.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); await webSocket.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); await webSocket.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); - })) + }, + Port)) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.ConnectAsync(new Uri(Address), CancellationToken.None); var clientBuffer = new byte[orriginalData.Length]; var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); Assert.False(result.EndOfMessage); @@ -404,11 +419,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test Assert.Equal(WebSocketMessageType.Close, result.MessageType); Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); Assert.Equal(closeDescription, result.CloseStatusDescription); - })) + }, + Port)) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.ConnectAsync(new Uri(Address), CancellationToken.None); await client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); Assert.Equal(WebSocketState.CloseSent, client.State); @@ -429,11 +445,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test var webSocket = await context.WebSockets.AcceptWebSocketAsync(); await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - })) + }, + Port)) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.ConnectAsync(new Uri(Address), CancellationToken.None); var clientBuffer = new byte[1024]; var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); Assert.True(result.EndOfMessage); @@ -468,11 +485,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test Assert.Equal(closeDescription, result.CloseStatusDescription); await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); - })) + }, + Port)) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.ConnectAsync(new Uri(Address), CancellationToken.None); await client.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); Assert.Equal(WebSocketState.Closed, client.State); @@ -501,11 +519,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test Assert.Equal(closeDescription, result.CloseStatusDescription); await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); - })) + }, + Port)) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.ConnectAsync(new Uri(Address), CancellationToken.None); await client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); Assert.Equal(WebSocketState.CloseSent, client.State); @@ -536,11 +555,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test Assert.Equal(WebSocketMessageType.Close, result.MessageType); Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); Assert.Equal(closeDescription, result.CloseStatusDescription); - })) + }, + Port)) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None); + await client.ConnectAsync(new Uri(Address), CancellationToken.None); var clientBuffer = new byte[1024]; var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); Assert.True(result.EndOfMessage); From a00eb4fa82843a0ff9f15bb78cf1aeb2d4005e28 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Wed, 5 Sep 2018 16:36:42 -0700 Subject: [PATCH 439/453] Update branding to 2.2.0-preview3 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 15637ba785..704cac087b 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.2.0 - preview2 + preview3 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 17f216a325cc9127066355c3424689007433d69c Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 9 Sep 2018 12:33:23 -0700 Subject: [PATCH 440/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 38 +++++++++++++++++++------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 9c6e768637..d7157de626 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,26 +3,26 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180821.1 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 0.6.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 + 2.2.0-preview1-20180907.8 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 0.6.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 2.0.9 - 2.1.2 - 2.2.0-preview1-26618-02 + 2.1.3 + 2.2.0-preview2-26905-02 15.6.1 2.0.3 4.5.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 524a2323d0..552300b0ce 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180821.1 -commithash:c8d0cc52cd1abb697be24e288ffd54f8fae8bf17 +version:2.2.0-preview1-20180907.8 +commithash:078918eb5c1f176ee1da351c584fb4a4d7491aa0 From 35000369eb238d4620b351a97ab3f351bebef119 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 16 Sep 2018 12:32:04 -0700 Subject: [PATCH 441/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 34 +++++++++++++++++----------------- korebuild-lock.txt | 4 ++-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index d7157de626..f54d179342 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,23 +3,23 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180907.8 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 0.6.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 + 2.2.0-preview1-20180911.1 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 0.6.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 2.0.9 2.1.3 2.2.0-preview2-26905-02 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 552300b0ce..1090ad6a92 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180907.8 -commithash:078918eb5c1f176ee1da351c584fb4a4d7491aa0 +version:2.2.0-preview1-20180911.1 +commithash:ddfecdfc6e8e4859db5a0daea578070b862aac65 From 0bf7c450748f47842562e75209b2239e0b335d1c Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 23 Sep 2018 19:35:26 +0000 Subject: [PATCH 442/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 34 +++++++++++++++++----------------- korebuild-lock.txt | 4 ++-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index f54d179342..0b6fa977b2 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,23 +3,23 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180911.1 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 0.6.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 + 2.2.0-preview1-20180918.1 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 0.6.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 2.0.9 2.1.3 2.2.0-preview2-26905-02 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 1090ad6a92..8491de70e6 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180911.1 -commithash:ddfecdfc6e8e4859db5a0daea578070b862aac65 +version:2.2.0-preview1-20180918.1 +commithash:ad5e3fc53442741a0dd49bce437d2ac72f4b5800 From 67f2c3149efd03511794ed64726a196ee0b1ab36 Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 28 Sep 2018 11:59:48 -0700 Subject: [PATCH 443/453] Use port 0 to avoid port collisions during tests --- .../IWebHostPortExtensions.cs | 30 +++++ .../KestrelWebSocketHelpers.cs | 5 +- .../WebSocketMiddlewareTests.cs | 121 +++++++----------- 3 files changed, 82 insertions(+), 74 deletions(-) create mode 100644 test/Microsoft.AspNetCore.WebSockets.Test/IWebHostPortExtensions.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/IWebHostPortExtensions.cs b/test/Microsoft.AspNetCore.WebSockets.Test/IWebHostPortExtensions.cs new file mode 100644 index 0000000000..d3b53681f4 --- /dev/null +++ b/test/Microsoft.AspNetCore.WebSockets.Test/IWebHostPortExtensions.cs @@ -0,0 +1,30 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.AspNetCore.Hosting.Server.Features; + +namespace Microsoft.AspNetCore.Hosting +{ + public static class IWebHostPortExtensions + { + public static int GetPort(this IWebHost host) + { + return host.GetPorts().First(); + } + + public static IEnumerable GetPorts(this IWebHost host) + { + return host.GetUris() + .Select(u => u.Port); + } + + public static IEnumerable GetUris(this IWebHost host) + { + return host.ServerFeatures.Get().Addresses + .Select(a => new Uri(a)); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs index 5a1b988d0a..9b2d31f125 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs @@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test { public class KestrelWebSocketHelpers { - public static IDisposable CreateServer(ILoggerFactory loggerFactory, Func app, int port) + public static IDisposable CreateServer(ILoggerFactory loggerFactory, out int port, Func app) { Action startup = builder => { @@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test var configBuilder = new ConfigurationBuilder(); configBuilder.AddInMemoryCollection(); var config = configBuilder.Build(); - config["server.urls"] = $"http://localhost:{port}"; + config["server.urls"] = $"http://127.0.0.1:0"; var host = new WebHostBuilder() .ConfigureServices(s => s.AddSingleton(loggerFactory)) @@ -55,6 +55,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test .Build(); host.Start(); + port = host.GetPort(); return host; } diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs index c976a69cec..9cf3445ab6 100644 --- a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs @@ -24,30 +24,22 @@ namespace Microsoft.AspNetCore.WebSockets.Test #endif public class WebSocketMiddlewareTests : LoggedTest { - private readonly int Port; - private readonly string Address; - - public WebSocketMiddlewareTests(ITestOutputHelper output) : base(output) - { - Port = TestUriHelper.GetNextPort(); - Address = $"ws://localhost:{Port}/"; - } + public WebSocketMiddlewareTests(ITestOutputHelper output) : base(output) { } [ConditionalFact] public async Task Connect_Success() { using (StartLog(out var loggerFactory)) { - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, out var port, async context => { Assert.True(context.WebSockets.IsWebSocketRequest); var webSocket = await context.WebSockets.AcceptWebSocketAsync(); - }, - Port)) + })) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(Address), CancellationToken.None); + await client.ConnectAsync(new Uri($"ws://localhost:{port}/"), CancellationToken.None); } } } @@ -58,20 +50,19 @@ namespace Microsoft.AspNetCore.WebSockets.Test { using (StartLog(out var loggerFactory)) { - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, out var port, async context => { Assert.True(context.WebSockets.IsWebSocketRequest); Assert.Equal("alpha, bravo, charlie", context.Request.Headers["Sec-WebSocket-Protocol"]); var webSocket = await context.WebSockets.AcceptWebSocketAsync("Bravo"); - }, - Port)) + })) { using (var client = new ClientWebSocket()) { client.Options.AddSubProtocol("alpha"); client.Options.AddSubProtocol("bravo"); client.Options.AddSubProtocol("charlie"); - await client.ConnectAsync(new Uri(Address), CancellationToken.None); + await client.ConnectAsync(new Uri($"ws://localhost:{port}/"), CancellationToken.None); // The Windows version of ClientWebSocket uses the casing from the header (Bravo) // However, the Managed version seems match the header against the list generated by @@ -90,7 +81,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test { using (StartLog(out var loggerFactory)) { - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, out var port, async context => { Assert.True(context.WebSockets.IsWebSocketRequest); var webSocket = await context.WebSockets.AcceptWebSocketAsync(); @@ -100,12 +91,11 @@ namespace Microsoft.AspNetCore.WebSockets.Test Assert.True(result.EndOfMessage); Assert.Equal(0, result.Count); Assert.Equal(WebSocketMessageType.Binary, result.MessageType); - }, - Port)) + })) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(Address), CancellationToken.None); + await client.ConnectAsync(new Uri($"ws://localhost:{port}/"), CancellationToken.None); var orriginalData = new byte[0]; await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); } @@ -119,7 +109,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test using (StartLog(out var loggerFactory)) { var orriginalData = Encoding.UTF8.GetBytes("Hello World"); - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, out var port, async context => { Assert.True(context.WebSockets.IsWebSocketRequest); var webSocket = await context.WebSockets.AcceptWebSocketAsync(); @@ -130,12 +120,11 @@ namespace Microsoft.AspNetCore.WebSockets.Test Assert.Equal(orriginalData.Length, result.Count); Assert.Equal(WebSocketMessageType.Binary, result.MessageType); Assert.Equal(orriginalData, serverBuffer); - }, - Port)) + })) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(Address), CancellationToken.None); + await client.ConnectAsync(new Uri($"ws://localhost:{port}/"), CancellationToken.None); await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); } } @@ -148,7 +137,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test using (StartLog(out var loggerFactory)) { var orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, out var port, async context => { Assert.True(context.WebSockets.IsWebSocketRequest); var webSocket = await context.WebSockets.AcceptWebSocketAsync(); @@ -159,12 +148,11 @@ namespace Microsoft.AspNetCore.WebSockets.Test Assert.Equal(orriginalData.Length, result.Count); Assert.Equal(WebSocketMessageType.Binary, result.MessageType); Assert.Equal(orriginalData, serverBuffer); - }, - Port)) + })) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(Address), CancellationToken.None); + await client.ConnectAsync(new Uri($"ws://localhost:{port}/"), CancellationToken.None); await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); } } @@ -177,7 +165,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test using (StartLog(out var loggerFactory)) { var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, out var port, async context => { Assert.True(context.WebSockets.IsWebSocketRequest); var webSocket = await context.WebSockets.AcceptWebSocketAsync(); @@ -200,12 +188,11 @@ namespace Microsoft.AspNetCore.WebSockets.Test Assert.Equal(WebSocketMessageType.Text, result.MessageType); Assert.Equal(orriginalData, serverBuffer); - }, - Port)) + })) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(Address), CancellationToken.None); + await client.ConnectAsync(new Uri($"ws://localhost:{port}/"), CancellationToken.None); await client.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); } } @@ -218,7 +205,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test using (StartLog(out var loggerFactory)) { var orriginalData = Encoding.UTF8.GetBytes("Hello World"); - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, out var port, async context => { Assert.True(context.WebSockets.IsWebSocketRequest); var webSocket = await context.WebSockets.AcceptWebSocketAsync(); @@ -245,12 +232,11 @@ namespace Microsoft.AspNetCore.WebSockets.Test Assert.Equal(WebSocketMessageType.Binary, result.MessageType); Assert.Equal(orriginalData, serverBuffer); - }, - Port)) + })) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(Address), CancellationToken.None); + await client.ConnectAsync(new Uri($"ws://localhost:{port}/"), CancellationToken.None); await client.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); await client.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); await client.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); @@ -265,18 +251,17 @@ namespace Microsoft.AspNetCore.WebSockets.Test using (StartLog(out var loggerFactory)) { var orriginalData = Encoding.UTF8.GetBytes("Hello World"); - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, out var port, async context => { Assert.True(context.WebSockets.IsWebSocketRequest); var webSocket = await context.WebSockets.AcceptWebSocketAsync(); await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - }, - Port)) + })) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(Address), CancellationToken.None); + await client.ConnectAsync(new Uri($"ws://localhost:{port}/"), CancellationToken.None); var clientBuffer = new byte[orriginalData.Length]; var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); Assert.True(result.EndOfMessage); @@ -294,18 +279,17 @@ namespace Microsoft.AspNetCore.WebSockets.Test using (StartLog(out var loggerFactory)) { var orriginalData = Encoding.UTF8.GetBytes(new string('a', 130)); - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, out var port, async context => { Assert.True(context.WebSockets.IsWebSocketRequest); var webSocket = await context.WebSockets.AcceptWebSocketAsync(); await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - }, - Port)) + })) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(Address), CancellationToken.None); + await client.ConnectAsync(new Uri($"ws://localhost:{port}/"), CancellationToken.None); var clientBuffer = new byte[orriginalData.Length]; var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); Assert.True(result.EndOfMessage); @@ -323,18 +307,17 @@ namespace Microsoft.AspNetCore.WebSockets.Test using (StartLog(out var loggerFactory)) { var orriginalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, out var port, async context => { Assert.True(context.WebSockets.IsWebSocketRequest); var webSocket = await context.WebSockets.AcceptWebSocketAsync(); await webSocket.SendAsync(new ArraySegment(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None); - }, - Port)) + })) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(Address), CancellationToken.None); + await client.ConnectAsync(new Uri($"ws://localhost:{port}/"), CancellationToken.None); var clientBuffer = new byte[orriginalData.Length]; WebSocketReceiveResult result; int receivedCount = 0; @@ -360,7 +343,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test using (StartLog(out var loggerFactory)) { var orriginalData = Encoding.UTF8.GetBytes("Hello World"); - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, out var port, async context => { Assert.True(context.WebSockets.IsWebSocketRequest); var webSocket = await context.WebSockets.AcceptWebSocketAsync(); @@ -368,12 +351,11 @@ namespace Microsoft.AspNetCore.WebSockets.Test await webSocket.SendAsync(new ArraySegment(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None); await webSocket.SendAsync(new ArraySegment(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None); await webSocket.SendAsync(new ArraySegment(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None); - }, - Port)) + })) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(Address), CancellationToken.None); + await client.ConnectAsync(new Uri($"ws://localhost:{port}/"), CancellationToken.None); var clientBuffer = new byte[orriginalData.Length]; var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); Assert.False(result.EndOfMessage); @@ -407,7 +389,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test using (StartLog(out var loggerFactory)) { string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, out var port, async context => { Assert.True(context.WebSockets.IsWebSocketRequest); var webSocket = await context.WebSockets.AcceptWebSocketAsync(); @@ -419,12 +401,11 @@ namespace Microsoft.AspNetCore.WebSockets.Test Assert.Equal(WebSocketMessageType.Close, result.MessageType); Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); Assert.Equal(closeDescription, result.CloseStatusDescription); - }, - Port)) + })) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(Address), CancellationToken.None); + await client.ConnectAsync(new Uri($"ws://localhost:{port}/"), CancellationToken.None); await client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); Assert.Equal(WebSocketState.CloseSent, client.State); @@ -439,18 +420,17 @@ namespace Microsoft.AspNetCore.WebSockets.Test using (StartLog(out var loggerFactory)) { string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, out var port, async context => { Assert.True(context.WebSockets.IsWebSocketRequest); var webSocket = await context.WebSockets.AcceptWebSocketAsync(); await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); - }, - Port)) + })) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(Address), CancellationToken.None); + await client.ConnectAsync(new Uri($"ws://localhost:{port}/"), CancellationToken.None); var clientBuffer = new byte[1024]; var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); Assert.True(result.EndOfMessage); @@ -471,7 +451,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test using (StartLog(out var loggerFactory)) { string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, out var port, async context => { Assert.True(context.WebSockets.IsWebSocketRequest); var webSocket = await context.WebSockets.AcceptWebSocketAsync(); @@ -485,12 +465,11 @@ namespace Microsoft.AspNetCore.WebSockets.Test Assert.Equal(closeDescription, result.CloseStatusDescription); await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); - }, - Port)) + })) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(Address), CancellationToken.None); + await client.ConnectAsync(new Uri($"ws://localhost:{port}/"), CancellationToken.None); await client.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); Assert.Equal(WebSocketState.Closed, client.State); @@ -505,7 +484,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test using (StartLog(out var loggerFactory)) { string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, out var port, async context => { Assert.True(context.WebSockets.IsWebSocketRequest); var webSocket = await context.WebSockets.AcceptWebSocketAsync(); @@ -519,12 +498,11 @@ namespace Microsoft.AspNetCore.WebSockets.Test Assert.Equal(closeDescription, result.CloseStatusDescription); await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); - }, - Port)) + })) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(Address), CancellationToken.None); + await client.ConnectAsync(new Uri($"ws://localhost:{port}/"), CancellationToken.None); await client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None); Assert.Equal(WebSocketState.CloseSent, client.State); @@ -541,7 +519,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test using (StartLog(out var loggerFactory)) { string closeDescription = "Test Closed"; - using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, async context => + using (var server = KestrelWebSocketHelpers.CreateServer(loggerFactory, out var port, async context => { Assert.True(context.WebSockets.IsWebSocketRequest); var webSocket = await context.WebSockets.AcceptWebSocketAsync(); @@ -555,12 +533,11 @@ namespace Microsoft.AspNetCore.WebSockets.Test Assert.Equal(WebSocketMessageType.Close, result.MessageType); Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus); Assert.Equal(closeDescription, result.CloseStatusDescription); - }, - Port)) + })) { using (var client = new ClientWebSocket()) { - await client.ConnectAsync(new Uri(Address), CancellationToken.None); + await client.ConnectAsync(new Uri($"ws://localhost:{port}/"), CancellationToken.None); var clientBuffer = new byte[1024]; var result = await client.ReceiveAsync(new ArraySegment(clientBuffer), CancellationToken.None); Assert.True(result.EndOfMessage); From 488d30fa158463a36b718daedef9aa499900154f Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Fri, 28 Sep 2018 17:10:41 -0700 Subject: [PATCH 444/453] automated: bulk infrastructure updates. Update bootstrapper scripts and remove unnecessary signing properties --- Directory.Build.props | 3 --- run.ps1 | 6 +++--- run.sh | 10 +++++----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 5a9460fb37..08744cc42e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -14,9 +14,6 @@ $(MSBuildThisFileDirectory) $(MSBuildThisFileDirectory)build\Key.snk true - Microsoft - MicrosoftNuGet - true true diff --git a/run.ps1 b/run.ps1 index 3b27382468..34604c7175 100644 --- a/run.ps1 +++ b/run.ps1 @@ -52,8 +52,8 @@ in the file are overridden by command line parameters. Example config file: ```json { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev", + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/master/tools/korebuild.schema.json", + "channel": "master", "toolsSource": "https://aspnetcore.blob.core.windows.net/buildtools" } ``` @@ -192,7 +192,7 @@ if (!$DotNetHome) { else { Join-Path $PSScriptRoot '.dotnet'} } -if (!$Channel) { $Channel = 'dev' } +if (!$Channel) { $Channel = 'master' } if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' } # Execute diff --git a/run.sh b/run.sh index 02aac15874..4c1fed5646 100755 --- a/run.sh +++ b/run.sh @@ -220,7 +220,7 @@ if [ -f "$config_file" ]; then config_channel="$(jq -r 'select(.channel!=null) | .channel' "$config_file")" config_tools_source="$(jq -r 'select(.toolsSource!=null) | .toolsSource' "$config_file")" else - _error "$config_file contains invalid JSON." + __error "$config_file contains invalid JSON." exit 1 fi elif __machine_has python ; then @@ -228,7 +228,7 @@ if [ -f "$config_file" ]; then config_channel="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')")" config_tools_source="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")" else - _error "$config_file contains invalid JSON." + __error "$config_file contains invalid JSON." exit 1 fi elif __machine_has python3 ; then @@ -236,11 +236,11 @@ if [ -f "$config_file" ]; then config_channel="$(python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')")" config_tools_source="$(python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")" else - _error "$config_file contains invalid JSON." + __error "$config_file contains invalid JSON." exit 1 fi else - _error 'Missing required command: jq or python. Could not parse the JSON file.' + __error 'Missing required command: jq or python. Could not parse the JSON file.' exit 1 fi @@ -248,7 +248,7 @@ if [ -f "$config_file" ]; then [ ! -z "${config_tools_source:-}" ] && tools_source="$config_tools_source" fi -[ -z "$channel" ] && channel='dev' +[ -z "$channel" ] && channel='master' [ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' get_korebuild From c639a462a1393a0e51f9a8835bfe21f62954cd18 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 30 Sep 2018 12:35:27 -0700 Subject: [PATCH 445/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 36 ++++++++++++++++++------------------ korebuild-lock.txt | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 0b6fa977b2..7f72d37f53 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,26 +3,26 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180918.1 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 0.6.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 + 2.2.0-preview1-20180928.5 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 0.6.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 2.0.9 2.1.3 - 2.2.0-preview2-26905-02 + 2.2.0-preview3-26927-02 15.6.1 2.0.3 4.5.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 8491de70e6..0507680073 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180918.1 -commithash:ad5e3fc53442741a0dd49bce437d2ac72f4b5800 +version:2.2.0-preview1-20180928.5 +commithash:43faa29f679f47b88689d645b39e6be5e0055d70 From 56f90124026b1da5f260b3c1a55f75fab7ecbb68 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 7 Oct 2018 19:37:05 +0000 Subject: [PATCH 446/453] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 36 ++++++++++++++++++------------------ korebuild-lock.txt | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 7f72d37f53..6a1e9ab585 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,26 +3,26 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180928.5 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 0.6.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 + 2.2.0-preview2-20181004.6 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 0.6.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 2.0.9 2.1.3 - 2.2.0-preview3-26927-02 + 2.2.0-preview3-27001-02 15.6.1 2.0.3 4.5.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 0507680073..3e92dd5543 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180928.5 -commithash:43faa29f679f47b88689d645b39e6be5e0055d70 +version:2.2.0-preview2-20181004.6 +commithash:c04c4b2f5018632647f96210ab01876661302dac From a036f920b8f32446e3524d3eb5a10fbd02f2a37c Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 16 Oct 2018 12:48:21 -0700 Subject: [PATCH 447/453] Update package branding for 2.2 RTM --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 704cac087b..4889a26987 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.2.0 - preview3 + rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From c2e4a74f7d38f34522c379e55cd8edd75bf82930 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 17 Oct 2018 10:24:18 -0700 Subject: [PATCH 448/453] React to renaming this repo from Universe to AspNetCore --- .azure/pipelines/fast-pr-validation.yml | 2 +- Directory.Build.props | 2 +- README.md | 6 +++--- build/PackageArchive.targets | 2 +- build/RepositoryBuild.targets | 2 +- .../lineups/Internal.AspNetCore.Universe.Lineup.nuspec | 2 +- build/repo.beforecommon.props | 2 +- build/repo.props | 2 +- build/repo.targets | 8 ++++---- dockerbuild.sh | 2 +- docs/Submodules.md | 10 +++++----- scripts/GenerateTags.ps1 | 10 +++++----- scripts/UpdateRepos.ps1 | 6 +++--- scripts/common.psm1 | 2 +- 14 files changed, 29 insertions(+), 29 deletions(-) diff --git a/.azure/pipelines/fast-pr-validation.yml b/.azure/pipelines/fast-pr-validation.yml index e91c970c6b..863270dc71 100644 --- a/.azure/pipelines/fast-pr-validation.yml +++ b/.azure/pipelines/fast-pr-validation.yml @@ -14,7 +14,7 @@ resources: phases: - template: .vsts-pipelines/templates/project-ci.yml@buildtools parameters: - buildArgs: "/t:CheckUniverse" + buildArgs: "/t:FastCheck" - phase: DataProtection queue: Hosted VS2017 steps: diff --git a/Directory.Build.props b/Directory.Build.props index 4316633c71..7cfecbbe60 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,7 +4,7 @@ Microsoft ASP.NET Core $(MSBuildThisFileDirectory) - https://github.com/aspnet/Universe + https://github.com/aspnet/AspNetCore git $(MSBuildThisFileDirectory)eng\AspNetCore.snk true diff --git a/README.md b/README.md index 9bc4f71e9a..4208c2744f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Universe +ASP.NET Core ======== Build infrastructure used to produce the whole ASP.NET Core stack. @@ -87,8 +87,8 @@ RedHat/Fedora (x64) | [Installer (rpm)][redhat-x64-rpm] ## Building from source ``` -git clone --recursive https://github.com/aspnet/Universe.git -cd Universe +git clone --recursive https://github.com/aspnet/AspNetCore.git +cd AspNetCore ./build.cmd ``` diff --git a/build/PackageArchive.targets b/build/PackageArchive.targets index bb892d102c..5ba1cadcf8 100644 --- a/build/PackageArchive.targets +++ b/build/PackageArchive.targets @@ -1,5 +1,5 @@ - + diff --git a/build/RepositoryBuild.targets b/build/RepositoryBuild.targets index a97112a561..428b35b65d 100644 --- a/build/RepositoryBuild.targets +++ b/build/RepositoryBuild.targets @@ -96,7 +96,7 @@ - + diff --git a/build/lineups/Internal.AspNetCore.Universe.Lineup.nuspec b/build/lineups/Internal.AspNetCore.Universe.Lineup.nuspec index cc35b59699..1209016b04 100644 --- a/build/lineups/Internal.AspNetCore.Universe.Lineup.nuspec +++ b/build/lineups/Internal.AspNetCore.Universe.Lineup.nuspec @@ -4,7 +4,7 @@ Internal.AspNetCore.Universe.Lineup $version$ Microsoft - This package used to unify ASP.NET Core package versions across all Universe repos. Internal use only. + This package used to unify ASP.NET Core package versions across all ASP.NET Core repos. Internal use only. diff --git a/build/repo.beforecommon.props b/build/repo.beforecommon.props index 0550358981..f470e9b2a6 100644 --- a/build/repo.beforecommon.props +++ b/build/repo.beforecommon.props @@ -2,7 +2,7 @@ true diff --git a/build/repo.props b/build/repo.props index 5650750c00..3c7b1970a2 100644 --- a/build/repo.props +++ b/build/repo.props @@ -43,7 +43,7 @@ - + $(IntermediateDir)branding.g.props PreinstallBundledPackages;SetTeamCityBuildNumberToVersion;$(PrepareDependsOn);VerifyPackageArtifactConfig;VerifyExternalDependencyConfig;PrepareOutputPaths - $(CleanDependsOn);CleanArtifacts;CleanUniverseArtifacts + $(CleanDependsOn);CleanArtifacts;CleanRepoArtifacts $(RestoreDependsOn);InstallDotNet $(CompileDependsOn);BuildRepositories $(PackageDependsOn);BuildMetapackages;CheckExpectedPackagesExist @@ -78,7 +78,7 @@ - + - + @@ -273,7 +273,7 @@ Condition=" @(ExternalDependency->WithMetadataValue('Version', '')->Count()) != 0 " /> - diff --git a/dockerbuild.sh b/dockerbuild.sh index d401522921..ccc55b8852 100755 --- a/dockerbuild.sh +++ b/dockerbuild.sh @@ -88,7 +88,7 @@ if ! __machine_has docker; then fi dockerfile="$DIR/build/docker/$image.Dockerfile" -tagname="universe-build-$image" +tagname="aspnetcore-build-$image" docker build "$(dirname "$dockerfile")" \ --build-arg "USER=$(whoami)" \ diff --git a/docs/Submodules.md b/docs/Submodules.md index 501e7884d3..8d24c40ff5 100644 --- a/docs/Submodules.md +++ b/docs/Submodules.md @@ -9,10 +9,10 @@ For full information, see the [official docs for git submodules](https://git-scm ## Fundamental concept -The parent repo (aspnet/Universe) stores two pieces of info about each submodule. +The parent repo (aspnet/AspNetCore) stores two pieces of info about each submodule. 1. Where to clone the submodule from. This is stored in the .gitmodules file -2. The commit hash of the submodule to use. +2. The commit hash of the submodule to use. This means you cannot commit a submodule's branch or a tag to the parent repo. Other info may appear in the .gitmodules file, but it is only used when attempting to @@ -22,7 +22,7 @@ Other info may appear in the .gitmodules file, but it is only used when attempti By default, submodules will not be present. Use `--recursive` to clone all submodules. - git clone https://github.com/aspnet/Universe.git --recursive + git clone https://github.com/aspnet/AspNetCore.git --recursive If you have already cloned, run this to initialize all submodules. @@ -53,7 +53,7 @@ Updating all submodules to newer versions can be done like this. Updating just one subumodule. git submodule update --remote modules/EntityFrameworkCore/ - + This uses the remote url and branch info configuration stored in .gitmodules to pull new commits. This does not guarantee the commit is going to be a fast-forward commit. @@ -72,7 +72,7 @@ that contains the new commit. git add modules/KestrelhttpServer/ git commit -m "Update Kestrel to latest version" -## PowerShell is slow in aspnet/Universe +## PowerShell is slow in aspnet/AspNetCore Many users have post-git, and extension that shows git status on the prompt line. Because `git status` with submodules on Windows is very slow, it can make PowerShell unbearable to use. diff --git a/scripts/GenerateTags.ps1 b/scripts/GenerateTags.ps1 index 5fc2ed9ee7..0cd9c331ca 100755 --- a/scripts/GenerateTags.ps1 +++ b/scripts/GenerateTags.ps1 @@ -85,12 +85,12 @@ if (-not $PSCmdlet.ShouldContinue("Continue?", "This will apply tags to all subm } -$universeTag = Get-PackageVersion $repoRoot -New-GitTag $repoRoot $universeTag -WhatIf:$WhatIfPreference +$repoTag = Get-PackageVersion $repoRoot +New-GitTag $repoRoot $repoTag -WhatIf:$WhatIfPreference $tags = @([pscustomobject] @{ repo = $(git config remote.origin.url) - tag = $universeTag + tag = $repoTag commit = $(git rev-parse HEAD) }) @@ -104,8 +104,8 @@ Get-Submodules $repoRoot | ForEach-Object { try { $tag = Get-PackageVersion $_.path - if ($tag -ne $universeTag) { - Write-Warning "${module}: version ($tag) does not match universe ($universeTag)" + if ($tag -ne $repoTag) { + Write-Warning "${module}: version ($tag) does not match repo ($repoTag)" } $tags += [pscustomobject] @{ repo = $_.remote diff --git a/scripts/UpdateRepos.ps1 b/scripts/UpdateRepos.ps1 index 24b921b867..d45002e144 100755 --- a/scripts/UpdateRepos.ps1 +++ b/scripts/UpdateRepos.ps1 @@ -2,7 +2,7 @@ <# .SYNOPSIS - Updates each repo Universe builds to new dependencies.props. + Updates each submodule this repo builds to new dependencies.props. .PARAMETER Source The NuGet package source to find the lineup on. .PARAMETER LineupID @@ -71,10 +71,10 @@ try { $koreBuildLock = "korebuild-lock.txt" - $universeKoreBuildLock = (Join-Path $RepoRoot $koreBuildLock) + $repoKoreBuildLock = (Join-Path $RepoRoot $koreBuildLock) $submoduleKoreBuildLock = (Join-Path $submodule.path $koreBuildLock) - Copy-Item $universeKoreBuildLock $submoduleKoreBuildLock -Force + Copy-Item $repoKoreBuildLock $submoduleKoreBuildLock -Force Write-Verbose "About to update dependencies.props for $($submodule.module)" & .\run.ps1 upgrade deps --source $Source --id $LineupID --version $LineupVersion --deps-file $depsFile diff --git a/scripts/common.psm1 b/scripts/common.psm1 index 5225c6d7b8..c547cba9a9 100644 --- a/scripts/common.psm1 +++ b/scripts/common.psm1 @@ -161,7 +161,7 @@ function CreatePR( [string]$gitHubToken) { $hubLocation = Ensure-Hub - Invoke-Block { git push -f https://$gitHubToken@github.com/$headFork/Universe.git $destinationBranch } + Invoke-Block { git push -f https://$gitHubToken@github.com/$headFork/AspNetCore.git $destinationBranch } & $hubLocation pull-request -f -b "${baseFork}:$baseBranch" -h "${headFork}:$destinationBranch" -m $body } From eb8ca94bc753059b3490c9c2d9997f0e65715e67 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Wed, 17 Oct 2018 10:33:19 -0700 Subject: [PATCH 449/453] Updating BuildTools from 2.1.3-rtm-15823 to 2.1.3-rtm-15824 [auto-updated: buildtools] --- korebuild-lock.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 7745e94179..7403c41108 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.3-rtm-15823 -commithash:e19710797af394871441593f20f2fb479525d9ac +version:2.1.3-rtm-15824 +commithash:cf73da2bacaceae3e9f6073b438e3c3f51ec3f79 From b68d47ebee1cc10184c04042f0e6c10631fc97d7 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Wed, 17 Oct 2018 21:07:55 +0000 Subject: [PATCH 450/453] Updating BuildTools from 2.1.3-rtm-15824 to 2.1.3-rtm-15825 [auto-updated: buildtools] --- korebuild-lock.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 7403c41108..a58ab85bb0 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.3-rtm-15824 -commithash:cf73da2bacaceae3e9f6073b438e3c3f51ec3f79 +version:2.1.3-rtm-15825 +commithash:ddaf03d40226070e49a7524509583c48ed83c3d3 From 5d84c92b746eaad111b143e62d4621291df9c46f Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 17 Oct 2018 14:27:00 -0700 Subject: [PATCH 451/453] Reorganize source code in preparation to move into aspnet/AspNetCore Prior to reorganiziation, this source code was found in https://github.com/aspnet/WebSockets/tree/67f2c3149efd03511794ed64726a196ee0b1ab36 --- .appveyor.yml | 23 -- .gitattributes | 52 ---- .github/ISSUE_TEMPLATE.md | 3 - .travis.yml | 29 --- CONTRIBUTING.md | 4 - LICENSE.txt | 14 -- NuGet.config | 7 - build.cmd | 2 - build.sh | 8 - korebuild-lock.txt | 2 - korebuild.json | 4 - run.cmd | 2 - run.ps1 | 196 --------------- run.sh | 231 ------------------ .gitignore => src/WebSockets/.gitignore | 0 .../WebSockets/Directory.Build.props | 0 .../WebSockets/Directory.Build.targets | 0 .../WebSockets/NuGetPackageVerifier.json | 0 README.md => src/WebSockets/README.md | 0 .../WebSockets/WebSockets.sln | 0 {build => src/WebSockets/build}/Key.snk | Bin .../WebSockets/build}/dependencies.props | 0 {build => src/WebSockets/build}/repo.props | 0 {build => src/WebSockets/build}/repo.targets | 0 .../WebSockets/build}/setup-wstest.ps1 | 0 .../WebSockets/build}/setup-wstest.sh | 0 {build => src/WebSockets/build}/sources.props | 0 .../AutobahnTestAppAspNet4.csproj.aspnet4 | 0 .../AutobahnTestAppAspNet4/EchoSocket.ashx | 0 .../AutobahnTestAppAspNet4/EchoSocket.ashx.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../AutobahnTestAppAspNet4/Web.Debug.config | 0 .../AutobahnTestAppAspNet4/Web.Release.config | 0 .../AutobahnTestAppAspNet4/Web.config | 0 .../AutobahnTestAppAspNet4/packages.config | 0 .../AutobahnTestAppAspNet4/wstest-spec.json | 0 .../AutobahnTestAppHttpListener/App.config | 0 .../AutobahnTestAppHttpListener.csproj.net461 | 0 .../AutobahnTestAppHttpListener/Program.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../samples}/EchoApp/EchoApp.csproj | 0 .../WebSockets/samples}/EchoApp/Program.cs | 0 .../EchoApp/Properties/launchSettings.json | 0 .../WebSockets/samples}/EchoApp/Startup.cs | 0 .../samples}/EchoApp/wwwroot/index.html | 0 .../WebSockets/samples}/TestServer/App.config | 0 .../WebSockets/samples}/TestServer/Program.cs | 0 .../TestServer/Properties/AssemblyInfo.cs | 0 .../samples}/TestServer/TestServer.csproj | 0 .../src}/Directory.Build.props | 0 .../ExtendedWebSocketAcceptContext.cs | 0 .../Internal/Constants.cs | 0 .../Internal/HandshakeHelpers.cs | 0 .../Microsoft.AspNetCore.WebSockets.csproj | 0 .../WebSocketMiddleware.cs | 0 .../WebSocketMiddlewareExtensions.cs | 0 .../WebSocketOptions.cs | 0 .../baseline.netcore.json | 0 .../AutobahnTestApp/AutobahnTestApp.csproj | 0 .../test}/AutobahnTestApp/Program.cs | 0 .../Properties/launchSettings.json | 0 .../test}/AutobahnTestApp/README.md | 0 .../test}/AutobahnTestApp/Startup.cs | 0 .../TestResources/testCert.pfx | Bin .../TestResources/testCert.txt | 0 .../scripts/RunAutobahnTests.ps1 | 0 .../scripts/autobahn.spec.json | 0 .../WebSockets/test}/Directory.Build.props | 0 .../Autobahn/AutobahnCaseResult.cs | 0 .../Autobahn/AutobahnExpectations.cs | 0 .../Autobahn/AutobahnResult.cs | 0 .../Autobahn/AutobahnServerResult.cs | 0 .../Autobahn/AutobahnSpec.cs | 0 .../Autobahn/AutobahnTester.cs | 0 .../Autobahn/Executable.cs | 0 .../Autobahn/Expectation.cs | 0 .../Autobahn/ServerSpec.cs | 0 .../Autobahn/Wstest.cs | 0 .../AutobahnTests.cs | 0 .../Helpers.cs | 0 .../Http.config | 0 ...pNetCore.WebSockets.ConformanceTest.csproj | 0 .../SkipIfWsTestNotPresentAttribute.cs | 0 .../BufferStream.cs | 0 .../DuplexStream.cs | 0 .../IWebHostPortExtensions.cs | 0 .../KestrelWebSocketHelpers.cs | 0 ...icrosoft.AspNetCore.WebSockets.Test.csproj | 0 .../SendReceiveTests.cs | 0 .../WebSocketMiddlewareTests.cs | 0 .../WebSocketPair.cs | 0 version.props => src/WebSockets/version.props | 0 92 files changed, 577 deletions(-) delete mode 100644 .appveyor.yml delete mode 100644 .gitattributes delete mode 100644 .github/ISSUE_TEMPLATE.md delete mode 100644 .travis.yml delete mode 100644 CONTRIBUTING.md delete mode 100644 LICENSE.txt delete mode 100644 NuGet.config delete mode 100644 build.cmd delete mode 100755 build.sh delete mode 100644 korebuild-lock.txt delete mode 100644 korebuild.json delete mode 100644 run.cmd delete mode 100644 run.ps1 delete mode 100755 run.sh rename .gitignore => src/WebSockets/.gitignore (100%) rename Directory.Build.props => src/WebSockets/Directory.Build.props (100%) rename Directory.Build.targets => src/WebSockets/Directory.Build.targets (100%) rename NuGetPackageVerifier.json => src/WebSockets/NuGetPackageVerifier.json (100%) rename README.md => src/WebSockets/README.md (100%) rename WebSockets.sln => src/WebSockets/WebSockets.sln (100%) rename {build => src/WebSockets/build}/Key.snk (100%) rename {build => src/WebSockets/build}/dependencies.props (100%) rename {build => src/WebSockets/build}/repo.props (100%) rename {build => src/WebSockets/build}/repo.targets (100%) rename {build => src/WebSockets/build}/setup-wstest.ps1 (100%) rename {build => src/WebSockets/build}/setup-wstest.sh (100%) rename {build => src/WebSockets/build}/sources.props (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppAspNet4/AutobahnTestAppAspNet4.csproj.aspnet4 (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppAspNet4/EchoSocket.ashx (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppAspNet4/EchoSocket.ashx.cs (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppAspNet4/Properties/AssemblyInfo.cs (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppAspNet4/Web.Debug.config (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppAspNet4/Web.Release.config (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppAspNet4/Web.config (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppAspNet4/packages.config (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppAspNet4/wstest-spec.json (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppHttpListener/App.config (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppHttpListener/AutobahnTestAppHttpListener.csproj.net461 (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppHttpListener/Program.cs (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppHttpListener/Properties/AssemblyInfo.cs (100%) rename {samples => src/WebSockets/samples}/EchoApp/EchoApp.csproj (100%) rename {samples => src/WebSockets/samples}/EchoApp/Program.cs (100%) rename {samples => src/WebSockets/samples}/EchoApp/Properties/launchSettings.json (100%) rename {samples => src/WebSockets/samples}/EchoApp/Startup.cs (100%) rename {samples => src/WebSockets/samples}/EchoApp/wwwroot/index.html (100%) rename {samples => src/WebSockets/samples}/TestServer/App.config (100%) rename {samples => src/WebSockets/samples}/TestServer/Program.cs (100%) rename {samples => src/WebSockets/samples}/TestServer/Properties/AssemblyInfo.cs (100%) rename {samples => src/WebSockets/samples}/TestServer/TestServer.csproj (100%) rename src/{ => WebSockets/src}/Directory.Build.props (100%) rename src/{ => WebSockets/src}/Microsoft.AspNetCore.WebSockets/ExtendedWebSocketAcceptContext.cs (100%) rename src/{ => WebSockets/src}/Microsoft.AspNetCore.WebSockets/Internal/Constants.cs (100%) rename src/{ => WebSockets/src}/Microsoft.AspNetCore.WebSockets/Internal/HandshakeHelpers.cs (100%) rename src/{ => WebSockets/src}/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj (100%) rename src/{ => WebSockets/src}/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs (100%) rename src/{ => WebSockets/src}/Microsoft.AspNetCore.WebSockets/WebSocketMiddlewareExtensions.cs (100%) rename src/{ => WebSockets/src}/Microsoft.AspNetCore.WebSockets/WebSocketOptions.cs (100%) rename src/{ => WebSockets/src}/Microsoft.AspNetCore.WebSockets/baseline.netcore.json (100%) rename {test => src/WebSockets/test}/AutobahnTestApp/AutobahnTestApp.csproj (100%) rename {test => src/WebSockets/test}/AutobahnTestApp/Program.cs (100%) rename {test => src/WebSockets/test}/AutobahnTestApp/Properties/launchSettings.json (100%) rename {test => src/WebSockets/test}/AutobahnTestApp/README.md (100%) rename {test => src/WebSockets/test}/AutobahnTestApp/Startup.cs (100%) rename {test => src/WebSockets/test}/AutobahnTestApp/TestResources/testCert.pfx (100%) rename {test => src/WebSockets/test}/AutobahnTestApp/TestResources/testCert.txt (100%) rename {test => src/WebSockets/test}/AutobahnTestApp/scripts/RunAutobahnTests.ps1 (100%) rename {test => src/WebSockets/test}/AutobahnTestApp/scripts/autobahn.spec.json (100%) rename {test => src/WebSockets/test}/Directory.Build.props (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnCaseResult.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnExpectations.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnResult.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnServerResult.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnSpec.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Expectation.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/ServerSpec.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Helpers.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Http.config (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.Test/IWebHostPortExtensions.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.Test/SendReceiveTests.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.Test/WebSocketPair.cs (100%) rename version.props => src/WebSockets/version.props (100%) diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index d1d38b8e18..0000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,23 +0,0 @@ -init: -- git config --global core.autocrlf true -environment: - AUTOBAHN_SUITES_LOG: 1 - global: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - ASPNETCORE_WSTEST_PATH: $(APPVEYOR_BUILD_FOLDER)/vendor/virtualenv/Scripts/wstest.exe -cache: -- vendor\VCForPython27.msi -branches: - only: - - dev - - /^release\/.*$/ - - /^(.*\/)?ci-.*$/ -install: -- ps: .\build\setup-wstest.ps1 -build_script: -- ps: .\run.ps1 default-build -clone_depth: 1 -test: 'off' -deploy: 'off' -os: Visual Studio 2017 diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index c2f0f84273..0000000000 --- a/.gitattributes +++ /dev/null @@ -1,52 +0,0 @@ -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain - -*.jpg binary -*.png binary -*.gif binary - -*.cs text=auto diff=csharp -*.vb text=auto -*.resx text=auto -*.c text=auto -*.cpp text=auto -*.cxx text=auto -*.h text=auto -*.hxx text=auto -*.py text=auto -*.rb text=auto -*.java text=auto -*.html text=auto -*.htm text=auto -*.css text=auto -*.scss text=auto -*.sass text=auto -*.less text=auto -*.js text=auto -*.lisp text=auto -*.clj text=auto -*.sql text=auto -*.php text=auto -*.lua text=auto -*.m text=auto -*.asm text=auto -*.erl text=auto -*.fs text=auto -*.fsx text=auto -*.hs text=auto - -*.csproj text=auto -*.vbproj text=auto -*.fsproj text=auto -*.dbproj text=auto -*.sln text=auto eol=crlf - -*.sh eol=lf \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 101a084f0a..0000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,3 +0,0 @@ -THIS ISSUE TRACKER IS CLOSED - please log new issues here: https://github.com/aspnet/Home/issues - -For information about this change, see https://github.com/aspnet/Announcements/issues/283 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 81bf8af485..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: csharp -sudo: false -dist: trusty -env: - global: - - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - - AUTOBAHN_SUITES_LOG: 1 - - ASPNETCORE_WSTEST_PATH: $TRAVIS_BUILD_DIR/.virtualenv/bin/wstest -mono: none -python: -- pypy -os: -- linux -- osx -osx_image: xcode8.2 -addons: - apt: - packages: - - libunwind8 -branches: - only: - - dev - - /^release\/.*$/ - - /^(.*\/)?ci-.*$/ -install: -- ./build/setup-wstest.sh -script: -- ./build.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 64ff041d5c..0000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,4 +0,0 @@ -Contributing -====== - -Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/dev/CONTRIBUTING.md) in the Home repo. diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 7b2956ecee..0000000000 --- a/LICENSE.txt +++ /dev/null @@ -1,14 +0,0 @@ -Copyright (c) .NET Foundation and Contributors - -All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software distributed -under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -CONDITIONS OF ANY KIND, either express or implied. See the License for the -specific language governing permissions and limitations under the License. diff --git a/NuGet.config b/NuGet.config deleted file mode 100644 index e32bddfd51..0000000000 --- a/NuGet.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/build.cmd b/build.cmd deleted file mode 100644 index c0050bda12..0000000000 --- a/build.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' default-build %*; exit $LASTEXITCODE" diff --git a/build.sh b/build.sh deleted file mode 100755 index 98a4b22765..0000000000 --- a/build.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -# Call "sync" between "chmod" and execution to prevent "text file busy" error in Docker (aufs) -chmod +x "$DIR/run.sh"; sync -"$DIR/run.sh" default-build "$@" diff --git a/korebuild-lock.txt b/korebuild-lock.txt deleted file mode 100644 index 1dfc352a0a..0000000000 --- a/korebuild-lock.txt +++ /dev/null @@ -1,2 +0,0 @@ -version:2.1.3-rtm-15802 -commithash:a7c08b45b440a7d2058a0aa1eaa3eb6ba811976a diff --git a/korebuild.json b/korebuild.json deleted file mode 100644 index 678d8bb948..0000000000 --- a/korebuild.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json", - "channel": "release/2.1" -} diff --git a/run.cmd b/run.cmd deleted file mode 100644 index d52d5c7e68..0000000000 --- a/run.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' %*; exit $LASTEXITCODE" diff --git a/run.ps1 b/run.ps1 deleted file mode 100644 index 27dcf848f8..0000000000 --- a/run.ps1 +++ /dev/null @@ -1,196 +0,0 @@ -#!/usr/bin/env powershell -#requires -version 4 - -<# -.SYNOPSIS -Executes KoreBuild commands. - -.DESCRIPTION -Downloads korebuild if required. Then executes the KoreBuild command. To see available commands, execute with `-Command help`. - -.PARAMETER Command -The KoreBuild command to run. - -.PARAMETER Path -The folder to build. Defaults to the folder containing this script. - -.PARAMETER Channel -The channel of KoreBuild to download. Overrides the value from the config file. - -.PARAMETER DotNetHome -The directory where .NET Core tools will be stored. - -.PARAMETER ToolsSource -The base url where build tools can be downloaded. Overrides the value from the config file. - -.PARAMETER Update -Updates KoreBuild to the latest version even if a lock file is present. - -.PARAMETER ConfigFile -The path to the configuration file that stores values. Defaults to korebuild.json. - -.PARAMETER ToolsSourceSuffix -The Suffix to append to the end of the ToolsSource. Useful for query strings in blob stores. - -.PARAMETER Arguments -Arguments to be passed to the command - -.NOTES -This function will create a file $PSScriptRoot/korebuild-lock.txt. This lock file can be committed to source, but does not have to be. -When the lockfile is not present, KoreBuild will create one using latest available version from $Channel. - -The $ConfigFile is expected to be an JSON file. It is optional, and the configuration values in it are optional as well. Any options set -in the file are overridden by command line parameters. - -.EXAMPLE -Example config file: -```json -{ - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev", - "toolsSource": "https://aspnetcore.blob.core.windows.net/buildtools" -} -``` -#> -[CmdletBinding(PositionalBinding = $false)] -param( - [Parameter(Mandatory = $true, Position = 0)] - [string]$Command, - [string]$Path = $PSScriptRoot, - [Alias('c')] - [string]$Channel, - [Alias('d')] - [string]$DotNetHome, - [Alias('s')] - [string]$ToolsSource, - [Alias('u')] - [switch]$Update, - [string]$ConfigFile, - [string]$ToolsSourceSuffix, - [Parameter(ValueFromRemainingArguments = $true)] - [string[]]$Arguments -) - -Set-StrictMode -Version 2 -$ErrorActionPreference = 'Stop' - -# -# Functions -# - -function Get-KoreBuild { - - $lockFile = Join-Path $Path 'korebuild-lock.txt' - - if (!(Test-Path $lockFile) -or $Update) { - Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile $ToolsSourceSuffix - } - - $version = Get-Content $lockFile | Where-Object { $_ -like 'version:*' } | Select-Object -first 1 - if (!$version) { - Write-Error "Failed to parse version from $lockFile. Expected a line that begins with 'version:'" - } - $version = $version.TrimStart('version:').Trim() - $korebuildPath = Join-Paths $DotNetHome ('buildtools', 'korebuild', $version) - - if (!(Test-Path $korebuildPath)) { - Write-Host -ForegroundColor Magenta "Downloading KoreBuild $version" - New-Item -ItemType Directory -Path $korebuildPath | Out-Null - $remotePath = "$ToolsSource/korebuild/artifacts/$version/korebuild.$version.zip" - - try { - $tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip" - Get-RemoteFile $remotePath $tmpfile $ToolsSourceSuffix - if (Get-Command -Name 'Expand-Archive' -ErrorAction Ignore) { - # Use built-in commands where possible as they are cross-plat compatible - Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath - } - else { - # Fallback to old approach for old installations of PowerShell - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::ExtractToDirectory($tmpfile, $korebuildPath) - } - } - catch { - Remove-Item -Recurse -Force $korebuildPath -ErrorAction Ignore - throw - } - finally { - Remove-Item $tmpfile -ErrorAction Ignore - } - } - - return $korebuildPath -} - -function Join-Paths([string]$path, [string[]]$childPaths) { - $childPaths | ForEach-Object { $path = Join-Path $path $_ } - return $path -} - -function Get-RemoteFile([string]$RemotePath, [string]$LocalPath, [string]$RemoteSuffix) { - if ($RemotePath -notlike 'http*') { - Copy-Item $RemotePath $LocalPath - return - } - - $retries = 10 - while ($retries -gt 0) { - $retries -= 1 - try { - Invoke-WebRequest -UseBasicParsing -Uri $($RemotePath + $RemoteSuffix) -OutFile $LocalPath - return - } - catch { - Write-Verbose "Request failed. $retries retries remaining" - } - } - - Write-Error "Download failed: '$RemotePath'." -} - -# -# Main -# - -# Load configuration or set defaults - -$Path = Resolve-Path $Path -if (!$ConfigFile) { $ConfigFile = Join-Path $Path 'korebuild.json' } - -if (Test-Path $ConfigFile) { - try { - $config = Get-Content -Raw -Encoding UTF8 -Path $ConfigFile | ConvertFrom-Json - if ($config) { - if (!($Channel) -and (Get-Member -Name 'channel' -InputObject $config)) { [string] $Channel = $config.channel } - if (!($ToolsSource) -and (Get-Member -Name 'toolsSource' -InputObject $config)) { [string] $ToolsSource = $config.toolsSource} - } - } - catch { - Write-Warning "$ConfigFile could not be read. Its settings will be ignored." - Write-Warning $Error[0] - } -} - -if (!$DotNetHome) { - $DotNetHome = if ($env:DOTNET_HOME) { $env:DOTNET_HOME } ` - elseif ($env:USERPROFILE) { Join-Path $env:USERPROFILE '.dotnet'} ` - elseif ($env:HOME) {Join-Path $env:HOME '.dotnet'}` - else { Join-Path $PSScriptRoot '.dotnet'} -} - -if (!$Channel) { $Channel = 'dev' } -if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' } - -# Execute - -$korebuildPath = Get-KoreBuild -Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') - -try { - Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile - Invoke-KoreBuildCommand $Command @Arguments -} -finally { - Remove-Module 'KoreBuild' -ErrorAction Ignore -} diff --git a/run.sh b/run.sh deleted file mode 100755 index 834961fc3a..0000000000 --- a/run.sh +++ /dev/null @@ -1,231 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -# -# variables -# - -RESET="\033[0m" -RED="\033[0;31m" -YELLOW="\033[0;33m" -MAGENTA="\033[0;95m" -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" -verbose=false -update=false -repo_path="$DIR" -channel='' -tools_source='' -tools_source_suffix='' - -# -# Functions -# -__usage() { - echo "Usage: $(basename "${BASH_SOURCE[0]}") command [options] [[--] ...]" - echo "" - echo "Arguments:" - echo " command The command to be run." - echo " ... Arguments passed to the command. Variable number of arguments allowed." - echo "" - echo "Options:" - echo " --verbose Show verbose output." - echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." - echo " --config-file The path to the configuration file that stores values. Defaults to korebuild.json." - echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." - echo " --path The directory to build. Defaults to the directory containing the script." - echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." - echo " --tools-source-suffix|-ToolsSourceSuffix The suffix to append to tools-source. Useful for query strings." - echo " -u|--update Update to the latest KoreBuild even if the lock file is present." - echo "" - echo "Description:" - echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." - echo " When the lockfile is not present, KoreBuild will create one using latest available version from \$channel." - - if [[ "${1:-}" != '--no-exit' ]]; then - exit 2 - fi -} - -get_korebuild() { - local version - local lock_file="$repo_path/korebuild-lock.txt" - if [ ! -f "$lock_file" ] || [ "$update" = true ]; then - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" "$tools_source_suffix" - fi - version="$(grep 'version:*' -m 1 "$lock_file")" - if [[ "$version" == '' ]]; then - __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" - return 1 - fi - version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" - local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" - - { - if [ ! -d "$korebuild_path" ]; then - mkdir -p "$korebuild_path" - local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" - tmpfile="$(mktemp)" - echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" - if __get_remote_file "$remote_path" "$tmpfile" "$tools_source_suffix"; then - unzip -q -d "$korebuild_path" "$tmpfile" - fi - rm "$tmpfile" || true - fi - - source "$korebuild_path/KoreBuild.sh" - } || { - if [ -d "$korebuild_path" ]; then - echo "Cleaning up after failed installation" - rm -rf "$korebuild_path" || true - fi - return 1 - } -} - -__error() { - echo -e "${RED}error: $*${RESET}" 1>&2 -} - -__warn() { - echo -e "${YELLOW}warning: $*${RESET}" -} - -__machine_has() { - hash "$1" > /dev/null 2>&1 - return $? -} - -__get_remote_file() { - local remote_path=$1 - local local_path=$2 - local remote_path_suffix=$3 - - if [[ "$remote_path" != 'http'* ]]; then - cp "$remote_path" "$local_path" - return 0 - fi - - local failed=false - if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "${remote_path}${remote_path_suffix}" || failed=true - else - failed=true - fi - - if [ "$failed" = true ] && __machine_has curl; then - failed=false - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "${remote_path}${remote_path_suffix}" || failed=true - fi - - if [ "$failed" = true ]; then - __error "Download failed: $remote_path" 1>&2 - return 1 - fi -} - -# -# main -# - -command="${1:-}" -shift - -while [[ $# -gt 0 ]]; do - case $1 in - -\?|-h|--help) - __usage --no-exit - exit 0 - ;; - -c|--channel|-Channel) - shift - channel="${1:-}" - [ -z "$channel" ] && __usage - ;; - --config-file|-ConfigFile) - shift - config_file="${1:-}" - [ -z "$config_file" ] && __usage - if [ ! -f "$config_file" ]; then - __error "Invalid value for --config-file. $config_file does not exist." - exit 1 - fi - ;; - -d|--dotnet-home|-DotNetHome) - shift - DOTNET_HOME="${1:-}" - [ -z "$DOTNET_HOME" ] && __usage - ;; - --path|-Path) - shift - repo_path="${1:-}" - [ -z "$repo_path" ] && __usage - ;; - -s|--tools-source|-ToolsSource) - shift - tools_source="${1:-}" - [ -z "$tools_source" ] && __usage - ;; - --tools-source-suffix|-ToolsSourceSuffix) - shift - tools_source_suffix="${1:-}" - [ -z "$tools_source_suffix" ] && __usage - ;; - -u|--update|-Update) - update=true - ;; - --verbose|-Verbose) - verbose=true - ;; - --) - shift - break - ;; - *) - break - ;; - esac - shift -done - -if ! __machine_has unzip; then - __error 'Missing required command: unzip' - exit 1 -fi - -if ! __machine_has curl && ! __machine_has wget; then - __error 'Missing required command. Either wget or curl is required.' - exit 1 -fi - -[ -z "${config_file:-}" ] && config_file="$repo_path/korebuild.json" -if [ -f "$config_file" ]; then - if __machine_has jq ; then - if jq '.' "$config_file" >/dev/null ; then - config_channel="$(jq -r 'select(.channel!=null) | .channel' "$config_file")" - config_tools_source="$(jq -r 'select(.toolsSource!=null) | .toolsSource' "$config_file")" - else - __warn "$config_file is invalid JSON. Its settings will be ignored." - fi - elif __machine_has python ; then - if python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then - config_channel="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')")" - config_tools_source="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")" - else - __warn "$config_file is invalid JSON. Its settings will be ignored." - fi - else - __warn 'Missing required command: jq or pyton. Could not parse the JSON file. Its settings will be ignored.' - fi - - [ ! -z "${config_channel:-}" ] && channel="$config_channel" - [ ! -z "${config_tools_source:-}" ] && tools_source="$config_tools_source" -fi - -[ -z "$channel" ] && channel='dev' -[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' - -get_korebuild -set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" -invoke_korebuild_command "$command" "$@" diff --git a/.gitignore b/src/WebSockets/.gitignore similarity index 100% rename from .gitignore rename to src/WebSockets/.gitignore diff --git a/Directory.Build.props b/src/WebSockets/Directory.Build.props similarity index 100% rename from Directory.Build.props rename to src/WebSockets/Directory.Build.props diff --git a/Directory.Build.targets b/src/WebSockets/Directory.Build.targets similarity index 100% rename from Directory.Build.targets rename to src/WebSockets/Directory.Build.targets diff --git a/NuGetPackageVerifier.json b/src/WebSockets/NuGetPackageVerifier.json similarity index 100% rename from NuGetPackageVerifier.json rename to src/WebSockets/NuGetPackageVerifier.json diff --git a/README.md b/src/WebSockets/README.md similarity index 100% rename from README.md rename to src/WebSockets/README.md diff --git a/WebSockets.sln b/src/WebSockets/WebSockets.sln similarity index 100% rename from WebSockets.sln rename to src/WebSockets/WebSockets.sln diff --git a/build/Key.snk b/src/WebSockets/build/Key.snk similarity index 100% rename from build/Key.snk rename to src/WebSockets/build/Key.snk diff --git a/build/dependencies.props b/src/WebSockets/build/dependencies.props similarity index 100% rename from build/dependencies.props rename to src/WebSockets/build/dependencies.props diff --git a/build/repo.props b/src/WebSockets/build/repo.props similarity index 100% rename from build/repo.props rename to src/WebSockets/build/repo.props diff --git a/build/repo.targets b/src/WebSockets/build/repo.targets similarity index 100% rename from build/repo.targets rename to src/WebSockets/build/repo.targets diff --git a/build/setup-wstest.ps1 b/src/WebSockets/build/setup-wstest.ps1 similarity index 100% rename from build/setup-wstest.ps1 rename to src/WebSockets/build/setup-wstest.ps1 diff --git a/build/setup-wstest.sh b/src/WebSockets/build/setup-wstest.sh similarity index 100% rename from build/setup-wstest.sh rename to src/WebSockets/build/setup-wstest.sh diff --git a/build/sources.props b/src/WebSockets/build/sources.props similarity index 100% rename from build/sources.props rename to src/WebSockets/build/sources.props diff --git a/samples/AutobahnTestAppAspNet4/AutobahnTestAppAspNet4.csproj.aspnet4 b/src/WebSockets/samples/AutobahnTestAppAspNet4/AutobahnTestAppAspNet4.csproj.aspnet4 similarity index 100% rename from samples/AutobahnTestAppAspNet4/AutobahnTestAppAspNet4.csproj.aspnet4 rename to src/WebSockets/samples/AutobahnTestAppAspNet4/AutobahnTestAppAspNet4.csproj.aspnet4 diff --git a/samples/AutobahnTestAppAspNet4/EchoSocket.ashx b/src/WebSockets/samples/AutobahnTestAppAspNet4/EchoSocket.ashx similarity index 100% rename from samples/AutobahnTestAppAspNet4/EchoSocket.ashx rename to src/WebSockets/samples/AutobahnTestAppAspNet4/EchoSocket.ashx diff --git a/samples/AutobahnTestAppAspNet4/EchoSocket.ashx.cs b/src/WebSockets/samples/AutobahnTestAppAspNet4/EchoSocket.ashx.cs similarity index 100% rename from samples/AutobahnTestAppAspNet4/EchoSocket.ashx.cs rename to src/WebSockets/samples/AutobahnTestAppAspNet4/EchoSocket.ashx.cs diff --git a/samples/AutobahnTestAppAspNet4/Properties/AssemblyInfo.cs b/src/WebSockets/samples/AutobahnTestAppAspNet4/Properties/AssemblyInfo.cs similarity index 100% rename from samples/AutobahnTestAppAspNet4/Properties/AssemblyInfo.cs rename to src/WebSockets/samples/AutobahnTestAppAspNet4/Properties/AssemblyInfo.cs diff --git a/samples/AutobahnTestAppAspNet4/Web.Debug.config b/src/WebSockets/samples/AutobahnTestAppAspNet4/Web.Debug.config similarity index 100% rename from samples/AutobahnTestAppAspNet4/Web.Debug.config rename to src/WebSockets/samples/AutobahnTestAppAspNet4/Web.Debug.config diff --git a/samples/AutobahnTestAppAspNet4/Web.Release.config b/src/WebSockets/samples/AutobahnTestAppAspNet4/Web.Release.config similarity index 100% rename from samples/AutobahnTestAppAspNet4/Web.Release.config rename to src/WebSockets/samples/AutobahnTestAppAspNet4/Web.Release.config diff --git a/samples/AutobahnTestAppAspNet4/Web.config b/src/WebSockets/samples/AutobahnTestAppAspNet4/Web.config similarity index 100% rename from samples/AutobahnTestAppAspNet4/Web.config rename to src/WebSockets/samples/AutobahnTestAppAspNet4/Web.config diff --git a/samples/AutobahnTestAppAspNet4/packages.config b/src/WebSockets/samples/AutobahnTestAppAspNet4/packages.config similarity index 100% rename from samples/AutobahnTestAppAspNet4/packages.config rename to src/WebSockets/samples/AutobahnTestAppAspNet4/packages.config diff --git a/samples/AutobahnTestAppAspNet4/wstest-spec.json b/src/WebSockets/samples/AutobahnTestAppAspNet4/wstest-spec.json similarity index 100% rename from samples/AutobahnTestAppAspNet4/wstest-spec.json rename to src/WebSockets/samples/AutobahnTestAppAspNet4/wstest-spec.json diff --git a/samples/AutobahnTestAppHttpListener/App.config b/src/WebSockets/samples/AutobahnTestAppHttpListener/App.config similarity index 100% rename from samples/AutobahnTestAppHttpListener/App.config rename to src/WebSockets/samples/AutobahnTestAppHttpListener/App.config diff --git a/samples/AutobahnTestAppHttpListener/AutobahnTestAppHttpListener.csproj.net461 b/src/WebSockets/samples/AutobahnTestAppHttpListener/AutobahnTestAppHttpListener.csproj.net461 similarity index 100% rename from samples/AutobahnTestAppHttpListener/AutobahnTestAppHttpListener.csproj.net461 rename to src/WebSockets/samples/AutobahnTestAppHttpListener/AutobahnTestAppHttpListener.csproj.net461 diff --git a/samples/AutobahnTestAppHttpListener/Program.cs b/src/WebSockets/samples/AutobahnTestAppHttpListener/Program.cs similarity index 100% rename from samples/AutobahnTestAppHttpListener/Program.cs rename to src/WebSockets/samples/AutobahnTestAppHttpListener/Program.cs diff --git a/samples/AutobahnTestAppHttpListener/Properties/AssemblyInfo.cs b/src/WebSockets/samples/AutobahnTestAppHttpListener/Properties/AssemblyInfo.cs similarity index 100% rename from samples/AutobahnTestAppHttpListener/Properties/AssemblyInfo.cs rename to src/WebSockets/samples/AutobahnTestAppHttpListener/Properties/AssemblyInfo.cs diff --git a/samples/EchoApp/EchoApp.csproj b/src/WebSockets/samples/EchoApp/EchoApp.csproj similarity index 100% rename from samples/EchoApp/EchoApp.csproj rename to src/WebSockets/samples/EchoApp/EchoApp.csproj diff --git a/samples/EchoApp/Program.cs b/src/WebSockets/samples/EchoApp/Program.cs similarity index 100% rename from samples/EchoApp/Program.cs rename to src/WebSockets/samples/EchoApp/Program.cs diff --git a/samples/EchoApp/Properties/launchSettings.json b/src/WebSockets/samples/EchoApp/Properties/launchSettings.json similarity index 100% rename from samples/EchoApp/Properties/launchSettings.json rename to src/WebSockets/samples/EchoApp/Properties/launchSettings.json diff --git a/samples/EchoApp/Startup.cs b/src/WebSockets/samples/EchoApp/Startup.cs similarity index 100% rename from samples/EchoApp/Startup.cs rename to src/WebSockets/samples/EchoApp/Startup.cs diff --git a/samples/EchoApp/wwwroot/index.html b/src/WebSockets/samples/EchoApp/wwwroot/index.html similarity index 100% rename from samples/EchoApp/wwwroot/index.html rename to src/WebSockets/samples/EchoApp/wwwroot/index.html diff --git a/samples/TestServer/App.config b/src/WebSockets/samples/TestServer/App.config similarity index 100% rename from samples/TestServer/App.config rename to src/WebSockets/samples/TestServer/App.config diff --git a/samples/TestServer/Program.cs b/src/WebSockets/samples/TestServer/Program.cs similarity index 100% rename from samples/TestServer/Program.cs rename to src/WebSockets/samples/TestServer/Program.cs diff --git a/samples/TestServer/Properties/AssemblyInfo.cs b/src/WebSockets/samples/TestServer/Properties/AssemblyInfo.cs similarity index 100% rename from samples/TestServer/Properties/AssemblyInfo.cs rename to src/WebSockets/samples/TestServer/Properties/AssemblyInfo.cs diff --git a/samples/TestServer/TestServer.csproj b/src/WebSockets/samples/TestServer/TestServer.csproj similarity index 100% rename from samples/TestServer/TestServer.csproj rename to src/WebSockets/samples/TestServer/TestServer.csproj diff --git a/src/Directory.Build.props b/src/WebSockets/src/Directory.Build.props similarity index 100% rename from src/Directory.Build.props rename to src/WebSockets/src/Directory.Build.props diff --git a/src/Microsoft.AspNetCore.WebSockets/ExtendedWebSocketAcceptContext.cs b/src/WebSockets/src/Microsoft.AspNetCore.WebSockets/ExtendedWebSocketAcceptContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.WebSockets/ExtendedWebSocketAcceptContext.cs rename to src/WebSockets/src/Microsoft.AspNetCore.WebSockets/ExtendedWebSocketAcceptContext.cs diff --git a/src/Microsoft.AspNetCore.WebSockets/Internal/Constants.cs b/src/WebSockets/src/Microsoft.AspNetCore.WebSockets/Internal/Constants.cs similarity index 100% rename from src/Microsoft.AspNetCore.WebSockets/Internal/Constants.cs rename to src/WebSockets/src/Microsoft.AspNetCore.WebSockets/Internal/Constants.cs diff --git a/src/Microsoft.AspNetCore.WebSockets/Internal/HandshakeHelpers.cs b/src/WebSockets/src/Microsoft.AspNetCore.WebSockets/Internal/HandshakeHelpers.cs similarity index 100% rename from src/Microsoft.AspNetCore.WebSockets/Internal/HandshakeHelpers.cs rename to src/WebSockets/src/Microsoft.AspNetCore.WebSockets/Internal/HandshakeHelpers.cs diff --git a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj b/src/WebSockets/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj similarity index 100% rename from src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj rename to src/WebSockets/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj diff --git a/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs b/src/WebSockets/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs similarity index 100% rename from src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs rename to src/WebSockets/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs diff --git a/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddlewareExtensions.cs b/src/WebSockets/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddlewareExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.WebSockets/WebSocketMiddlewareExtensions.cs rename to src/WebSockets/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddlewareExtensions.cs diff --git a/src/Microsoft.AspNetCore.WebSockets/WebSocketOptions.cs b/src/WebSockets/src/Microsoft.AspNetCore.WebSockets/WebSocketOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.WebSockets/WebSocketOptions.cs rename to src/WebSockets/src/Microsoft.AspNetCore.WebSockets/WebSocketOptions.cs diff --git a/src/Microsoft.AspNetCore.WebSockets/baseline.netcore.json b/src/WebSockets/src/Microsoft.AspNetCore.WebSockets/baseline.netcore.json similarity index 100% rename from src/Microsoft.AspNetCore.WebSockets/baseline.netcore.json rename to src/WebSockets/src/Microsoft.AspNetCore.WebSockets/baseline.netcore.json diff --git a/test/AutobahnTestApp/AutobahnTestApp.csproj b/src/WebSockets/test/AutobahnTestApp/AutobahnTestApp.csproj similarity index 100% rename from test/AutobahnTestApp/AutobahnTestApp.csproj rename to src/WebSockets/test/AutobahnTestApp/AutobahnTestApp.csproj diff --git a/test/AutobahnTestApp/Program.cs b/src/WebSockets/test/AutobahnTestApp/Program.cs similarity index 100% rename from test/AutobahnTestApp/Program.cs rename to src/WebSockets/test/AutobahnTestApp/Program.cs diff --git a/test/AutobahnTestApp/Properties/launchSettings.json b/src/WebSockets/test/AutobahnTestApp/Properties/launchSettings.json similarity index 100% rename from test/AutobahnTestApp/Properties/launchSettings.json rename to src/WebSockets/test/AutobahnTestApp/Properties/launchSettings.json diff --git a/test/AutobahnTestApp/README.md b/src/WebSockets/test/AutobahnTestApp/README.md similarity index 100% rename from test/AutobahnTestApp/README.md rename to src/WebSockets/test/AutobahnTestApp/README.md diff --git a/test/AutobahnTestApp/Startup.cs b/src/WebSockets/test/AutobahnTestApp/Startup.cs similarity index 100% rename from test/AutobahnTestApp/Startup.cs rename to src/WebSockets/test/AutobahnTestApp/Startup.cs diff --git a/test/AutobahnTestApp/TestResources/testCert.pfx b/src/WebSockets/test/AutobahnTestApp/TestResources/testCert.pfx similarity index 100% rename from test/AutobahnTestApp/TestResources/testCert.pfx rename to src/WebSockets/test/AutobahnTestApp/TestResources/testCert.pfx diff --git a/test/AutobahnTestApp/TestResources/testCert.txt b/src/WebSockets/test/AutobahnTestApp/TestResources/testCert.txt similarity index 100% rename from test/AutobahnTestApp/TestResources/testCert.txt rename to src/WebSockets/test/AutobahnTestApp/TestResources/testCert.txt diff --git a/test/AutobahnTestApp/scripts/RunAutobahnTests.ps1 b/src/WebSockets/test/AutobahnTestApp/scripts/RunAutobahnTests.ps1 similarity index 100% rename from test/AutobahnTestApp/scripts/RunAutobahnTests.ps1 rename to src/WebSockets/test/AutobahnTestApp/scripts/RunAutobahnTests.ps1 diff --git a/test/AutobahnTestApp/scripts/autobahn.spec.json b/src/WebSockets/test/AutobahnTestApp/scripts/autobahn.spec.json similarity index 100% rename from test/AutobahnTestApp/scripts/autobahn.spec.json rename to src/WebSockets/test/AutobahnTestApp/scripts/autobahn.spec.json diff --git a/test/Directory.Build.props b/src/WebSockets/test/Directory.Build.props similarity index 100% rename from test/Directory.Build.props rename to src/WebSockets/test/Directory.Build.props diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnCaseResult.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnCaseResult.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnCaseResult.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnCaseResult.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnExpectations.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnExpectations.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnExpectations.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnExpectations.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnResult.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnResult.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnResult.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnResult.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnServerResult.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnServerResult.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnServerResult.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnServerResult.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnSpec.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnSpec.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnSpec.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnSpec.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Expectation.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Expectation.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Expectation.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Expectation.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/ServerSpec.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/ServerSpec.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/ServerSpec.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/ServerSpec.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Helpers.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Helpers.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Helpers.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Helpers.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Http.config b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Http.config similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Http.config rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Http.config diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/IWebHostPortExtensions.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/IWebHostPortExtensions.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Test/IWebHostPortExtensions.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/IWebHostPortExtensions.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/SendReceiveTests.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/SendReceiveTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Test/SendReceiveTests.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/SendReceiveTests.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketPair.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketPair.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Test/WebSocketPair.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketPair.cs diff --git a/version.props b/src/WebSockets/version.props similarity index 100% rename from version.props rename to src/WebSockets/version.props From b1427c759bf2012576afed4ab6124fcb267bb126 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 17 Oct 2018 14:35:48 -0700 Subject: [PATCH 452/453] Remove the WebSockets submodule --- .azure/pipelines/fast-pr-validation.yml | 17 ++++++++++++----- .gitmodules | 4 ---- build/buildorder.props | 2 +- build/submodules.props | 2 +- modules/WebSockets | 1 - src/WebSockets/build.cmd | 3 +++ src/WebSockets/build.sh | 7 +++++++ 7 files changed, 24 insertions(+), 12 deletions(-) delete mode 160000 modules/WebSockets create mode 100644 src/WebSockets/build.cmd create mode 100755 src/WebSockets/build.sh diff --git a/.azure/pipelines/fast-pr-validation.yml b/.azure/pipelines/fast-pr-validation.yml index 863270dc71..6857144c97 100644 --- a/.azure/pipelines/fast-pr-validation.yml +++ b/.azure/pipelines/fast-pr-validation.yml @@ -15,14 +15,21 @@ phases: - template: .vsts-pipelines/templates/project-ci.yml@buildtools parameters: buildArgs: "/t:FastCheck" -- phase: DataProtection - queue: Hosted VS2017 +- phase: RepoBuilds + queue: + name: Hosted VS2017 + parallel: 2 + matrix: + DataProtection: + _FolderName: DataProtection + WebSockets: + _FolderName: WebSockets steps: - - script: src/DataProtection/build.cmd -ci - displayName: Run src/DataProtection/build.cmd + - script: src/$(_FolderName)/build.cmd -ci + displayName: Run src/$(_FolderName)/build.cmd - task: PublishTestResults@2 displayName: Publish test results condition: always() inputs: testRunner: vstest - testResultsFiles: 'src/DataProtection/artifacts/logs/**/*.trx' + testResultsFiles: 'src/$(_FolderName)/artifacts/logs/**/*.trx' diff --git a/.gitmodules b/.gitmodules index 972b9ce3f8..513f28cb14 100644 --- a/.gitmodules +++ b/.gitmodules @@ -178,7 +178,3 @@ path = modules/Testing url = https://github.com/aspnet/Testing.git branch = release/2.1 -[submodule "modules/WebSockets"] - path = modules/WebSockets - url = https://github.com/aspnet/WebSockets.git - branch = release/2.1 diff --git a/build/buildorder.props b/build/buildorder.props index c8b166f55b..761d9e7f39 100644 --- a/build/buildorder.props +++ b/build/buildorder.props @@ -40,7 +40,7 @@ - + diff --git a/build/submodules.props b/build/submodules.props index cc0a5c1603..26ca5497b6 100644 --- a/build/submodules.props +++ b/build/submodules.props @@ -87,6 +87,6 @@ - + diff --git a/modules/WebSockets b/modules/WebSockets deleted file mode 160000 index 67f2c3149e..0000000000 --- a/modules/WebSockets +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 67f2c3149efd03511794ed64726a196ee0b1ab36 diff --git a/src/WebSockets/build.cmd b/src/WebSockets/build.cmd new file mode 100644 index 0000000000..f4169ea5e4 --- /dev/null +++ b/src/WebSockets/build.cmd @@ -0,0 +1,3 @@ +@ECHO OFF +SET RepoRoot="%~dp0..\.." +%RepoRoot%\build.cmd -LockFile %RepoRoot%\korebuild-lock.txt -Path %~dp0 %* diff --git a/src/WebSockets/build.sh b/src/WebSockets/build.sh new file mode 100755 index 0000000000..d5bb0cf631 --- /dev/null +++ b/src/WebSockets/build.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -euo pipefail + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +repo_root="$DIR/../.." +"$repo_root/build.sh" --path "$DIR" --lockfile "$repo_root/korebuild-lock.txt" "$@" From 24f85a200c3e369282bfd4674a836455272645a3 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 17 Oct 2018 15:34:25 -0700 Subject: [PATCH 453/453] Reorganize source code in preparation to move into aspnet/AspNetCore Prior to reorganization, this source code was found in https://github.com/aspnet/WebSockets/tree/a036f920b8f32446e3524d3eb5a10fbd02f2a37c --- .appveyor.yml | 23 -- .gitattributes | 52 ---- .github/ISSUE_TEMPLATE.md | 3 - .travis.yml | 29 -- .vsts-pipelines/builds/ci-internal.yml | 13 - .vsts-pipelines/builds/ci-public.yml | 15 - CONTRIBUTING.md | 4 - LICENSE.txt | 14 - NuGet.config | 7 - build.cmd | 2 - build.sh | 8 - korebuild-lock.txt | 2 - korebuild.json | 4 - run.cmd | 2 - run.ps1 | 209 -------------- run.sh | 256 ------------------ .gitignore => src/WebSockets/.gitignore | 0 .../WebSockets/Directory.Build.props | 0 .../WebSockets/Directory.Build.targets | 0 .../WebSockets/NuGetPackageVerifier.json | 0 README.md => src/WebSockets/README.md | 0 .../WebSockets/WebSockets.sln | 0 {build => src/WebSockets/build}/Key.snk | Bin .../WebSockets/build}/dependencies.props | 0 {build => src/WebSockets/build}/repo.props | 0 {build => src/WebSockets/build}/repo.targets | 0 .../WebSockets/build}/setup-wstest.ps1 | 0 .../WebSockets/build}/setup-wstest.sh | 0 {build => src/WebSockets/build}/sources.props | 0 .../AutobahnTestAppAspNet4.csproj.aspnet4 | 0 .../AutobahnTestAppAspNet4/EchoSocket.ashx | 0 .../AutobahnTestAppAspNet4/EchoSocket.ashx.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../AutobahnTestAppAspNet4/Web.Debug.config | 0 .../AutobahnTestAppAspNet4/Web.Release.config | 0 .../AutobahnTestAppAspNet4/Web.config | 0 .../AutobahnTestAppAspNet4/packages.config | 0 .../AutobahnTestAppAspNet4/wstest-spec.json | 0 .../AutobahnTestAppHttpListener/App.config | 0 .../AutobahnTestAppHttpListener.csproj.net461 | 0 .../AutobahnTestAppHttpListener/Program.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../samples}/EchoApp/EchoApp.csproj | 0 .../WebSockets/samples}/EchoApp/Program.cs | 0 .../EchoApp/Properties/launchSettings.json | 0 .../WebSockets/samples}/EchoApp/Startup.cs | 0 .../samples}/EchoApp/wwwroot/index.html | 0 .../WebSockets/samples}/TestServer/App.config | 0 .../WebSockets/samples}/TestServer/Program.cs | 0 .../TestServer/Properties/AssemblyInfo.cs | 0 .../samples}/TestServer/TestServer.csproj | 0 .../src}/Directory.Build.props | 0 .../ExtendedWebSocketAcceptContext.cs | 0 .../Internal/Constants.cs | 0 .../Internal/HandshakeHelpers.cs | 0 .../Microsoft.AspNetCore.WebSockets.csproj | 0 .../WebSocketMiddleware.cs | 0 .../WebSocketMiddlewareExtensions.cs | 0 .../WebSocketOptions.cs | 0 ...WebSocketsDependencyInjectionExtensions.cs | 0 .../baseline.netcore.json | 0 .../AutobahnTestApp/AutobahnTestApp.csproj | 0 .../test}/AutobahnTestApp/Program.cs | 0 .../Properties/launchSettings.json | 0 .../test}/AutobahnTestApp/README.md | 0 .../test}/AutobahnTestApp/Startup.cs | 0 .../TestResources/testCert.pfx | Bin .../TestResources/testCert.txt | 0 .../scripts/RunAutobahnTests.ps1 | 0 .../scripts/autobahn.spec.json | 0 .../WebSockets/test}/Directory.Build.props | 0 .../Autobahn/AutobahnCaseResult.cs | 0 .../Autobahn/AutobahnExpectations.cs | 0 .../Autobahn/AutobahnResult.cs | 0 .../Autobahn/AutobahnServerResult.cs | 0 .../Autobahn/AutobahnSpec.cs | 0 .../Autobahn/AutobahnTester.cs | 0 .../Autobahn/Executable.cs | 0 .../Autobahn/Expectation.cs | 0 .../Autobahn/ServerSpec.cs | 0 .../Autobahn/Wstest.cs | 0 .../AutobahnTests.cs | 0 .../Helpers.cs | 0 .../Http.config | 0 ...pNetCore.WebSockets.ConformanceTest.csproj | 0 .../SkipIfWsTestNotPresentAttribute.cs | 0 .../AddWebSocketsTests.cs | 0 .../BufferStream.cs | 0 .../DuplexStream.cs | 0 .../IWebHostPortExtensions.cs | 0 .../KestrelWebSocketHelpers.cs | 0 ...icrosoft.AspNetCore.WebSockets.Test.csproj | 0 .../SendReceiveTests.cs | 0 .../WebSocketMiddlewareTests.cs | 0 .../WebSocketPair.cs | 0 version.props => src/WebSockets/version.props | 0 96 files changed, 643 deletions(-) delete mode 100644 .appveyor.yml delete mode 100644 .gitattributes delete mode 100644 .github/ISSUE_TEMPLATE.md delete mode 100644 .travis.yml delete mode 100644 .vsts-pipelines/builds/ci-internal.yml delete mode 100644 .vsts-pipelines/builds/ci-public.yml delete mode 100644 CONTRIBUTING.md delete mode 100644 LICENSE.txt delete mode 100644 NuGet.config delete mode 100644 build.cmd delete mode 100755 build.sh delete mode 100644 korebuild-lock.txt delete mode 100644 korebuild.json delete mode 100644 run.cmd delete mode 100644 run.ps1 delete mode 100755 run.sh rename .gitignore => src/WebSockets/.gitignore (100%) rename Directory.Build.props => src/WebSockets/Directory.Build.props (100%) rename Directory.Build.targets => src/WebSockets/Directory.Build.targets (100%) rename NuGetPackageVerifier.json => src/WebSockets/NuGetPackageVerifier.json (100%) rename README.md => src/WebSockets/README.md (100%) rename WebSockets.sln => src/WebSockets/WebSockets.sln (100%) rename {build => src/WebSockets/build}/Key.snk (100%) rename {build => src/WebSockets/build}/dependencies.props (100%) rename {build => src/WebSockets/build}/repo.props (100%) rename {build => src/WebSockets/build}/repo.targets (100%) rename {build => src/WebSockets/build}/setup-wstest.ps1 (100%) rename {build => src/WebSockets/build}/setup-wstest.sh (100%) rename {build => src/WebSockets/build}/sources.props (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppAspNet4/AutobahnTestAppAspNet4.csproj.aspnet4 (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppAspNet4/EchoSocket.ashx (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppAspNet4/EchoSocket.ashx.cs (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppAspNet4/Properties/AssemblyInfo.cs (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppAspNet4/Web.Debug.config (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppAspNet4/Web.Release.config (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppAspNet4/Web.config (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppAspNet4/packages.config (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppAspNet4/wstest-spec.json (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppHttpListener/App.config (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppHttpListener/AutobahnTestAppHttpListener.csproj.net461 (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppHttpListener/Program.cs (100%) rename {samples => src/WebSockets/samples}/AutobahnTestAppHttpListener/Properties/AssemblyInfo.cs (100%) rename {samples => src/WebSockets/samples}/EchoApp/EchoApp.csproj (100%) rename {samples => src/WebSockets/samples}/EchoApp/Program.cs (100%) rename {samples => src/WebSockets/samples}/EchoApp/Properties/launchSettings.json (100%) rename {samples => src/WebSockets/samples}/EchoApp/Startup.cs (100%) rename {samples => src/WebSockets/samples}/EchoApp/wwwroot/index.html (100%) rename {samples => src/WebSockets/samples}/TestServer/App.config (100%) rename {samples => src/WebSockets/samples}/TestServer/Program.cs (100%) rename {samples => src/WebSockets/samples}/TestServer/Properties/AssemblyInfo.cs (100%) rename {samples => src/WebSockets/samples}/TestServer/TestServer.csproj (100%) rename src/{ => WebSockets/src}/Directory.Build.props (100%) rename src/{ => WebSockets/src}/Microsoft.AspNetCore.WebSockets/ExtendedWebSocketAcceptContext.cs (100%) rename src/{ => WebSockets/src}/Microsoft.AspNetCore.WebSockets/Internal/Constants.cs (100%) rename src/{ => WebSockets/src}/Microsoft.AspNetCore.WebSockets/Internal/HandshakeHelpers.cs (100%) rename src/{ => WebSockets/src}/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj (100%) rename src/{ => WebSockets/src}/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs (100%) rename src/{ => WebSockets/src}/Microsoft.AspNetCore.WebSockets/WebSocketMiddlewareExtensions.cs (100%) rename src/{ => WebSockets/src}/Microsoft.AspNetCore.WebSockets/WebSocketOptions.cs (100%) rename src/{ => WebSockets/src}/Microsoft.AspNetCore.WebSockets/WebSocketsDependencyInjectionExtensions.cs (100%) rename src/{ => WebSockets/src}/Microsoft.AspNetCore.WebSockets/baseline.netcore.json (100%) rename {test => src/WebSockets/test}/AutobahnTestApp/AutobahnTestApp.csproj (100%) rename {test => src/WebSockets/test}/AutobahnTestApp/Program.cs (100%) rename {test => src/WebSockets/test}/AutobahnTestApp/Properties/launchSettings.json (100%) rename {test => src/WebSockets/test}/AutobahnTestApp/README.md (100%) rename {test => src/WebSockets/test}/AutobahnTestApp/Startup.cs (100%) rename {test => src/WebSockets/test}/AutobahnTestApp/TestResources/testCert.pfx (100%) rename {test => src/WebSockets/test}/AutobahnTestApp/TestResources/testCert.txt (100%) rename {test => src/WebSockets/test}/AutobahnTestApp/scripts/RunAutobahnTests.ps1 (100%) rename {test => src/WebSockets/test}/AutobahnTestApp/scripts/autobahn.spec.json (100%) rename {test => src/WebSockets/test}/Directory.Build.props (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnCaseResult.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnExpectations.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnResult.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnServerResult.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnSpec.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Expectation.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/ServerSpec.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Helpers.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Http.config (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.Test/AddWebSocketsTests.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.Test/IWebHostPortExtensions.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.Test/SendReceiveTests.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs (100%) rename {test => src/WebSockets/test}/Microsoft.AspNetCore.WebSockets.Test/WebSocketPair.cs (100%) rename version.props => src/WebSockets/version.props (100%) diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index d1d38b8e18..0000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,23 +0,0 @@ -init: -- git config --global core.autocrlf true -environment: - AUTOBAHN_SUITES_LOG: 1 - global: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - ASPNETCORE_WSTEST_PATH: $(APPVEYOR_BUILD_FOLDER)/vendor/virtualenv/Scripts/wstest.exe -cache: -- vendor\VCForPython27.msi -branches: - only: - - dev - - /^release\/.*$/ - - /^(.*\/)?ci-.*$/ -install: -- ps: .\build\setup-wstest.ps1 -build_script: -- ps: .\run.ps1 default-build -clone_depth: 1 -test: 'off' -deploy: 'off' -os: Visual Studio 2017 diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index c2f0f84273..0000000000 --- a/.gitattributes +++ /dev/null @@ -1,52 +0,0 @@ -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain - -*.jpg binary -*.png binary -*.gif binary - -*.cs text=auto diff=csharp -*.vb text=auto -*.resx text=auto -*.c text=auto -*.cpp text=auto -*.cxx text=auto -*.h text=auto -*.hxx text=auto -*.py text=auto -*.rb text=auto -*.java text=auto -*.html text=auto -*.htm text=auto -*.css text=auto -*.scss text=auto -*.sass text=auto -*.less text=auto -*.js text=auto -*.lisp text=auto -*.clj text=auto -*.sql text=auto -*.php text=auto -*.lua text=auto -*.m text=auto -*.asm text=auto -*.erl text=auto -*.fs text=auto -*.fsx text=auto -*.hs text=auto - -*.csproj text=auto -*.vbproj text=auto -*.fsproj text=auto -*.dbproj text=auto -*.sln text=auto eol=crlf - -*.sh eol=lf \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 101a084f0a..0000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,3 +0,0 @@ -THIS ISSUE TRACKER IS CLOSED - please log new issues here: https://github.com/aspnet/Home/issues - -For information about this change, see https://github.com/aspnet/Announcements/issues/283 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 28a92bb1fa..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: csharp -sudo: false -dist: trusty -env: - global: - - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - - AUTOBAHN_SUITES_LOG: 1 - - ASPNETCORE_WSTEST_PATH: $TRAVIS_BUILD_DIR/.virtualenv/bin/wstest -mono: none -python: -- pypy -os: -- linux -- osx -osx_image: xcode9.3 -addons: - apt: - packages: - - libunwind8 -branches: - only: - - dev - - /^release\/.*$/ - - /^(.*\/)?ci-.*$/ -install: -- ./build/setup-wstest.sh -script: -- ./build.sh diff --git a/.vsts-pipelines/builds/ci-internal.yml b/.vsts-pipelines/builds/ci-internal.yml deleted file mode 100644 index dc7b8a3cb9..0000000000 --- a/.vsts-pipelines/builds/ci-internal.yml +++ /dev/null @@ -1,13 +0,0 @@ -trigger: -- master -- release/* - -resources: - repositories: - - repository: buildtools - type: git - name: aspnet-BuildTools - ref: refs/heads/release/2.2 - -phases: -- template: .vsts-pipelines/templates/project-ci.yml@buildtools diff --git a/.vsts-pipelines/builds/ci-public.yml b/.vsts-pipelines/builds/ci-public.yml deleted file mode 100644 index f5087d9c30..0000000000 --- a/.vsts-pipelines/builds/ci-public.yml +++ /dev/null @@ -1,15 +0,0 @@ -trigger: -- master -- release/* - -# See https://github.com/aspnet/BuildTools -resources: - repositories: - - repository: buildtools - type: github - endpoint: DotNet-Bot GitHub Connection - name: aspnet/BuildTools - ref: refs/heads/release/2.2 - -phases: -- template: .vsts-pipelines/templates/project-ci.yml@buildtools diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 64ff041d5c..0000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,4 +0,0 @@ -Contributing -====== - -Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/dev/CONTRIBUTING.md) in the Home repo. diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 7b2956ecee..0000000000 --- a/LICENSE.txt +++ /dev/null @@ -1,14 +0,0 @@ -Copyright (c) .NET Foundation and Contributors - -All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software distributed -under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -CONDITIONS OF ANY KIND, either express or implied. See the License for the -specific language governing permissions and limitations under the License. diff --git a/NuGet.config b/NuGet.config deleted file mode 100644 index e32bddfd51..0000000000 --- a/NuGet.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/build.cmd b/build.cmd deleted file mode 100644 index c0050bda12..0000000000 --- a/build.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' default-build %*; exit $LASTEXITCODE" diff --git a/build.sh b/build.sh deleted file mode 100755 index 98a4b22765..0000000000 --- a/build.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -# Call "sync" between "chmod" and execution to prevent "text file busy" error in Docker (aufs) -chmod +x "$DIR/run.sh"; sync -"$DIR/run.sh" default-build "$@" diff --git a/korebuild-lock.txt b/korebuild-lock.txt deleted file mode 100644 index 3e92dd5543..0000000000 --- a/korebuild-lock.txt +++ /dev/null @@ -1,2 +0,0 @@ -version:2.2.0-preview2-20181004.6 -commithash:c04c4b2f5018632647f96210ab01876661302dac diff --git a/korebuild.json b/korebuild.json deleted file mode 100644 index d217d06e3e..0000000000 --- a/korebuild.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.2/tools/korebuild.schema.json", - "channel": "release/2.2" -} diff --git a/run.cmd b/run.cmd deleted file mode 100644 index d52d5c7e68..0000000000 --- a/run.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' %*; exit $LASTEXITCODE" diff --git a/run.ps1 b/run.ps1 deleted file mode 100644 index 34604c7175..0000000000 --- a/run.ps1 +++ /dev/null @@ -1,209 +0,0 @@ -#!/usr/bin/env powershell -#requires -version 4 - -<# -.SYNOPSIS -Executes KoreBuild commands. - -.DESCRIPTION -Downloads korebuild if required. Then executes the KoreBuild command. To see available commands, execute with `-Command help`. - -.PARAMETER Command -The KoreBuild command to run. - -.PARAMETER Path -The folder to build. Defaults to the folder containing this script. - -.PARAMETER Channel -The channel of KoreBuild to download. Overrides the value from the config file. - -.PARAMETER DotNetHome -The directory where .NET Core tools will be stored. - -.PARAMETER ToolsSource -The base url where build tools can be downloaded. Overrides the value from the config file. - -.PARAMETER Update -Updates KoreBuild to the latest version even if a lock file is present. - -.PARAMETER Reinstall -Re-installs KoreBuild - -.PARAMETER ConfigFile -The path to the configuration file that stores values. Defaults to korebuild.json. - -.PARAMETER ToolsSourceSuffix -The Suffix to append to the end of the ToolsSource. Useful for query strings in blob stores. - -.PARAMETER CI -Sets up CI specific settings and variables. - -.PARAMETER Arguments -Arguments to be passed to the command - -.NOTES -This function will create a file $PSScriptRoot/korebuild-lock.txt. This lock file can be committed to source, but does not have to be. -When the lockfile is not present, KoreBuild will create one using latest available version from $Channel. - -The $ConfigFile is expected to be an JSON file. It is optional, and the configuration values in it are optional as well. Any options set -in the file are overridden by command line parameters. - -.EXAMPLE -Example config file: -```json -{ - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/master/tools/korebuild.schema.json", - "channel": "master", - "toolsSource": "https://aspnetcore.blob.core.windows.net/buildtools" -} -``` -#> -[CmdletBinding(PositionalBinding = $false)] -param( - [Parameter(Mandatory = $true, Position = 0)] - [string]$Command, - [string]$Path = $PSScriptRoot, - [Alias('c')] - [string]$Channel, - [Alias('d')] - [string]$DotNetHome, - [Alias('s')] - [string]$ToolsSource, - [Alias('u')] - [switch]$Update, - [switch]$Reinstall, - [string]$ToolsSourceSuffix, - [string]$ConfigFile = $null, - [switch]$CI, - [Parameter(ValueFromRemainingArguments = $true)] - [string[]]$Arguments -) - -Set-StrictMode -Version 2 -$ErrorActionPreference = 'Stop' - -# -# Functions -# - -function Get-KoreBuild { - - $lockFile = Join-Path $Path 'korebuild-lock.txt' - - if (!(Test-Path $lockFile) -or $Update) { - Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile $ToolsSourceSuffix - } - - $version = Get-Content $lockFile | Where-Object { $_ -like 'version:*' } | Select-Object -first 1 - if (!$version) { - Write-Error "Failed to parse version from $lockFile. Expected a line that begins with 'version:'" - } - $version = $version.TrimStart('version:').Trim() - $korebuildPath = Join-Paths $DotNetHome ('buildtools', 'korebuild', $version) - - if ($Reinstall -and (Test-Path $korebuildPath)) { - Remove-Item -Force -Recurse $korebuildPath - } - - if (!(Test-Path $korebuildPath)) { - Write-Host -ForegroundColor Magenta "Downloading KoreBuild $version" - New-Item -ItemType Directory -Path $korebuildPath | Out-Null - $remotePath = "$ToolsSource/korebuild/artifacts/$version/korebuild.$version.zip" - - try { - $tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip" - Get-RemoteFile $remotePath $tmpfile $ToolsSourceSuffix - if (Get-Command -Name 'Microsoft.PowerShell.Archive\Expand-Archive' -ErrorAction Ignore) { - # Use built-in commands where possible as they are cross-plat compatible - Microsoft.PowerShell.Archive\Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath - } - else { - # Fallback to old approach for old installations of PowerShell - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::ExtractToDirectory($tmpfile, $korebuildPath) - } - } - catch { - Remove-Item -Recurse -Force $korebuildPath -ErrorAction Ignore - throw - } - finally { - Remove-Item $tmpfile -ErrorAction Ignore - } - } - - return $korebuildPath -} - -function Join-Paths([string]$path, [string[]]$childPaths) { - $childPaths | ForEach-Object { $path = Join-Path $path $_ } - return $path -} - -function Get-RemoteFile([string]$RemotePath, [string]$LocalPath, [string]$RemoteSuffix) { - if ($RemotePath -notlike 'http*') { - Copy-Item $RemotePath $LocalPath - return - } - - $retries = 10 - while ($retries -gt 0) { - $retries -= 1 - try { - Invoke-WebRequest -UseBasicParsing -Uri $($RemotePath + $RemoteSuffix) -OutFile $LocalPath - return - } - catch { - Write-Verbose "Request failed. $retries retries remaining" - } - } - - Write-Error "Download failed: '$RemotePath'." -} - -# -# Main -# - -# Load configuration or set defaults - -$Path = Resolve-Path $Path -if (!$ConfigFile) { $ConfigFile = Join-Path $Path 'korebuild.json' } - -if (Test-Path $ConfigFile) { - try { - $config = Get-Content -Raw -Encoding UTF8 -Path $ConfigFile | ConvertFrom-Json - if ($config) { - if (!($Channel) -and (Get-Member -Name 'channel' -InputObject $config)) { [string] $Channel = $config.channel } - if (!($ToolsSource) -and (Get-Member -Name 'toolsSource' -InputObject $config)) { [string] $ToolsSource = $config.toolsSource} - } - } - catch { - Write-Host -ForegroundColor Red $Error[0] - Write-Error "$ConfigFile contains invalid JSON." - exit 1 - } -} - -if (!$DotNetHome) { - $DotNetHome = if ($env:DOTNET_HOME) { $env:DOTNET_HOME } ` - elseif ($env:USERPROFILE) { Join-Path $env:USERPROFILE '.dotnet'} ` - elseif ($env:HOME) {Join-Path $env:HOME '.dotnet'}` - else { Join-Path $PSScriptRoot '.dotnet'} -} - -if (!$Channel) { $Channel = 'master' } -if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' } - -# Execute - -$korebuildPath = Get-KoreBuild -Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') - -try { - Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile -CI:$CI - Invoke-KoreBuildCommand $Command @Arguments -} -finally { - Remove-Module 'KoreBuild' -ErrorAction Ignore -} diff --git a/run.sh b/run.sh deleted file mode 100755 index 4c1fed5646..0000000000 --- a/run.sh +++ /dev/null @@ -1,256 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -# -# variables -# - -RESET="\033[0m" -RED="\033[0;31m" -YELLOW="\033[0;33m" -MAGENTA="\033[0;95m" -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" -verbose=false -update=false -reinstall=false -repo_path="$DIR" -channel='' -tools_source='' -tools_source_suffix='' -ci=false - -# -# Functions -# -__usage() { - echo "Usage: $(basename "${BASH_SOURCE[0]}") command [options] [[--] ...]" - echo "" - echo "Arguments:" - echo " command The command to be run." - echo " ... Arguments passed to the command. Variable number of arguments allowed." - echo "" - echo "Options:" - echo " --verbose Show verbose output." - echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." - echo " --config-file The path to the configuration file that stores values. Defaults to korebuild.json." - echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." - echo " --path The directory to build. Defaults to the directory containing the script." - echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." - echo " --tools-source-suffix|-ToolsSourceSuffix The suffix to append to tools-source. Useful for query strings." - echo " -u|--update Update to the latest KoreBuild even if the lock file is present." - echo " --reinstall Reinstall KoreBuild." - echo " --ci Apply CI specific settings and environment variables." - echo "" - echo "Description:" - echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." - echo " When the lockfile is not present, KoreBuild will create one using latest available version from \$channel." - - if [[ "${1:-}" != '--no-exit' ]]; then - exit 2 - fi -} - -get_korebuild() { - local version - local lock_file="$repo_path/korebuild-lock.txt" - if [ ! -f "$lock_file" ] || [ "$update" = true ]; then - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" "$tools_source_suffix" - fi - version="$(grep 'version:*' -m 1 "$lock_file")" - if [[ "$version" == '' ]]; then - __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" - return 1 - fi - version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" - local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" - - if [ "$reinstall" = true ] && [ -d "$korebuild_path" ]; then - rm -rf "$korebuild_path" - fi - - { - if [ ! -d "$korebuild_path" ]; then - mkdir -p "$korebuild_path" - local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" - tmpfile="$(mktemp)" - echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" - if __get_remote_file "$remote_path" "$tmpfile" "$tools_source_suffix"; then - unzip -q -d "$korebuild_path" "$tmpfile" - fi - rm "$tmpfile" || true - fi - - source "$korebuild_path/KoreBuild.sh" - } || { - if [ -d "$korebuild_path" ]; then - echo "Cleaning up after failed installation" - rm -rf "$korebuild_path" || true - fi - return 1 - } -} - -__error() { - echo -e "${RED}error: $*${RESET}" 1>&2 -} - -__warn() { - echo -e "${YELLOW}warning: $*${RESET}" -} - -__machine_has() { - hash "$1" > /dev/null 2>&1 - return $? -} - -__get_remote_file() { - local remote_path=$1 - local local_path=$2 - local remote_path_suffix=$3 - - if [[ "$remote_path" != 'http'* ]]; then - cp "$remote_path" "$local_path" - return 0 - fi - - local failed=false - if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "${remote_path}${remote_path_suffix}" || failed=true - else - failed=true - fi - - if [ "$failed" = true ] && __machine_has curl; then - failed=false - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "${remote_path}${remote_path_suffix}" || failed=true - fi - - if [ "$failed" = true ]; then - __error "Download failed: $remote_path" 1>&2 - return 1 - fi -} - -# -# main -# - -command="${1:-}" -shift - -while [[ $# -gt 0 ]]; do - case $1 in - -\?|-h|--help) - __usage --no-exit - exit 0 - ;; - -c|--channel|-Channel) - shift - channel="${1:-}" - [ -z "$channel" ] && __usage - ;; - --config-file|-ConfigFile) - shift - config_file="${1:-}" - [ -z "$config_file" ] && __usage - if [ ! -f "$config_file" ]; then - __error "Invalid value for --config-file. $config_file does not exist." - exit 1 - fi - ;; - -d|--dotnet-home|-DotNetHome) - shift - DOTNET_HOME="${1:-}" - [ -z "$DOTNET_HOME" ] && __usage - ;; - --path|-Path) - shift - repo_path="${1:-}" - [ -z "$repo_path" ] && __usage - ;; - -s|--tools-source|-ToolsSource) - shift - tools_source="${1:-}" - [ -z "$tools_source" ] && __usage - ;; - --tools-source-suffix|-ToolsSourceSuffix) - shift - tools_source_suffix="${1:-}" - [ -z "$tools_source_suffix" ] && __usage - ;; - -u|--update|-Update) - update=true - ;; - --reinstall|-[Rr]einstall) - reinstall=true - ;; - --ci|-[Cc][Ii]) - ci=true - ;; - --verbose|-Verbose) - verbose=true - ;; - --) - shift - break - ;; - *) - break - ;; - esac - shift -done - -if ! __machine_has unzip; then - __error 'Missing required command: unzip' - exit 1 -fi - -if ! __machine_has curl && ! __machine_has wget; then - __error 'Missing required command. Either wget or curl is required.' - exit 1 -fi - -[ -z "${config_file:-}" ] && config_file="$repo_path/korebuild.json" -if [ -f "$config_file" ]; then - if __machine_has jq ; then - if jq '.' "$config_file" >/dev/null ; then - config_channel="$(jq -r 'select(.channel!=null) | .channel' "$config_file")" - config_tools_source="$(jq -r 'select(.toolsSource!=null) | .toolsSource' "$config_file")" - else - __error "$config_file contains invalid JSON." - exit 1 - fi - elif __machine_has python ; then - if python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then - config_channel="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')")" - config_tools_source="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")" - else - __error "$config_file contains invalid JSON." - exit 1 - fi - elif __machine_has python3 ; then - if python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then - config_channel="$(python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')")" - config_tools_source="$(python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")" - else - __error "$config_file contains invalid JSON." - exit 1 - fi - else - __error 'Missing required command: jq or python. Could not parse the JSON file.' - exit 1 - fi - - [ ! -z "${config_channel:-}" ] && channel="$config_channel" - [ ! -z "${config_tools_source:-}" ] && tools_source="$config_tools_source" -fi - -[ -z "$channel" ] && channel='master' -[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' - -get_korebuild -set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" "$ci" -invoke_korebuild_command "$command" "$@" diff --git a/.gitignore b/src/WebSockets/.gitignore similarity index 100% rename from .gitignore rename to src/WebSockets/.gitignore diff --git a/Directory.Build.props b/src/WebSockets/Directory.Build.props similarity index 100% rename from Directory.Build.props rename to src/WebSockets/Directory.Build.props diff --git a/Directory.Build.targets b/src/WebSockets/Directory.Build.targets similarity index 100% rename from Directory.Build.targets rename to src/WebSockets/Directory.Build.targets diff --git a/NuGetPackageVerifier.json b/src/WebSockets/NuGetPackageVerifier.json similarity index 100% rename from NuGetPackageVerifier.json rename to src/WebSockets/NuGetPackageVerifier.json diff --git a/README.md b/src/WebSockets/README.md similarity index 100% rename from README.md rename to src/WebSockets/README.md diff --git a/WebSockets.sln b/src/WebSockets/WebSockets.sln similarity index 100% rename from WebSockets.sln rename to src/WebSockets/WebSockets.sln diff --git a/build/Key.snk b/src/WebSockets/build/Key.snk similarity index 100% rename from build/Key.snk rename to src/WebSockets/build/Key.snk diff --git a/build/dependencies.props b/src/WebSockets/build/dependencies.props similarity index 100% rename from build/dependencies.props rename to src/WebSockets/build/dependencies.props diff --git a/build/repo.props b/src/WebSockets/build/repo.props similarity index 100% rename from build/repo.props rename to src/WebSockets/build/repo.props diff --git a/build/repo.targets b/src/WebSockets/build/repo.targets similarity index 100% rename from build/repo.targets rename to src/WebSockets/build/repo.targets diff --git a/build/setup-wstest.ps1 b/src/WebSockets/build/setup-wstest.ps1 similarity index 100% rename from build/setup-wstest.ps1 rename to src/WebSockets/build/setup-wstest.ps1 diff --git a/build/setup-wstest.sh b/src/WebSockets/build/setup-wstest.sh similarity index 100% rename from build/setup-wstest.sh rename to src/WebSockets/build/setup-wstest.sh diff --git a/build/sources.props b/src/WebSockets/build/sources.props similarity index 100% rename from build/sources.props rename to src/WebSockets/build/sources.props diff --git a/samples/AutobahnTestAppAspNet4/AutobahnTestAppAspNet4.csproj.aspnet4 b/src/WebSockets/samples/AutobahnTestAppAspNet4/AutobahnTestAppAspNet4.csproj.aspnet4 similarity index 100% rename from samples/AutobahnTestAppAspNet4/AutobahnTestAppAspNet4.csproj.aspnet4 rename to src/WebSockets/samples/AutobahnTestAppAspNet4/AutobahnTestAppAspNet4.csproj.aspnet4 diff --git a/samples/AutobahnTestAppAspNet4/EchoSocket.ashx b/src/WebSockets/samples/AutobahnTestAppAspNet4/EchoSocket.ashx similarity index 100% rename from samples/AutobahnTestAppAspNet4/EchoSocket.ashx rename to src/WebSockets/samples/AutobahnTestAppAspNet4/EchoSocket.ashx diff --git a/samples/AutobahnTestAppAspNet4/EchoSocket.ashx.cs b/src/WebSockets/samples/AutobahnTestAppAspNet4/EchoSocket.ashx.cs similarity index 100% rename from samples/AutobahnTestAppAspNet4/EchoSocket.ashx.cs rename to src/WebSockets/samples/AutobahnTestAppAspNet4/EchoSocket.ashx.cs diff --git a/samples/AutobahnTestAppAspNet4/Properties/AssemblyInfo.cs b/src/WebSockets/samples/AutobahnTestAppAspNet4/Properties/AssemblyInfo.cs similarity index 100% rename from samples/AutobahnTestAppAspNet4/Properties/AssemblyInfo.cs rename to src/WebSockets/samples/AutobahnTestAppAspNet4/Properties/AssemblyInfo.cs diff --git a/samples/AutobahnTestAppAspNet4/Web.Debug.config b/src/WebSockets/samples/AutobahnTestAppAspNet4/Web.Debug.config similarity index 100% rename from samples/AutobahnTestAppAspNet4/Web.Debug.config rename to src/WebSockets/samples/AutobahnTestAppAspNet4/Web.Debug.config diff --git a/samples/AutobahnTestAppAspNet4/Web.Release.config b/src/WebSockets/samples/AutobahnTestAppAspNet4/Web.Release.config similarity index 100% rename from samples/AutobahnTestAppAspNet4/Web.Release.config rename to src/WebSockets/samples/AutobahnTestAppAspNet4/Web.Release.config diff --git a/samples/AutobahnTestAppAspNet4/Web.config b/src/WebSockets/samples/AutobahnTestAppAspNet4/Web.config similarity index 100% rename from samples/AutobahnTestAppAspNet4/Web.config rename to src/WebSockets/samples/AutobahnTestAppAspNet4/Web.config diff --git a/samples/AutobahnTestAppAspNet4/packages.config b/src/WebSockets/samples/AutobahnTestAppAspNet4/packages.config similarity index 100% rename from samples/AutobahnTestAppAspNet4/packages.config rename to src/WebSockets/samples/AutobahnTestAppAspNet4/packages.config diff --git a/samples/AutobahnTestAppAspNet4/wstest-spec.json b/src/WebSockets/samples/AutobahnTestAppAspNet4/wstest-spec.json similarity index 100% rename from samples/AutobahnTestAppAspNet4/wstest-spec.json rename to src/WebSockets/samples/AutobahnTestAppAspNet4/wstest-spec.json diff --git a/samples/AutobahnTestAppHttpListener/App.config b/src/WebSockets/samples/AutobahnTestAppHttpListener/App.config similarity index 100% rename from samples/AutobahnTestAppHttpListener/App.config rename to src/WebSockets/samples/AutobahnTestAppHttpListener/App.config diff --git a/samples/AutobahnTestAppHttpListener/AutobahnTestAppHttpListener.csproj.net461 b/src/WebSockets/samples/AutobahnTestAppHttpListener/AutobahnTestAppHttpListener.csproj.net461 similarity index 100% rename from samples/AutobahnTestAppHttpListener/AutobahnTestAppHttpListener.csproj.net461 rename to src/WebSockets/samples/AutobahnTestAppHttpListener/AutobahnTestAppHttpListener.csproj.net461 diff --git a/samples/AutobahnTestAppHttpListener/Program.cs b/src/WebSockets/samples/AutobahnTestAppHttpListener/Program.cs similarity index 100% rename from samples/AutobahnTestAppHttpListener/Program.cs rename to src/WebSockets/samples/AutobahnTestAppHttpListener/Program.cs diff --git a/samples/AutobahnTestAppHttpListener/Properties/AssemblyInfo.cs b/src/WebSockets/samples/AutobahnTestAppHttpListener/Properties/AssemblyInfo.cs similarity index 100% rename from samples/AutobahnTestAppHttpListener/Properties/AssemblyInfo.cs rename to src/WebSockets/samples/AutobahnTestAppHttpListener/Properties/AssemblyInfo.cs diff --git a/samples/EchoApp/EchoApp.csproj b/src/WebSockets/samples/EchoApp/EchoApp.csproj similarity index 100% rename from samples/EchoApp/EchoApp.csproj rename to src/WebSockets/samples/EchoApp/EchoApp.csproj diff --git a/samples/EchoApp/Program.cs b/src/WebSockets/samples/EchoApp/Program.cs similarity index 100% rename from samples/EchoApp/Program.cs rename to src/WebSockets/samples/EchoApp/Program.cs diff --git a/samples/EchoApp/Properties/launchSettings.json b/src/WebSockets/samples/EchoApp/Properties/launchSettings.json similarity index 100% rename from samples/EchoApp/Properties/launchSettings.json rename to src/WebSockets/samples/EchoApp/Properties/launchSettings.json diff --git a/samples/EchoApp/Startup.cs b/src/WebSockets/samples/EchoApp/Startup.cs similarity index 100% rename from samples/EchoApp/Startup.cs rename to src/WebSockets/samples/EchoApp/Startup.cs diff --git a/samples/EchoApp/wwwroot/index.html b/src/WebSockets/samples/EchoApp/wwwroot/index.html similarity index 100% rename from samples/EchoApp/wwwroot/index.html rename to src/WebSockets/samples/EchoApp/wwwroot/index.html diff --git a/samples/TestServer/App.config b/src/WebSockets/samples/TestServer/App.config similarity index 100% rename from samples/TestServer/App.config rename to src/WebSockets/samples/TestServer/App.config diff --git a/samples/TestServer/Program.cs b/src/WebSockets/samples/TestServer/Program.cs similarity index 100% rename from samples/TestServer/Program.cs rename to src/WebSockets/samples/TestServer/Program.cs diff --git a/samples/TestServer/Properties/AssemblyInfo.cs b/src/WebSockets/samples/TestServer/Properties/AssemblyInfo.cs similarity index 100% rename from samples/TestServer/Properties/AssemblyInfo.cs rename to src/WebSockets/samples/TestServer/Properties/AssemblyInfo.cs diff --git a/samples/TestServer/TestServer.csproj b/src/WebSockets/samples/TestServer/TestServer.csproj similarity index 100% rename from samples/TestServer/TestServer.csproj rename to src/WebSockets/samples/TestServer/TestServer.csproj diff --git a/src/Directory.Build.props b/src/WebSockets/src/Directory.Build.props similarity index 100% rename from src/Directory.Build.props rename to src/WebSockets/src/Directory.Build.props diff --git a/src/Microsoft.AspNetCore.WebSockets/ExtendedWebSocketAcceptContext.cs b/src/WebSockets/src/Microsoft.AspNetCore.WebSockets/ExtendedWebSocketAcceptContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.WebSockets/ExtendedWebSocketAcceptContext.cs rename to src/WebSockets/src/Microsoft.AspNetCore.WebSockets/ExtendedWebSocketAcceptContext.cs diff --git a/src/Microsoft.AspNetCore.WebSockets/Internal/Constants.cs b/src/WebSockets/src/Microsoft.AspNetCore.WebSockets/Internal/Constants.cs similarity index 100% rename from src/Microsoft.AspNetCore.WebSockets/Internal/Constants.cs rename to src/WebSockets/src/Microsoft.AspNetCore.WebSockets/Internal/Constants.cs diff --git a/src/Microsoft.AspNetCore.WebSockets/Internal/HandshakeHelpers.cs b/src/WebSockets/src/Microsoft.AspNetCore.WebSockets/Internal/HandshakeHelpers.cs similarity index 100% rename from src/Microsoft.AspNetCore.WebSockets/Internal/HandshakeHelpers.cs rename to src/WebSockets/src/Microsoft.AspNetCore.WebSockets/Internal/HandshakeHelpers.cs diff --git a/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj b/src/WebSockets/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj similarity index 100% rename from src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj rename to src/WebSockets/src/Microsoft.AspNetCore.WebSockets/Microsoft.AspNetCore.WebSockets.csproj diff --git a/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs b/src/WebSockets/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs similarity index 100% rename from src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs rename to src/WebSockets/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddleware.cs diff --git a/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddlewareExtensions.cs b/src/WebSockets/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddlewareExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.WebSockets/WebSocketMiddlewareExtensions.cs rename to src/WebSockets/src/Microsoft.AspNetCore.WebSockets/WebSocketMiddlewareExtensions.cs diff --git a/src/Microsoft.AspNetCore.WebSockets/WebSocketOptions.cs b/src/WebSockets/src/Microsoft.AspNetCore.WebSockets/WebSocketOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.WebSockets/WebSocketOptions.cs rename to src/WebSockets/src/Microsoft.AspNetCore.WebSockets/WebSocketOptions.cs diff --git a/src/Microsoft.AspNetCore.WebSockets/WebSocketsDependencyInjectionExtensions.cs b/src/WebSockets/src/Microsoft.AspNetCore.WebSockets/WebSocketsDependencyInjectionExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.WebSockets/WebSocketsDependencyInjectionExtensions.cs rename to src/WebSockets/src/Microsoft.AspNetCore.WebSockets/WebSocketsDependencyInjectionExtensions.cs diff --git a/src/Microsoft.AspNetCore.WebSockets/baseline.netcore.json b/src/WebSockets/src/Microsoft.AspNetCore.WebSockets/baseline.netcore.json similarity index 100% rename from src/Microsoft.AspNetCore.WebSockets/baseline.netcore.json rename to src/WebSockets/src/Microsoft.AspNetCore.WebSockets/baseline.netcore.json diff --git a/test/AutobahnTestApp/AutobahnTestApp.csproj b/src/WebSockets/test/AutobahnTestApp/AutobahnTestApp.csproj similarity index 100% rename from test/AutobahnTestApp/AutobahnTestApp.csproj rename to src/WebSockets/test/AutobahnTestApp/AutobahnTestApp.csproj diff --git a/test/AutobahnTestApp/Program.cs b/src/WebSockets/test/AutobahnTestApp/Program.cs similarity index 100% rename from test/AutobahnTestApp/Program.cs rename to src/WebSockets/test/AutobahnTestApp/Program.cs diff --git a/test/AutobahnTestApp/Properties/launchSettings.json b/src/WebSockets/test/AutobahnTestApp/Properties/launchSettings.json similarity index 100% rename from test/AutobahnTestApp/Properties/launchSettings.json rename to src/WebSockets/test/AutobahnTestApp/Properties/launchSettings.json diff --git a/test/AutobahnTestApp/README.md b/src/WebSockets/test/AutobahnTestApp/README.md similarity index 100% rename from test/AutobahnTestApp/README.md rename to src/WebSockets/test/AutobahnTestApp/README.md diff --git a/test/AutobahnTestApp/Startup.cs b/src/WebSockets/test/AutobahnTestApp/Startup.cs similarity index 100% rename from test/AutobahnTestApp/Startup.cs rename to src/WebSockets/test/AutobahnTestApp/Startup.cs diff --git a/test/AutobahnTestApp/TestResources/testCert.pfx b/src/WebSockets/test/AutobahnTestApp/TestResources/testCert.pfx similarity index 100% rename from test/AutobahnTestApp/TestResources/testCert.pfx rename to src/WebSockets/test/AutobahnTestApp/TestResources/testCert.pfx diff --git a/test/AutobahnTestApp/TestResources/testCert.txt b/src/WebSockets/test/AutobahnTestApp/TestResources/testCert.txt similarity index 100% rename from test/AutobahnTestApp/TestResources/testCert.txt rename to src/WebSockets/test/AutobahnTestApp/TestResources/testCert.txt diff --git a/test/AutobahnTestApp/scripts/RunAutobahnTests.ps1 b/src/WebSockets/test/AutobahnTestApp/scripts/RunAutobahnTests.ps1 similarity index 100% rename from test/AutobahnTestApp/scripts/RunAutobahnTests.ps1 rename to src/WebSockets/test/AutobahnTestApp/scripts/RunAutobahnTests.ps1 diff --git a/test/AutobahnTestApp/scripts/autobahn.spec.json b/src/WebSockets/test/AutobahnTestApp/scripts/autobahn.spec.json similarity index 100% rename from test/AutobahnTestApp/scripts/autobahn.spec.json rename to src/WebSockets/test/AutobahnTestApp/scripts/autobahn.spec.json diff --git a/test/Directory.Build.props b/src/WebSockets/test/Directory.Build.props similarity index 100% rename from test/Directory.Build.props rename to src/WebSockets/test/Directory.Build.props diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnCaseResult.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnCaseResult.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnCaseResult.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnCaseResult.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnExpectations.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnExpectations.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnExpectations.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnExpectations.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnResult.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnResult.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnResult.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnResult.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnServerResult.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnServerResult.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnServerResult.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnServerResult.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnSpec.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnSpec.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnSpec.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnSpec.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Expectation.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Expectation.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Expectation.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Expectation.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/ServerSpec.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/ServerSpec.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/ServerSpec.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/ServerSpec.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Wstest.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/AutobahnTests.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Helpers.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Helpers.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Helpers.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Helpers.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Http.config b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Http.config similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Http.config rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Http.config diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Microsoft.AspNetCore.WebSockets.ConformanceTest.csproj diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/SkipIfWsTestNotPresentAttribute.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/AddWebSocketsTests.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/AddWebSocketsTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Test/AddWebSocketsTests.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/AddWebSocketsTests.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/BufferStream.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/DuplexStream.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/IWebHostPortExtensions.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/IWebHostPortExtensions.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Test/IWebHostPortExtensions.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/IWebHostPortExtensions.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/SendReceiveTests.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/SendReceiveTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Test/SendReceiveTests.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/SendReceiveTests.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketPair.cs b/src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketPair.cs similarity index 100% rename from test/Microsoft.AspNetCore.WebSockets.Test/WebSocketPair.cs rename to src/WebSockets/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketPair.cs diff --git a/version.props b/src/WebSockets/version.props similarity index 100% rename from version.props rename to src/WebSockets/version.props