diff --git a/examples/Titanium.Web.Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.csproj b/examples/Titanium.Web.Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.csproj index 12327d6e3..d9a1156b4 100644 --- a/examples/Titanium.Web.Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.csproj +++ b/examples/Titanium.Web.Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.csproj @@ -72,8 +72,8 @@ true - - ..\..\packages\StreamExtended.1.0.179\lib\net45\StreamExtended.dll + + ..\..\src\packages\StreamExtended.1.0.183-beta\lib\net45\StreamExtended.dll diff --git a/examples/Titanium.Web.Proxy.Examples.Wpf/packages.config b/examples/Titanium.Web.Proxy.Examples.Wpf/packages.config index f05fe4629..72c976674 100644 --- a/examples/Titanium.Web.Proxy.Examples.Wpf/packages.config +++ b/examples/Titanium.Web.Proxy.Examples.Wpf/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/src/Titanium.Web.Proxy/Helpers/TcpHelper.cs b/src/Titanium.Web.Proxy/Helpers/TcpHelper.cs index 22e23c594..f321c2e24 100644 --- a/src/Titanium.Web.Proxy/Helpers/TcpHelper.cs +++ b/src/Titanium.Web.Proxy/Helpers/TcpHelper.cs @@ -93,112 +93,6 @@ private static uint toNetworkByteOrder(uint port) return ((port >> 8) & 0x00FF00FFu) | ((port << 8) & 0xFF00FF00u); } - /// - /// relays the input clientStream to the server at the specified host name and port with the given httpCmd and headers - /// as prefix - /// Usefull for websocket requests - /// Asynchronous Programming Model, which does not throw exceptions when the socket is closed - /// - /// - /// - /// - /// - /// - /// - /// - /// - internal static async Task SendRawApm(Stream clientStream, Stream serverStream, - IBufferPool bufferPool, int bufferSize, - Action onDataSend, Action onDataReceive, - CancellationTokenSource cancellationTokenSource, - ExceptionHandler exceptionFunc) - { - var taskCompletionSource = new TaskCompletionSource(); - cancellationTokenSource.Token.Register(() => taskCompletionSource.TrySetResult(true)); - - // Now async relay all server=>client & client=>server data - var clientBuffer = bufferPool.GetBuffer(bufferSize); - var serverBuffer = bufferPool.GetBuffer(bufferSize); - try - { - beginRead(clientStream, serverStream, clientBuffer, onDataSend, cancellationTokenSource, exceptionFunc); - beginRead(serverStream, clientStream, serverBuffer, onDataReceive, cancellationTokenSource, - exceptionFunc); - await taskCompletionSource.Task; - } - finally - { - bufferPool.ReturnBuffer(clientBuffer); - bufferPool.ReturnBuffer(serverBuffer); - } - } - - private static void beginRead(Stream inputStream, Stream outputStream, byte[] buffer, - Action onCopy, CancellationTokenSource cancellationTokenSource, - ExceptionHandler exceptionFunc) - { - if (cancellationTokenSource.IsCancellationRequested) - { - return; - } - - bool readFlag = false; - var readCallback = (AsyncCallback)(ar => - { - if (cancellationTokenSource.IsCancellationRequested || readFlag) - { - return; - } - - readFlag = true; - - try - { - int read = inputStream.EndRead(ar); - if (read <= 0) - { - cancellationTokenSource.Cancel(); - return; - } - - onCopy?.Invoke(buffer, 0, read); - - var writeCallback = (AsyncCallback)(ar2 => - { - if (cancellationTokenSource.IsCancellationRequested) - { - return; - } - - try - { - outputStream.EndWrite(ar2); - beginRead(inputStream, outputStream, buffer, onCopy, cancellationTokenSource, - exceptionFunc); - } - catch (IOException ex) - { - cancellationTokenSource.Cancel(); - exceptionFunc(ex); - } - }); - - outputStream.BeginWrite(buffer, 0, read, writeCallback, null); - } - catch (IOException ex) - { - cancellationTokenSource.Cancel(); - exceptionFunc(ex); - } - }); - - var readResult = inputStream.BeginRead(buffer, 0, buffer.Length, readCallback, null); - if (readResult.CompletedSynchronously) - { - readCallback(readResult); - } - } - /// /// relays the input clientStream to the server at the specified host name and port with the given httpCmd and headers /// as prefix diff --git a/src/Titanium.Web.Proxy/Titanium.Web.Proxy.csproj b/src/Titanium.Web.Proxy/Titanium.Web.Proxy.csproj index 6f4ed48d0..b5d301479 100644 --- a/src/Titanium.Web.Proxy/Titanium.Web.Proxy.csproj +++ b/src/Titanium.Web.Proxy/Titanium.Web.Proxy.csproj @@ -14,8 +14,8 @@ - - + +