Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #92 from loudej/updating-ver

Bumping up to OWIN 0.12 ctp4
  • Loading branch information...
commit 6e2eb9a0438db8ba3347ad0cd93e182cc88a3e1b 2 parents 4792b7d + b2b1765
@loudej loudej authored
Showing with 196 additions and 226 deletions.
  1. +1 −1  Sakefile.shade
  2. +2 −2 src/Adapters/Gate.Adapters.AspNetWebApi/Gate.Adapters.AspNetWebApi.csproj
  3. +8 −9 src/Adapters/Gate.Adapters.AspNetWebApi/WebApiAdapter.cs
  4. +1 −1  src/Adapters/Gate.Adapters.AspNetWebApi/packages.config
  5. +3 −2 src/Adapters/Gate.Adapters.Nancy/Gate.Adapters.Nancy.csproj
  6. +3 −3 src/Adapters/Gate.Adapters.Nancy/NancyAdapter.cs
  7. +1 −1  src/Adapters/Gate.Adapters.Nancy/packages.config
  8. +1 −1  src/CommonAssemblyInfo.cs
  9. +2 −14 src/Hosts/Gate.Hosts.AspNet/AppHandler.cs
  10. +2 −2 src/Hosts/Gate.Hosts.AspNet/Gate.Hosts.AspNet.csproj
  11. +1 −1  src/Hosts/Gate.Hosts.AspNet/packages.config
  12. +2 −2 src/Hosts/Gate.Hosts.Firefly/Gate.Hosts.Firefly.csproj
  13. +1 −1  src/Hosts/Gate.Hosts.Firefly/packages.config
  14. +2 −2 src/Hosts/Gate.Hosts.HttpListener/Gate.Hosts.HttpListener.csproj
  15. +1 −1  src/Hosts/Gate.Hosts.HttpListener/ServerFactory.cs
  16. +1 −1  src/Hosts/Gate.Hosts.HttpListener/packages.config
  17. +4 −2 src/Hosts/Gate.Hosts.Kayak/DataProducer.cs
  18. +2 −2 src/Hosts/Gate.Hosts.Kayak/Gate.Hosts.Kayak.csproj
  19. +0 −1  src/Hosts/Gate.Hosts.Kayak/GateRequestDelegate.cs
  20. +1 −1  src/Hosts/Gate.Hosts.Kayak/packages.config
  21. +5 −4 src/Hosts/Gate.Hosts/ErrorPage.cs
  22. +9 −12 src/Hosts/Gate.Hosts/ExecutionContextPerRequest.cs
  23. +3 −2 src/Hosts/Gate.Hosts/Gate.Hosts.csproj
  24. +1 −1  src/Hosts/Gate.Hosts/packages.config
  25. +5 −22 src/Main/Gate.Builder/Adapters.cs
  26. +0 −2  src/Main/Gate.Builder/AppBuilder.cs
  27. +3 −2 src/Main/Gate.Builder/Gate.Builder.csproj
  28. +1 −1  src/Main/Gate.Builder/NotFound.cs
  29. +1 −1  src/Main/Gate.Builder/packages.config
  30. +3 −3 src/Main/Gate.Middleware/Chunked.cs
  31. +7 −8 src/Main/Gate.Middleware/ContentLength.cs
  32. +2 −2 src/Main/Gate.Middleware/Gate.Middleware.csproj
  33. +1 −1  src/Main/Gate.Middleware/NotFound.cs
  34. +3 −3 src/Main/Gate.Middleware/ShowExceptions.cs
  35. +5 −5 src/Main/Gate.Middleware/StaticFiles/FileBody.cs
  36. +2 −1  src/Main/Gate.Middleware/StaticFiles/FileServer.cs
  37. +4 −4 src/Main/Gate.Middleware/StaticFiles/TextBody.cs
  38. +1 −1  src/Main/Gate.Middleware/packages.config
  39. +3 −2 src/Main/Gate/Gate.csproj
  40. +1 −0  src/Main/Gate/OwinConstants.cs
  41. +7 −8 src/Main/Gate/Request.cs
  42. +14 −14 src/Main/Gate/Response.cs
  43. +1 −2  src/Main/Gate/ResponseStream.cs
  44. +1 −1  src/Main/Gate/packages.config
  45. +3 −2 src/Samples/Sample.AspNetWebApi/Sample.AspNetWebApi.csproj
  46. +1 −1  src/Samples/Sample.AspNetWebApi/packages.config
  47. +3 −2 src/Samples/Sample.HelloWorld/Sample.HelloWorld.csproj
  48. +1 −1  src/Samples/Sample.HelloWorld/packages.config
  49. +2 −2 src/Samples/Sample.Nancy/Sample.Nancy.csproj
  50. +1 −1  src/Samples/Sample.Nancy/packages.config
  51. +2 −2 src/Samples/Samples.ViaRouting/Samples.ViaRouting.csproj
  52. +1 −1  src/Samples/Samples.ViaRouting/Startup.cs
  53. +1 −1  src/Samples/Samples.ViaRouting/packages.config
  54. +6 −8 src/Tests/Gate.Builder.Tests/AppBuilderTests.cs
  55. +3 −2 src/Tests/Gate.Builder.Tests/Gate.Builder.Tests.csproj
  56. +1 −1  src/Tests/Gate.Builder.Tests/packages.config
  57. +2 −2 src/Tests/Gate.Hosts.AspNet.Tests/Gate.Hosts.AspNet.Tests.csproj
  58. +1 −1  src/Tests/Gate.Hosts.AspNet.Tests/packages.config
  59. +2 −2 src/Tests/Gate.Hosts.HttpListener.Tests/Gate.Hosts.HttpListener.Tests.csproj
  60. +1 −1  src/Tests/Gate.Hosts.HttpListener.Tests/Startup.cs
  61. +1 −1  src/Tests/Gate.Hosts.HttpListener.Tests/packages.config
  62. +2 −2 src/Tests/Gate.Hosts.Kayak.Tests/Gate.Hosts.Kayak.Tests.csproj
  63. +1 −1  src/Tests/Gate.Hosts.Kayak.Tests/packages.config
  64. +4 −4 src/Tests/Gate.Middleware.Tests/CascadeTests.cs
  65. +2 −2 src/Tests/Gate.Middleware.Tests/ChunkedTests.cs
  66. +2 −2 src/Tests/Gate.Middleware.Tests/Gate.Middleware.Tests.csproj
  67. +3 −2 src/Tests/Gate.Middleware.Tests/MethodOverrideTests.cs
  68. +3 −3 src/Tests/Gate.Middleware.Tests/ShowExceptionsTests.cs
  69. +3 −2 src/Tests/Gate.Middleware.Tests/StaticFiles/FileServerTests.cs
  70. +1 −1  src/Tests/Gate.Middleware.Tests/packages.config
  71. +3 −2 src/Tests/Gate.TestHelpers/Gate.TestHelpers.csproj
  72. +8 −11 src/Tests/Gate.TestHelpers/TestHttpClient.cs
  73. +1 −1  src/Tests/Gate.TestHelpers/packages.config
  74. +2 −2 src/Tests/Gate.Tests/Gate.Tests.csproj
  75. +1 −2  src/Tests/Gate.Tests/RequestTests.cs
  76. +3 −2 src/Tests/Gate.Tests/ResponseTests.cs
  77. +2 −2 src/Tests/Gate.Tests/TestClientTests.cs
  78. +0 −1  src/Tests/Gate.Tests/UrlMapperTests.cs
  79. +1 −1  src/Tests/Gate.Tests/packages.config
View
2  Sakefile.shade
@@ -1,7 +1,7 @@
var PROJECT='Gate'
var VERSION='0.12'
-var FULL_VERSION='${VERSION}-ctp3'
+var FULL_VERSION='${VERSION}-ctp4'
var AUTHORS='${PROJECT} contributors'
var BASE_DIR='${Directory.GetCurrentDirectory()}'
View
4 src/Adapters/Gate.Adapters.AspNetWebApi/Gate.Adapters.AspNetWebApi.csproj
@@ -45,9 +45,9 @@
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\packages\Newtonsoft.Json.4.5.5\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
- <Reference Include="Owin, Version=0.11.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
+ <Reference Include="Owin, Version=0.12.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\packages\Owin.0.11\lib\net40\Owin.dll</HintPath>
+ <HintPath>..\..\..\packages\Owin.0.12-ctp4\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
View
17 src/Adapters/Gate.Adapters.AspNetWebApi/WebApiAdapter.cs
@@ -68,7 +68,7 @@ public static AppDelegate App(HttpServer server)
var owinRequestProtocol = Get<string>(call.Environment, "owin.RequestProtocol");
var owinRequestHeaders = call.Headers;
var owinRequestBody = call.Body;
- var cancellationToken = call.Completed;
+ var owinCallCompleted = Get<Task>(call.Environment, "owin.CallCompleted");
var uriBuilder =
new UriBuilder(owinRequestScheme, "localhost")
@@ -99,8 +99,11 @@ public static AppDelegate App(HttpServer server)
}
}
}
-
- return invoker.SendAsync(request, cancellationToken)
+
+ var cts = new CancellationTokenSource();
+ owinCallCompleted.Finally(() => cts.Cancel(false));
+
+ return invoker.SendAsync(request, cts.Token)
.Then(response =>
{
ResultParameters result = new ResultParameters();
@@ -131,18 +134,14 @@ private static T Get<T>(IDictionary<string, object> env, string name)
}
- private static BodyDelegate GetResponseBody(HttpContent content)
+ private static Func<Stream, Task> GetResponseBody(HttpContent content)
{
if (content == null)
{
return null;
}
- return (output, cancel) =>
- {
- cancel.ThrowIfCancellationRequested();
- return content.CopyToAsync(output);
- };
+ return output => content.CopyToAsync(output);
}
}
}
View
2  src/Adapters/Gate.Adapters.AspNetWebApi/packages.config
@@ -4,6 +4,6 @@
<package id="Microsoft.AspNet.WebApi.Core" version="4.0.20516.0" />
<package id="Microsoft.Net.Http" version="2.0.20516.0" />
<package id="Newtonsoft.Json" version="4.5.5" />
- <package id="Owin" version="0.11" />
+ <package id="Owin" version="0.12-ctp4" />
<package id="TaskHelpers.Sources" version="0.1" />
</packages>
View
5 src/Adapters/Gate.Adapters.Nancy/Gate.Adapters.Nancy.csproj
@@ -37,8 +37,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Nancy.0.11.0\lib\net40\Nancy.dll</HintPath>
</Reference>
- <Reference Include="Owin, Version=0.11.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
- <HintPath>..\..\..\packages\Owin.0.11\lib\net40\Owin.dll</HintPath>
+ <Reference Include="Owin, Version=0.12.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\packages\Owin.0.12-ctp4\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
View
6 src/Adapters/Gate.Adapters.Nancy/NancyAdapter.cs
@@ -43,7 +43,7 @@ public static AppDelegate App(INancyBootstrapper bootstrapper)
var owinRequestQueryString = Get<string>(env, OwinConstants.RequestQueryString);
var owinRequestBody = call.Body;
var serverClientIp = Get<string>(env, "server.CLIENT_IP");
- var callDisposing = call.Completed;
+ var callCompleted = Get<Task>(env, OwinConstants.CallCompleted);
var url = new Url
{
@@ -69,7 +69,7 @@ public static AppDelegate App(INancyBootstrapper bootstrapper)
nancyRequest,
context =>
{
- callDisposing.Register(context.Dispose);
+ callCompleted.Finally(context.Dispose);
var nancyResponse = context.Response;
var headers = nancyResponse.Headers.ToDictionary(kv => kv.Key, kv => new[] { kv.Value }, StringComparer.OrdinalIgnoreCase);
@@ -85,7 +85,7 @@ public static AppDelegate App(INancyBootstrapper bootstrapper)
{
Status = (int)nancyResponse.StatusCode,
Headers = headers,
- Body = (output, cancel) =>
+ Body = output =>
{
nancyResponse.Contents(output);
return TaskHelpers.Completed();
View
2  src/Adapters/Gate.Adapters.Nancy/packages.config
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Nancy" version="0.11.0" />
- <package id="Owin" version="0.11" />
+ <package id="Owin" version="0.12-ctp4" />
<package id="TaskHelpers.Sources" version="0.1" />
</packages>
View
2  src/CommonAssemblyInfo.cs
@@ -13,4 +13,4 @@
[assembly: AssemblyVersion("0.12")]
[assembly: AssemblyFileVersion("0.12")]
-[assembly: AssemblyInformationalVersion("0.12-ctp3")]
+[assembly: AssemblyInformationalVersion("0.12")]
View
16 src/Hosts/Gate.Hosts.AspNet/AppHandler.cs
@@ -22,7 +22,6 @@ public AppHandler(AppDelegate app)
public IAsyncResult BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, object state)
{
- var cancellationTokenSource = new CancellationTokenSource();
var taskCompletionSource = new TaskCompletionSource<Action>(state);
if (callback != null)
taskCompletionSource.Task.ContinueWith(task => callback(task), TaskContinuationOptions.ExecuteSynchronously);
@@ -45,8 +44,6 @@ public IAsyncResult BeginProcessRequest(HttpContextBase httpContext, AsyncCallba
call.Body = httpRequest.InputStream;
- call.Completed = cancellationTokenSource.Token;
-
call.Environment = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase)
{
{OwinConstants.Version, "1.0"},
@@ -57,6 +54,7 @@ public IAsyncResult BeginProcessRequest(HttpContextBase httpContext, AsyncCallba
{OwinConstants.RequestQueryString, serverVariables.QueryString},
{OwinConstants.RequestProtocol, serverVariables.ProtocolVersion},
{"aspnet.HttpContextBase", httpContext},
+ {OwinConstants.CallCompleted, taskCompletionSource.Task},
};
foreach (var kv in serverVariables.AddToEnvironment())
{
@@ -84,8 +82,7 @@ public IAsyncResult BeginProcessRequest(HttpContextBase httpContext, AsyncCallba
if (result.Body != null)
{
- // TODO: Cancellation?
- result.Body(httpContext.Response.OutputStream, cancellationTokenSource.Token)
+ result.Body(httpContext.Response.OutputStream)
.Then(() =>
{
taskCompletionSource.TrySetResult(() => { });
@@ -113,15 +110,6 @@ public IAsyncResult BeginProcessRequest(HttpContextBase httpContext, AsyncCallba
taskCompletionSource.TrySetException(ex);
}
- if (taskCompletionSource.Task.IsCompleted)
- {
- cancellationTokenSource.Cancel(false);
- }
- else
- {
- taskCompletionSource.Task.ContinueWith(t => cancellationTokenSource.Cancel(false));
- }
-
return taskCompletionSource.Task;
}
View
4 src/Hosts/Gate.Hosts.AspNet/Gate.Hosts.AspNet.csproj
@@ -36,9 +36,9 @@
<Private>True</Private>
<HintPath>..\..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
- <Reference Include="Owin, Version=0.11.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
+ <Reference Include="Owin, Version=0.12.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\packages\Owin.0.11\lib\net40\Owin.dll</HintPath>
+ <HintPath>..\..\..\packages\Owin.0.12-ctp4\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
View
2  src/Hosts/Gate.Hosts.AspNet/packages.config
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
- <package id="Owin" version="0.11" />
+ <package id="Owin" version="0.12-ctp4" />
<package id="TaskHelpers.Sources" version="0.1" />
</packages>
View
4 src/Hosts/Gate.Hosts.Firefly/Gate.Hosts.Firefly.csproj
@@ -49,9 +49,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Firefly.0.4\lib\net40\Firefly.dll</HintPath>
</Reference>
- <Reference Include="Owin, Version=0.11.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
+ <Reference Include="Owin, Version=0.12.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\packages\Owin.0.11\lib\net40\Owin.dll</HintPath>
+ <HintPath>..\..\..\packages\Owin.0.12-ctp4\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
View
2  src/Hosts/Gate.Hosts.Firefly/packages.config
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Firefly" version="0.4" />
- <package id="Owin" version="0.11" />
+ <package id="Owin" version="0.12-ctp4" />
<package id="TaskHelpers.Sources" version="0.1" />
</packages>
View
4 src/Hosts/Gate.Hosts.HttpListener/Gate.Hosts.HttpListener.csproj
@@ -33,9 +33,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Owin, Version=0.11.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
+ <Reference Include="Owin, Version=0.12.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\packages\Owin.0.11\lib\net40\Owin.dll</HintPath>
+ <HintPath>..\..\..\packages\Owin.0.12-ctp4\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
View
2  src/Hosts/Gate.Hosts.HttpListener/ServerFactory.cs
@@ -118,7 +118,7 @@ public static IDisposable Create(AppDelegate app, int port, string path)
{
try
{
- Task bodyTask = result.Body(context.Response.OutputStream, CancellationToken.None);
+ Task bodyTask = result.Body(context.Response.OutputStream);
bodyTask.ContinueWith(task => context.Response.Abort(), TaskContinuationOptions.NotOnRanToCompletion);
View
2  src/Hosts/Gate.Hosts.HttpListener/packages.config
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Owin" version="0.11" />
+ <package id="Owin" version="0.12-ctp4" />
<package id="TaskHelpers.Sources" version="0.1" />
</packages>
View
6 src/Hosts/Gate.Hosts.Kayak/DataProducer.cs
@@ -1,5 +1,7 @@
using System;
+using System.IO;
using System.Threading;
+using System.Threading.Tasks;
using Owin;
using Kayak;
@@ -7,9 +9,9 @@ namespace Gate.Hosts.Kayak
{
class DataProducer : IDataProducer
{
- readonly BodyDelegate del;
+ readonly Func<Stream, Task> del;
- public DataProducer(BodyDelegate del)
+ public DataProducer(Func<Stream, Task> del)
{
this.del = del;
}
View
4 src/Hosts/Gate.Hosts.Kayak/Gate.Hosts.Kayak.csproj
@@ -35,9 +35,9 @@
<Reference Include="Kayak, Version=0.7.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Kayak.0.7.2\lib\Kayak.dll</HintPath>
</Reference>
- <Reference Include="Owin, Version=0.11.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
+ <Reference Include="Owin, Version=0.12.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\packages\Owin.0.11\lib\net40\Owin.dll</HintPath>
+ <HintPath>..\..\..\packages\Owin.0.12-ctp4\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
View
1  src/Hosts/Gate.Hosts.Kayak/GateRequestDelegate.cs
@@ -25,7 +25,6 @@ public GateRequestDelegate(AppDelegate appDelegate, IDictionary<string, object>
public void OnRequest(HttpRequestHead head, IDataProducer body, IHttpResponseDelegate response)
{
var request = new CallParameters();
- request.Completed = CancellationToken.None; // TODO:
request.Environment = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
var requestWrapper = new RequestEnvironment(request.Environment);
View
2  src/Hosts/Gate.Hosts.Kayak/packages.config
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Kayak" version="0.7.2" />
- <package id="Owin" version="0.11" />
+ <package id="Owin" version="0.12-ctp4" />
<package id="TaskHelpers.Sources" version="0.1" />
</packages>
View
9 src/Hosts/Gate.Hosts/ErrorPage.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Text;
using Owin;
using System.Threading.Tasks;
@@ -35,12 +36,12 @@ public static AppDelegate Middleware(AppDelegate app, Action<Exception> logError
{
if (result.Body != null)
{
- BodyDelegate nestedBody = result.Body;
- result.Body = (stream, cancel) =>
+ var nestedBody = result.Body;
+ result.Body = stream =>
{
try
{
- return nestedBody(stream, cancel)
+ return nestedBody(stream)
.Catch(errorInfo =>
{
logError(errorInfo.Exception);
@@ -83,7 +84,7 @@ private static ResultParameters CreateErrorResponse()
{
{ "Content-Type", new[] { "text/html" } }
},
- Body = (stream, cancel) =>
+ Body = stream =>
{
stream.Write(Body.Array, Body.Offset, Body.Count);
return TaskHelpers.Completed();
View
21 src/Hosts/Gate.Hosts/ExecutionContextPerRequest.cs
@@ -29,22 +29,19 @@ static ResultParameters WrapBodyDelegate(ResultParameters result)
{
if (result.Body != null)
{
- BodyDelegate nestedBody = result.Body;
- result.Body = (stream, cancel) =>
+ var nestedBody = result.Body;
+ result.Body = stream =>
{
TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
ExecutionContext.SuppressFlow();
ThreadPool.QueueUserWorkItem(
- _ =>
- {
- nestedBody(stream, cancel)
- .Then(() => { bool ignored = tcs.TrySetResult(null); })
- .Catch(errorInfo =>
- {
- bool ignored = tcs.TrySetException(errorInfo.Exception);
- return errorInfo.Handled();
- });
- },
+ _ => nestedBody(stream)
+ .Then(() => { bool ignored = tcs.TrySetResult(null); })
+ .Catch(errorInfo =>
+ {
+ bool ignored = tcs.TrySetException(errorInfo.Exception);
+ return errorInfo.Handled();
+ }),
null);
ExecutionContext.RestoreFlow();
return tcs.Task;
View
5 src/Hosts/Gate.Hosts/Gate.Hosts.csproj
@@ -43,8 +43,9 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
- <Reference Include="Owin">
- <HintPath>..\..\..\packages\Owin.0.11\lib\net40\Owin.dll</HintPath>
+ <Reference Include="Owin, Version=0.12.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\packages\Owin.0.12-ctp4\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
View
2  src/Hosts/Gate.Hosts/packages.config
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Owin" version="0.11" />
+ <package id="Owin" version="0.12-ctp4" />
<package id="TaskHelpers.Sources" version="0.1" />
</packages>
View
27 src/Main/Gate.Builder/Adapters.cs
@@ -12,47 +12,35 @@ namespace Gate.Builder
IDictionary<string, object>, // Environment
IDictionary<string, string[]>, // Headers
Stream, // Body
- CancellationToken, // CallCancelled
Task<Tuple< //Result
IDictionary<string, object>, // Properties
int, // Status
IDictionary<string, string[]>, // Headers
Func< // CopyTo
Stream, // Body
- CancellationToken, // CopyToCancelled
Task>>>>; // Done
- using BodyFunc = Func< // CopyTo
- Stream, // Body
- CancellationToken, // CopyToCancelled
- Task>; // Done
-
public static class Adapters
{
public static AppFunc ToFunc(AppDelegate app)
{
- return (env, headers, body, completed) =>
+ return (env, headers, body) =>
{
var task = app(new CallParameters
{
Environment = env,
Headers = headers,
- Body = body,
- Completed = completed
+ Body = body
});
return task.Then(result => Tuple.Create(
result.Properties,
result.Status,
result.Headers,
- ToFunc(result.Body)));
+ result.Body));
};
}
- static BodyFunc ToFunc(BodyDelegate body)
- {
- return (stream, cancel) => body(stream, cancel);
- }
public static AppDelegate ToDelegate(AppFunc app)
{
@@ -61,22 +49,17 @@ public static AppDelegate ToDelegate(AppFunc app)
var task = app(
call.Environment,
call.Headers,
- call.Body,
- call.Completed);
+ call.Body);
return task.Then(result => new ResultParameters
{
Properties = result.Item1,
Status = result.Item2,
Headers = result.Item3,
- Body = ToDelegate(result.Item4)
+ Body = result.Item4
});
};
}
- static BodyDelegate ToDelegate(BodyFunc body)
- {
- return (stream, cancel) => body(stream, cancel);
- }
}
}
View
2  src/Main/Gate.Builder/AppBuilder.cs
@@ -14,14 +14,12 @@ namespace Gate.Builder
IDictionary<string, object>, // Environment
IDictionary<string, string[]>, // Headers
Stream, // Body
- CancellationToken, // CallCancelled
Task<Tuple< //Result
IDictionary<string, object>, // Properties
int, // Status
IDictionary<string, string[]>, // Headers
Func< // CopyTo
Stream, // Body
- CancellationToken, // CopyToCancelled
Task>>>>; // Done
public class AppBuilder : IAppBuilder
View
5 src/Main/Gate.Builder/Gate.Builder.csproj
@@ -33,8 +33,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Owin, Version=0.11.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
- <HintPath>..\..\..\packages\Owin.0.11\lib\net40\Owin.dll</HintPath>
+ <Reference Include="Owin, Version=0.12.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\packages\Owin.0.12-ctp4\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
</ItemGroup>
View
2  src/Main/Gate.Builder/NotFound.cs
@@ -33,7 +33,7 @@ public static Task<ResultParameters> Call(CallParameters call)
{
{"Content-Type", new[] {"text/html"}}
},
- Body = (output, _) =>
+ Body = output =>
{
output.Write(Body.Array, Body.Offset, Body.Count);
return TaskHelpers.Completed();
View
2  src/Main/Gate.Builder/packages.config
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Owin" version="0.11" />
+ <package id="Owin" version="0.12-ctp4" />
<package id="TaskHelpers.Sources" version="0.1" />
</packages>
View
6 src/Main/Gate.Middleware/Chunked.cs
@@ -36,10 +36,10 @@ public static AppDelegate Middleware(AppDelegate app)
});
}
- public static BodyDelegate WrapOutputStream(BodyDelegate body)
+ public static Func<Stream, Task> WrapOutputStream(Func<Stream, Task> body)
{
- return (output, cancel) =>
- body(new StreamWrapper(output, OnWriteFilter), cancel)
+ return output =>
+ body(new StreamWrapper(output, OnWriteFilter))
.Then(() =>
output.WriteAsync(FinalChunk.Array, FinalChunk.Offset, FinalChunk.Count));
}
View
15 src/Main/Gate.Middleware/ContentLength.cs
@@ -1,3 +1,5 @@
+using System.Globalization;
+
namespace Gate.Middleware
{
using System.IO;
@@ -34,20 +36,17 @@ public static AppDelegate Middleware(AppDelegate app)
// Buffer the body
MemoryStream buffer = new MemoryStream();
- return result.Body(buffer, call.Completed).Then<ResultParameters>(
+ return result.Body(buffer).Then<ResultParameters>(
() =>
{
buffer.Seek(0, SeekOrigin.Begin);
- result.Headers.SetHeader("Content-Length", buffer.Length.ToString());
- result.Body = (output, cancel) =>
- {
- return buffer.CopyToAsync(output, cancel);
- };
+ result.Headers.SetHeader("Content-Length", buffer.Length.ToString(CultureInfo.InvariantCulture));
+ result.Body = output => buffer.CopyToAsync(output);
return TaskHelpers.FromResult(result);
- }, call.Completed);
+ });
- }, call.Completed);
+ });
};
}
View
4 src/Main/Gate.Middleware/Gate.Middleware.csproj
@@ -32,9 +32,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Owin, Version=0.11.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
+ <Reference Include="Owin, Version=0.12.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\packages\Owin.0.11\lib\net40\Owin.dll</HintPath>
+ <HintPath>..\..\..\packages\Owin.0.12-ctp4\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
View
2  src/Main/Gate.Middleware/NotFound.cs
@@ -32,7 +32,7 @@ public static Task<ResultParameters> Call(CallParameters call)
{
{"Content-Type", new[] {"text/html"}}
},
- Body = (output, _) =>
+ Body = output =>
{
output.Write(Body.Array, Body.Offset, Body.Count);
return TaskHelpers.Completed();
View
6 src/Main/Gate.Middleware/ShowExceptions.cs
@@ -42,12 +42,12 @@ public static AppDelegate Middleware(AppDelegate app)
{
if (result.Body != null)
{
- BodyDelegate nestedBody = result.Body;
- result.Body = (stream, cancel) =>
+ var nestedBody = result.Body;
+ result.Body = stream =>
{
try
{
- return nestedBody(stream, cancel).Catch(
+ return nestedBody(stream).Catch(
errorInfo =>
{
showErrorMessage(errorInfo.Exception, data => stream.Write(data, 0, data.Length));
View
10 src/Main/Gate.Middleware/StaticFiles/FileBody.cs
@@ -19,19 +19,19 @@ public FileBody(string path, Tuple<long, long> range)
this.range = range;
}
- public static BodyDelegate Create(string path, Tuple<long, long> range)
+ public static Func<Stream, Task> Create(string path, Tuple<long, long> range)
{
- return (stream, cancel) =>
+ return stream =>
{
var fileBody = new FileBody(path, range);
- return fileBody.Start(stream, cancel);
+ return fileBody.Start(stream);
};
}
- private Task Start(Stream stream, CancellationToken cancellationToken)
+ private Task Start(Stream stream)
{
this.OpenFileStream();
- return this.fileStream.CopyToAsync(stream, (int)(range.Item2 - range.Item1 + 1), cancellationToken);
+ return this.fileStream.CopyToAsync(stream, (int)(range.Item2 - range.Item1 + 1));
}
private void OpenFileStream()
View
3  src/Main/Gate.Middleware/StaticFiles/FileServer.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
@@ -69,7 +70,7 @@ private static AppDelegate Fail(int status, string body, IDictionary<string, str
Status = status,
Headers = Headers.New(headers)
.SetHeader("Content-Type", "text/plain")
- .SetHeader("Content-Length", body.Length.ToString())
+ .SetHeader("Content-Length", body.Length.ToString(CultureInfo.InvariantCulture))
.SetHeader("X-Cascade", "pass"),
Body = TextBody.Create(body, Encoding.UTF8),
Properties = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase)
View
8 src/Main/Gate.Middleware/StaticFiles/TextBody.cs
@@ -18,17 +18,17 @@ public TextBody(string text, Encoding encoding)
this.encoding = encoding;
}
- public static BodyDelegate Create(string text, Encoding encoding)
+ public static Func<Stream, Task> Create(string text, Encoding encoding)
{
- return (stream, cancel) =>
+ return stream =>
{
var textBody = new TextBody(text, encoding);
- return textBody.Start(stream, cancel);
+ return textBody.Start(stream);
};
}
- public Task Start(Stream stream, CancellationToken cancellationToken)
+ public Task Start(Stream stream)
{
TaskCompletionSource<object> completed = new TaskCompletionSource<object>();
var bytes = encoding.GetBytes(text);
View
2  src/Main/Gate.Middleware/packages.config
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Owin" version="0.11" />
+ <package id="Owin" version="0.12-ctp4" />
<package id="TaskHelpers.Sources" version="0.1" />
</packages>
View
5 src/Main/Gate/Gate.csproj
@@ -32,8 +32,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Owin, Version=0.11.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
- <HintPath>..\..\..\packages\Owin.0.11\lib\net40\Owin.dll</HintPath>
+ <Reference Include="Owin, Version=0.12.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\packages\Owin.0.12-ctp4\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
View
1  src/Main/Gate/OwinConstants.cs
@@ -10,5 +10,6 @@ internal static class OwinConstants
public const string RequestQueryString = "owin.RequestQueryString";
public const string RequestProtocol = "owin.RequestProtocol";
public const string ReasonPhrase = "owin.ReasonPhrase";
+ public const string CallCompleted = "owin.CallCompleted";
}
}
View
15 src/Main/Gate/Request.cs
@@ -19,8 +19,7 @@ public Request()
_call = new CallParameters()
{
Body = null,
- Completed = CancellationToken.None,
- Environment = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase),
+ Environment = new Dictionary<string, object>(),
Headers = Gate.Headers.New()
};
}
@@ -45,10 +44,10 @@ public Stream Body
get { return _call.Body; }
set { _call.Body = value; }
}
- public CancellationToken Completed
+ public Task Completed
{
- get { return _call.Completed; }
- set { _call.Completed = value; }
+ get { return Get<Task>("owin.CallCompleted"); }
+ set { Environment["owin.CallCompleted"] = value; }
}
private T Get<T>(string name)
@@ -204,13 +203,13 @@ public string MediaType
}
}
- public Task CopyToStreamAsync(Stream stream, CancellationToken cancel)
+ public Task CopyToStreamAsync(Stream stream)
{
if (_call.Body == null)
{
return TaskHelpers.Completed();
}
- return _call.Body.CopyToAsync(stream, cancel);
+ return _call.Body.CopyToAsync(stream);
}
public Task<string> ReadTextAsync()
@@ -228,7 +227,7 @@ public Task<string> ReadTextAsync()
var buffer = new MemoryStream();
//TODO: determine encoding from request content type
- return CopyToStreamAsync(buffer, Completed)
+ return CopyToStreamAsync(buffer)
.Then(() =>
{
text = new StreamReader(buffer).ReadToEnd();
View
28 src/Main/Gate/Response.cs
@@ -23,7 +23,7 @@ public class Response
private CancellationToken completeToken;
private ResponseStream responseStream;
- private BodyDelegate defaultBodyDelegate;
+ private Func<Stream, Task> defaultBodyDelegate;
public Response()
: this(200)
@@ -41,7 +41,7 @@ public Response(int statusCode, IDictionary<string, string[]> headers)
}
public Response(int statusCode, IDictionary<string, string[]> headers, IDictionary<string, object> properties)
- : this (
+ : this(
new ResultParameters()
{
Status = statusCode,
@@ -49,7 +49,7 @@ public Response(int statusCode, IDictionary<string, string[]> headers, IDictiona
Body = null,
Properties = properties
})
- {
+ {
}
public Response(ResultParameters result, CancellationToken completed = default(CancellationToken))
@@ -135,7 +135,7 @@ public string ReasonPhrase
}
set { Properties["owin.ReasonPhrase"] = value; }
}
-
+
public string GetHeader(string name)
{
var values = GetHeaders(name);
@@ -250,7 +250,7 @@ public Response DeleteCookie(string key, Cookie cookie)
Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc),
});
}
-
+
public class Cookie
{
public Cookie()
@@ -287,7 +287,7 @@ public long ContentLength
// (true) Buffer or (false) auto-start/SendHeaders on write
public bool Buffer { get; set; }
- public BodyDelegate BodyDelegate
+ public Func<Stream, Task> BodyDelegate
{
get
{
@@ -317,7 +317,7 @@ private void EnsureResponseStream()
public Stream OutputStream
{
- get
+ get
{
EnsureResponseStream();
if (!Buffer) // Auto-Start
@@ -341,7 +341,7 @@ public void Write(string format, params object[] args)
public void Write(byte[] buffer)
{
- completeToken.ThrowIfCancellationRequested();
+ completeToken.ThrowIfCancellationRequested();
OutputStream.Write(buffer, 0, buffer.Length);
}
@@ -384,10 +384,10 @@ public void Flush()
}
// Copy the buffer to the output and then provide direct access to the output stream.
- private Task DefaultBodyDelegate(Stream output, CancellationToken cancel)
+ private Task DefaultBodyDelegate(Stream output)
{
EnsureResponseStream();
- Task transitionTask = responseStream.TransitionFromBufferedToUnbuffered(output, cancel)
+ Task transitionTask = responseStream.TransitionFromBufferedToUnbuffered(output)
.Then(() =>
{
// Offload complete
@@ -403,7 +403,7 @@ private Task DefaultBodyDelegate(Stream output, CancellationToken cancel)
{
bodyTransitionCompletionSource.TrySetResult(null);
});
-
+
return bodyCompletionSource.Task;
}
@@ -422,7 +422,7 @@ public Task<Response> StartAsync()
callCompletionSource.TrySetResult(result);
// TODO: Make Headers and Properties read only to prevent user errors
-
+
if (result.Body == defaultBodyDelegate)
{
// Register for cancelation in case the body delegate is not invoked.
@@ -459,7 +459,7 @@ public Task<ResultParameters> EndAsync()
Start();
sendHeaderAsyncCompletionSource.TrySetCanceled();
// End the body as soon as the buffer copies.
- bodyTransitionCompletionSource.Task.Then(() => { bodyCompletionSource.TrySetResult(null); } );
+ bodyTransitionCompletionSource.Task.Then(() => { bodyCompletionSource.TrySetResult(null); });
return callCompletionSource.Task;
}
@@ -468,7 +468,7 @@ public void Error(Exception error)
callCompletionSource.TrySetException(error);
// This just goes back to user code, we don't need to report their own exception back to them.
sendHeaderAsyncCompletionSource.TrySetCanceled();
- bodyCompletionSource.TrySetException(error);
+ bodyCompletionSource.TrySetException(error);
}
}
}
View
3  src/Main/Gate/ResponseStream.cs
@@ -193,7 +193,7 @@ public override void Flush()
}
}
- internal Task TransitionFromBufferedToUnbuffered(Stream output, CancellationToken cancel)
+ internal Task TransitionFromBufferedToUnbuffered(Stream output)
{
if (output == null)
{
@@ -211,7 +211,6 @@ internal Task TransitionFromBufferedToUnbuffered(Stream output, CancellationToke
}
outputStream = output;
- this.cancel = cancel;
return DrainBufferAsync();
}
View
2  src/Main/Gate/packages.config
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Owin" version="0.11" />
+ <package id="Owin" version="0.12-ctp4" />
<package id="TaskHelpers.Sources" version="0.1" />
</packages>
View
5 src/Samples/Sample.AspNetWebApi/Sample.AspNetWebApi.csproj
@@ -38,8 +38,9 @@
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Newtonsoft.Json.4.5.5\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
- <Reference Include="Owin, Version=0.11.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
- <HintPath>..\..\..\packages\Owin.0.11\lib\net40\Owin.dll</HintPath>
+ <Reference Include="Owin, Version=0.12.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\packages\Owin.0.12-ctp4\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
View
2  src/Samples/Sample.AspNetWebApi/packages.config
@@ -4,5 +4,5 @@
<package id="Microsoft.AspNet.WebApi.Core" version="4.0.20516.0" />
<package id="Microsoft.Net.Http" version="2.0.20516.0" />
<package id="Newtonsoft.Json" version="4.5.5" />
- <package id="Owin" version="0.11" />
+ <package id="Owin" version="0.12-ctp4" />
</packages>
View
5 src/Samples/Sample.HelloWorld/Sample.HelloWorld.csproj
@@ -58,8 +58,9 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
- <Reference Include="Owin, Version=0.11.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
- <HintPath>..\..\..\packages\Owin.0.11\lib\net40\Owin.dll</HintPath>
+ <Reference Include="Owin, Version=0.12.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\packages\Owin.0.12-ctp4\lib\net40\Owin.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
View
2  src/Samples/Sample.HelloWorld/packages.config
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Owin" version="0.11" />
+ <package id="Owin" version="0.12-ctp4" />
</packages>
View
4 src/Samples/Sample.Nancy/Sample.Nancy.csproj
@@ -42,9 +42,9 @@
<Reference Include="Nancy.ViewEngines.Spark">
<HintPath>..\..\..\packages\Nancy.Viewengines.Spark.0.9.0\lib\net40\Nancy.ViewEngines.Spark.dll</HintPath>
</Reference>
- <Reference Include="Owin, Version=0.11.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
+ <Reference Include="Owin, Version=0.12.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\packages\Owin.0.11\lib\net40\Owin.dll</HintPath>
+ <HintPath>..\..\..\packages\Owin.0.12-ctp4\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="Spark">
<HintPath>..\..\..\packages\Spark.1.5.1\lib\NET40\Spark.dll</HintPath>
View
2  src/Samples/Sample.Nancy/packages.config
@@ -2,7 +2,7 @@
<packages>
<package id="Nancy" version="0.9.0" />
<package id="Nancy.Viewengines.Spark" version="0.9.0" />
- <package id="Owin" version="0.11" />
+ <package id="Owin" version="0.12-ctp4" />
<package id="Spark" version="1.5.1" />
<package id="TaskHelpers.Sources" version="0.1" />
</packages>
View
4 src/Samples/Samples.ViaRouting/Samples.ViaRouting.csproj
@@ -36,9 +36,9 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
- <Reference Include="Owin, Version=0.11.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
+ <Reference Include="Owin, Version=0.12.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\packages\Owin.0.11\lib\net40\Owin.dll</HintPath>
+ <HintPath>..\..\..\packages\Owin.0.12-ctp4\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
View
2  src/Samples/Samples.ViaRouting/Startup.cs
@@ -52,7 +52,7 @@ Task<ResultParameters> Raw(CallParameters call)
result.Status = 200;
result.Headers = new Dictionary<string, string[]>(StringComparer.OrdinalIgnoreCase) { { "Content-Type", new[] { "text/plain" } } };
result.Properties = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
- result.Body = (stream, cancel) =>
+ result.Body = stream =>
{
byte[] body = Encoding.UTF8.GetBytes("Hello from lowest-level code");
stream.Write(body, 0, body.Length);
View
2  src/Samples/Samples.ViaRouting/packages.config
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Owin" version="0.11" />
+ <package id="Owin" version="0.12-ctp4" />
<package id="TaskHelpers.Sources" version="0.1" />
</packages>
View
14 src/Tests/Gate.Builder.Tests/AppBuilderTests.cs
@@ -19,17 +19,15 @@ namespace Gate.Builder.Tests
IDictionary<string, object>, // Environment
IDictionary<string, string[]>, // Headers
Stream, // Body
- CancellationToken, // CallCancelled
Task<Tuple< //Result
IDictionary<string, object>, // Properties
int, // Status
IDictionary<string, string[]>, // Headers
Func< // CopyTo
Stream, // Body
- CancellationToken, // CopyToCancelled
Task>>>>; // Done
- using ResultTuple = Tuple<IDictionary<string, object>, int, IDictionary<string, string[]>, Func<Stream, CancellationToken, Task>>;
+ using ResultTuple = Tuple<IDictionary<string, object>, int, IDictionary<string, string[]>, Func<Stream, Task>>;
public class AppBuilderTests
{
@@ -42,7 +40,7 @@ public class AppBuilderTests
{
{"Content-Type", new[] {"text/plain"}}
},
- Body = (stream, stop) =>
+ Body = stream =>
{
stream.Write(Encoding.UTF8.GetBytes("Hello Foo"), 0, 9);
return TaskHelpers.Completed();
@@ -53,7 +51,7 @@ public class AppBuilderTests
}
});
- static readonly AppAction TwoHundredFooAction = (env, headers, body, cancel) => TaskHelpers.FromResult(
+ static readonly AppAction TwoHundredFooAction = (env, headers, body) => TaskHelpers.FromResult(
new ResultTuple(
new Dictionary<string, object>
{
@@ -64,7 +62,7 @@ public class AppBuilderTests
{
{"Content-Type", new[] {"text/plain"}}
},
- (stream, stop) =>
+ stream =>
{
stream.Write(Encoding.UTF8.GetBytes("Hello Foo"), 0, 9);
return TaskHelpers.Completed();
@@ -200,8 +198,8 @@ public Task Use_middleware_runs_in_the_order_they_are_registered()
static readonly Func<AppAction, string, AppAction> AddStatus =
(app, appendReasonPhrase) =>
- (env, headers, body, cancel) =>
- app(env, headers, body, cancel).Then(result =>
+ (env, headers, body) =>
+ app(env, headers, body).Then(result =>
{
result.Item1["owin.ReasonPhrase"] = result.Item1["owin.ReasonPhrase"] + appendReasonPhrase;
return result;
View
5 src/Tests/Gate.Builder.Tests/Gate.Builder.Tests.csproj
@@ -47,8 +47,9 @@
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\packages\Newtonsoft.Json.4.5.7\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
- <Reference Include="Owin, Version=0.11.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
- <HintPath>..\..\..\packages\Owin.0.11\lib\net40\Owin.dll</HintPath>
+ <Reference Include="Owin, Version=0.12.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\packages\Owin.0.12-ctp4\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="Shouldly">
<HintPath>..\..\..\packages\Shouldly.1.1.1.1\lib\35\Shouldly.dll</HintPath>
View
2  src/Tests/Gate.Builder.Tests/packages.config
@@ -3,7 +3,7 @@
<package id="Microsoft.AspNet.WebApi.Client" version="4.0.20710.0" />
<package id="Microsoft.Net.Http" version="2.0.20710.0" />
<package id="Newtonsoft.Json" version="4.5.7" />
- <package id="Owin" version="0.11" />
+ <package id="Owin" version="0.12-ctp4" />
<package id="Shouldly" version="1.1.1.1" />
<package id="TaskHelpers.Sources" version="0.1" />
<package id="xunit" version="1.9.1" />
View
4 src/Tests/Gate.Hosts.AspNet.Tests/Gate.Hosts.AspNet.Tests.csproj
@@ -46,9 +46,9 @@
<Reference Include="nunit.mocks">
<HintPath>..\..\..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath>
</Reference>
- <Reference Include="Owin, Version=0.11.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
+ <Reference Include="Owin, Version=0.12.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\packages\Owin.0.11\lib\net40\Owin.dll</HintPath>
+ <HintPath>..\..\..\packages\Owin.0.12-ctp4\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="pnunit.framework">
<HintPath>..\..\..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll</HintPath>
View
2  src/Tests/Gate.Hosts.AspNet.Tests/packages.config
@@ -3,7 +3,7 @@
<package id="Castle.Core" version="2.5.2" />
<package id="FakeItEasy" version="1.7.4257.42" />
<package id="NUnit" version="2.5.10.11092" />
- <package id="Owin" version="0.11" />
+ <package id="Owin" version="0.12-ctp4" />
<package id="TaskHelpers.Sources" version="0.1" />
<package id="xunit" version="1.9.1" />
</packages>
View
4 src/Tests/Gate.Hosts.HttpListener.Tests/Gate.Hosts.HttpListener.Tests.csproj
@@ -39,9 +39,9 @@
<Reference Include="nunit.mocks">
<HintPath>..\..\..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath>
</Reference>
- <Reference Include="Owin, Version=0.11.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
+ <Reference Include="Owin, Version=0.12.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\packages\Owin.0.11\lib\net40\Owin.dll</HintPath>
+ <HintPath>..\..\..\packages\Owin.0.12-ctp4\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="pnunit.framework">
<HintPath>..\..\..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll</HintPath>
View
2  src/Tests/Gate.Hosts.HttpListener.Tests/Startup.cs
@@ -22,7 +22,7 @@ static AppDelegate App(AppDelegate arg)
Status = 200,
Headers = new Dictionary<string, string[]>(StringComparer.OrdinalIgnoreCase) { { "Content-Type", new[] { "text/plain" } } },
Properties = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase),
- Body = (stream, cancel) =>
+ Body = stream =>
{
var bytes = Encoding.Default.GetBytes("This is a custom page");
stream.Write(bytes, 0, bytes.Length);
View
2  src/Tests/Gate.Hosts.HttpListener.Tests/packages.config
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="2.5.10.11092" />
- <package id="Owin" version="0.11" />
+ <package id="Owin" version="0.12-ctp4" />
<package id="xunit" version="1.9.1" />
</packages>
View
4 src/Tests/Gate.Hosts.Kayak.Tests/Gate.Hosts.Kayak.Tests.csproj
@@ -43,9 +43,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath>
</Reference>
- <Reference Include="Owin, Version=0.11.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
+ <Reference Include="Owin, Version=0.12.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\packages\Owin.0.11\lib\net40\Owin.dll</HintPath>
+ <HintPath>..\..\..\packages\Owin.0.12-ctp4\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="pnunit.framework, Version=1.0.4109.34242, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
View
2  src/Tests/Gate.Hosts.Kayak.Tests/packages.config
@@ -3,6 +3,6 @@
<package id="HttpMachine" version="0.9.0.0" />
<package id="Kayak" version="0.7.2" />
<package id="NUnit" version="2.5.10.11092" />
- <package id="Owin" version="0.11" />
+ <package id="Owin" version="0.12-ctp4" />
<package id="xunit" version="1.9.1" />
</packages>
View
8 src/Tests/Gate.Middleware.Tests/CascadeTests.cs
@@ -19,9 +19,9 @@ AppDelegate Build(Action<IAppBuilder> b)
return AppBuilder.BuildPipeline<AppDelegate>(b);
}
- private BodyDelegate CreateBody(String text)
+ private Func<Stream, Task> CreateBody(String text)
{
- return (stream, cancel) =>
+ return stream =>
{
byte[] body = Encoding.ASCII.GetBytes(text);
stream.Write(body, 0, body.Length);
@@ -29,11 +29,11 @@ private BodyDelegate CreateBody(String text)
};
}
- private String ReadBody(BodyDelegate body)
+ private String ReadBody(Func<Stream, Task> body)
{
using (MemoryStream buffer = new MemoryStream())
{
- body(buffer, CancellationToken.None).Wait();
+ body(buffer).Wait();
return Encoding.ASCII.GetString(buffer.ToArray());
}
}
View
4 src/Tests/Gate.Middleware.Tests/ChunkedTests.cs
@@ -18,7 +18,7 @@ private ResultParameters Call(Action<IAppBuilder> pipe)
return app(new Request().Call).Result;
}
- private string ReadBody(BodyDelegate body)
+ private string ReadBody(Func<Stream, Task> body)
{
if (body == null)
{
@@ -27,7 +27,7 @@ private string ReadBody(BodyDelegate body)
using (MemoryStream buffer = new MemoryStream())
{
- body(buffer, CancellationToken.None).Wait();
+ body(buffer).Wait();
return Encoding.ASCII.GetString(buffer.ToArray());
}
}
View
4 src/Tests/Gate.Middleware.Tests/Gate.Middleware.Tests.csproj
@@ -40,9 +40,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath>
</Reference>
- <Reference Include="Owin, Version=0.11.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
+ <Reference Include="Owin, Version=0.12.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\packages\Owin.0.11\lib\net40\Owin.dll</HintPath>
+ <HintPath>..\..\..\packages\Owin.0.12-ctp4\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="pnunit.framework, Version=1.0.4109.34242, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
View
5 src/Tests/Gate.Middleware.Tests/MethodOverrideTests.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.Threading.Tasks;
using NUnit.Framework;
using Gate.TestHelpers;
using Gate.Builder;
@@ -20,11 +21,11 @@ private ResultParameters Call(Action<IAppBuilder> pipe, Request request)
return app(request.Call).Result;
}
- private string ReadBody(BodyDelegate body)
+ private string ReadBody(Func<Stream, Task> body)
{
using (MemoryStream buffer = new MemoryStream())
{
- body(buffer, CancellationToken.None).Wait();
+ body(buffer).Wait();
return Encoding.ASCII.GetString(buffer.ToArray());
}
}
View
6 src/Tests/Gate.Middleware.Tests/ShowExceptionsTests.cs
@@ -18,11 +18,11 @@ AppDelegate Build(Action<IAppBuilder> b)
return AppBuilder.BuildPipeline<AppDelegate>(b);
}
- private String ReadBody(BodyDelegate body)
+ private String ReadBody(Func<Stream, Task> body)
{
using (MemoryStream buffer = new MemoryStream())
{
- body(buffer, CancellationToken.None).Wait();
+ body(buffer).Wait();
return Encoding.ASCII.GetString(buffer.ToArray());
}
}
@@ -71,7 +71,7 @@ public void Sync_Exception_in_response_body_stream_should_be_formatted_as_it_pas
.Run(appCall =>
{
ResultParameters rawResult = new ResultParameters();
- rawResult.Body = (stream, cancel) =>
+ rawResult.Body = stream =>
{
byte[] bodyBytes = Encoding.ASCII.GetBytes("<p>so far so good</p>");
stream.Write(bodyBytes, 0, bodyBytes.Length);
View
5 src/Tests/Gate.Middleware.Tests/StaticFiles/FileServerTests.cs
@@ -2,6 +2,7 @@
using System.IO;
using System.Text;
using System.Threading;
+using System.Threading.Tasks;
using Gate.Middleware.StaticFiles;
using Gate.Middleware.Utils;
using NUnit.Framework;
@@ -22,11 +23,11 @@ private ResultParameters GetFile(string path)
return fileServer.Invoke(request.Call).Result;
}
- private String ReadBody(BodyDelegate body)
+ private String ReadBody(Func<Stream, Task> body)
{
using (MemoryStream buffer = new MemoryStream())
{
- body(buffer, CancellationToken.None).Wait();
+ body(buffer).Wait();
return Encoding.ASCII.GetString(buffer.ToArray());
}
}
View
2  src/Tests/Gate.Middleware.Tests/packages.config
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="2.5.10.11092" />
- <package id="Owin" version="0.11" />
+ <package id="Owin" version="0.12-ctp4" />
<package id="TaskHelpers.Sources" version="0.1" />
<package id="xunit" version="1.9.1" />
</packages>
View
5 src/Tests/Gate.TestHelpers/Gate.TestHelpers.csproj
@@ -35,8 +35,9 @@
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Newtonsoft.Json.4.5.7\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
- <Reference Include="Owin, Version=0.11.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
- <HintPath>..\..\..\packages\Owin.0.11\lib\net40\Owin.dll</HintPath>
+ <Reference Include="Owin, Version=0.12.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\packages\Owin.0.12-ctp4\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
View
19 src/Tests/Gate.TestHelpers/TestHttpClient.cs
@@ -38,7 +38,7 @@ public class Call
public IDictionary<string, object> Environment { get; set; }
public int ResponseStatus { get; set; }
public IDictionary<string, string[]> ResponseHeaders { get; set; }
- public BodyDelegate ResponseBody { get; set; }
+ public Func<Stream, Task> ResponseBody { get; set; }
public IDictionary<string, object> ResponseProperties { get; set; }
public Exception Exception { get; set; }
@@ -99,15 +99,14 @@ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage reques
{
Environment = call.Environment,
Headers = GetRequestHeaders(request),
- Body = body,
- Completed = cancel
+ Body = body
}))
.Then(result =>
{
call.ResponseStatus = result.Status;
call.ResponseHeaders = result.Headers;
call.ResponseBody = result.Body;
- call.HttpResponseMessage = MakeResponseMessage(result.Status, result.Headers, result.Body, result.Properties, cancel);
+ call.HttpResponseMessage = MakeResponseMessage(result.Status, result.Headers, result.Body, result.Properties);
call.HttpResponseMessage.RequestMessage = request;
return call.HttpResponseMessage;
});
@@ -128,13 +127,13 @@ static Task<Stream> GetRequestBody(HttpRequestMessage request)
return requestHeaders;
}
- static HttpResponseMessage MakeResponseMessage(int status, IDictionary<string, string[]> headers, BodyDelegate body, IDictionary<string, object> properties, CancellationToken cancel)
+ static HttpResponseMessage MakeResponseMessage(int status, IDictionary<string, string[]> headers, Func<Stream, Task> body, IDictionary<string, object> properties)
{
var response = new HttpResponseMessage((HttpStatusCode)status);
if (body != null)
{
- response.Content = new BodyDelegateHttpContent(body, cancel);
+ response.Content = new BodyDelegateHttpContent(body);
}
if (properties != null)
@@ -166,18 +165,16 @@ static HttpResponseMessage MakeResponseMessage(int status, IDictionary<string, s
class BodyDelegateHttpContent : HttpContent
{
- readonly BodyDelegate _body;
- readonly CancellationToken _cancel;
+ readonly Func<Stream, Task> _body;
- public BodyDelegateHttpContent(BodyDelegate body, CancellationToken cancel)
+ public BodyDelegateHttpContent(Func<Stream, Task> body)
{
_body = body;
- _cancel = cancel;
}
protected override Task SerializeToStreamAsync(Stream stream, TransportContext context)
{
- return _body(stream, _cancel);
+ return _body(stream);
}
protected override bool TryComputeLength(out long length)
View
2  src/Tests/Gate.TestHelpers/packages.config
@@ -3,6 +3,6 @@
<package id="Microsoft.AspNet.WebApi.Client" version="4.0.20710.0" />
<package id="Microsoft.Net.Http" version="2.0.20710.0" />
<package id="Newtonsoft.Json" version="4.5.7" />
- <package id="Owin" version="0.11" />
+ <package id="Owin" version="0.12-ctp4" />
<package id="TaskHelpers.Sources" version="0.1" />
</packages>
View
4 src/Tests/Gate.Tests/Gate.Tests.csproj
@@ -40,9 +40,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath>
</Reference>
- <Reference Include="Owin, Version=0.11.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
+ <Reference Include="Owin, Version=0.12.0.0, Culture=neutral, PublicKeyToken=f585506a2da1fef4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\packages\Owin.0.11\lib\net40\Owin.dll</HintPath>
+ <HintPath>..\..\..\packages\Owin.0.12-ctp4\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="pnunit.framework, Version=1.0.4109.34242, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
View
3  src/Tests/Gate.Tests/RequestTests.cs
@@ -14,10 +14,9 @@ private CallParameters CreateEmptyCall()
{
return new CallParameters()
{
- Body = null,
- Completed = CancellationToken.None,
Environment = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase),
Headers = Headers.New(),
+ Body = null,
};
}
View
5 src/Tests/Gate.Tests/ResponseTests.cs
@@ -3,6 +3,7 @@
using System.IO;
using System.Text;
using System.Threading;
+using System.Threading.Tasks;
using Owin;
using NUnit.Framework;
@@ -11,10 +12,10 @@ namespace Gate.Tests
[TestFixture]
public class ResponseTests
{
- private static byte[] Consume(BodyDelegate body)
+ private static byte[] Consume(Func<Stream, Task> body)
{
var memory = new MemoryStream();
- body(memory, CancellationToken.None).Wait();
+ body(memory).Wait();
return memory.ToArray();
}
View
4 src/Tests/Gate.Tests/TestClientTests.cs
@@ -106,7 +106,7 @@ AppDelegate EchoRequestBody()
call.Body.CopyTo(buffer);
buffer.Seek(0, SeekOrigin.Begin);
- result.Body = (stream, cancel) =>
+ result.Body = stream =>
{
buffer.CopyTo(stream);
return TaskHelpers.Completed();
@@ -129,7 +129,7 @@ AppDelegate ReturnText(string text)
{"X-Server", new[] {"inproc"}}
};
- result.Body = (stream, cancel) =>
+ result.Body = stream =>
{
byte[] body = Encoding.ASCII.GetBytes(text);
stream.Write(body, 0, body.Length);
View
1  src/Tests/Gate.Tests/UrlMapperTests.cs
@@ -19,7 +19,6 @@ private CallParameters CreateEmptyCall()
return new CallParameters()
{
Body = null,
- Completed = CancellationToken.None,
Environment = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase),
Headers = Headers.New(),
};
View
2  src/Tests/Gate.Tests/packages.config
@@ -2,6 +2,6 @@
<packages>
<package id="Microsoft.Net.Http" version="2.0.20525.0" />
<package id="NUnit" version="2.5.10.11092" />
- <package id="Owin" version="0.11" />
+ <package id="Owin" version="0.12-ctp4" />
<package id="xunit" version="1.9.1" />
</packages>
Please sign in to comment.
Something went wrong with that request. Please try again.