diff --git a/HttpAbstractions.sln b/HttpAbstractions.sln index d0bb133101..48380ad6d4 100644 --- a/HttpAbstractions.sln +++ b/HttpAbstractions.sln @@ -26,6 +26,7 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Abstractions.Owin.net45", "src\Microsoft.AspNet.Abstractions.Owin\Microsoft.AspNet.Abstractions.Owin.net45.csproj", "{E6B7056F-547E-4B96-9E58-858DDDAE75D3}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Abstractions.Owin.k10", "src\Microsoft.AspNet.Abstractions.Owin\Microsoft.AspNet.Abstractions.Owin.k10.csproj", "{C5C104A4-EE38-4D77-AC77-DF599FD5443A}" + EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/Microsoft.AspNet.Abstractions/HttpContext.cs b/src/Microsoft.AspNet.Abstractions/HttpContext.cs index 241c1d17e2..ab1193bd44 100644 --- a/src/Microsoft.AspNet.Abstractions/HttpContext.cs +++ b/src/Microsoft.AspNet.Abstractions/HttpContext.cs @@ -1,13 +1,15 @@ using System; +using System.Collections.Generic; namespace Microsoft.AspNet.Abstractions { public abstract class HttpContext : IDisposable { - // TODO - review IOwinContext for properties - public abstract HttpRequest Request { get; } + public abstract HttpResponse Response { get; } + + public abstract IDictionary Items { get; } public abstract void Dispose(); diff --git a/src/Microsoft.AspNet.PipelineCore/DefaultHttpContext.cs b/src/Microsoft.AspNet.PipelineCore/DefaultHttpContext.cs index bbd69ef0f8..f5a85826d7 100644 --- a/src/Microsoft.AspNet.PipelineCore/DefaultHttpContext.cs +++ b/src/Microsoft.AspNet.PipelineCore/DefaultHttpContext.cs @@ -18,6 +18,7 @@ namespace Microsoft.AspNet.PipelineCore } public override HttpRequest Request { get { return _request; } } + public override HttpResponse Response { get { return _response; } } public int Revision { get { return _environment.Revision; } } diff --git a/src/Microsoft.AspNet.PipelineCore/Infrastructure/ParsingHelpers.cs b/src/Microsoft.AspNet.PipelineCore/Infrastructure/ParsingHelpers.cs index 204b3cda0e..0a9a581ec2 100644 --- a/src/Microsoft.AspNet.PipelineCore/Infrastructure/ParsingHelpers.cs +++ b/src/Microsoft.AspNet.PipelineCore/Infrastructure/ParsingHelpers.cs @@ -1,4 +1,5 @@ using Microsoft.AspNet.Abstractions; +using Microsoft.AspNet.PipelineCore.Collections; using System; using System.Collections; using System.Collections.Generic; @@ -514,21 +515,32 @@ namespace Microsoft.AspNet.PipelineCore.Infrastructure private static readonly char[] SemicolonAndComma = new[] { ';', ',' }; + internal static T GetItem(HttpRequest request, string key) + { + object value; + return request.HttpContext.Items.TryGetValue(key, out value) ? (T)value : default(T); + } + + internal static void SetItem(HttpRequest request, string key, T value) + { + request.HttpContext.Items[key] = value; + } + internal static IDictionary GetCookies(HttpRequest request) { - var cookies = request.Get>("Microsoft.Owin.Cookies#dictionary"); + var cookies = GetItem>(request, "Microsoft.Owin.Cookies#dictionary"); if (cookies == null) { cookies = new Dictionary(StringComparer.Ordinal); - request.Set("Microsoft.Owin.Cookies#dictionary", cookies); + SetItem(request, "Microsoft.Owin.Cookies#dictionary", cookies); } string text = GetHeader(request.Headers, "Cookie"); - if (request.Get("Microsoft.Owin.Cookies#text") != text) + if (GetItem(request, "Microsoft.Owin.Cookies#text") != text) { cookies.Clear(); ParseDelimited(text, SemicolonAndComma, AddCookieCallback, cookies); - request.Set("Microsoft.Owin.Cookies#text", text); + SetItem(request, "Microsoft.Owin.Cookies#text", text); } return cookies; } @@ -570,14 +582,9 @@ namespace Microsoft.AspNet.PipelineCore.Infrastructure scanIndex = delimiterIndex + 1; } } - - internal static string GetJoinedValue(IDictionary Store, string key) - { - throw new NotImplementedException(); - } } - internal static partial class OwinHelpers + internal static partial class ParsingHelpers { public static string GetHeader(IDictionary headers, string key) { @@ -768,7 +775,7 @@ namespace Microsoft.AspNet.PipelineCore.Infrastructure } } - internal static partial class OwinHelpers + internal static partial class ParsingHelpers { private static readonly Action AppendItemCallback = (name, value, state) => { @@ -789,15 +796,15 @@ namespace Microsoft.AspNet.PipelineCore.Infrastructure internal static IDictionary GetQuery(HttpRequest request) { - var query = request.Get>("Microsoft.Owin.Query#dictionary"); + var query = GetItem>(request, "Microsoft.Owin.Query#dictionary"); if (query == null) { query = new Dictionary(StringComparer.OrdinalIgnoreCase); - request.Set("Microsoft.Owin.Query#dictionary", query); + SetItem(request, "Microsoft.Owin.Query#dictionary", query); } string text = request.QueryString.Value; - if (request.Get("Microsoft.Owin.Query#text") != text) + if (GetItem(request, "Microsoft.Owin.Query#text") != text) { query.Clear(); var accumulator = new Dictionary>(StringComparer.OrdinalIgnoreCase); @@ -806,7 +813,7 @@ namespace Microsoft.AspNet.PipelineCore.Infrastructure { query.Add(kv.Key, kv.Value.ToArray()); } - request.Set("Microsoft.Owin.Query#text", text); + SetItem(request, "Microsoft.Owin.Query#text", text); } return query; } @@ -842,7 +849,7 @@ namespace Microsoft.AspNet.PipelineCore.Infrastructure } } - internal static partial class OwinHelpers + internal static partial class ParsingHelpers { internal static string GetHost(HttpRequest request) { diff --git a/src/Microsoft.AspNet.PipelineCore/Microsoft.AspNet.PipelineCore.net45.csproj b/src/Microsoft.AspNet.PipelineCore/Microsoft.AspNet.PipelineCore.net45.csproj new file mode 100644 index 0000000000..b4d658e9fb --- /dev/null +++ b/src/Microsoft.AspNet.PipelineCore/Microsoft.AspNet.PipelineCore.net45.csproj @@ -0,0 +1,80 @@ + + + + + Debug + AnyCPU + {68A538BA-D542-49CB-9615-B4F5A4E78C87} + Library + Properties + Microsoft.AspNet.PipelineCore + Microsoft.AspNet.PipelineCore + v4.5 + 512 + obj/net45 + + + AnyCPU + true + full + false + bin\Debug\net45 + DEBUG;TRACE;NET45 + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\net45 + TRACE;NET45 + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + {95AEE59D-BF51-47CB-A957-C03D909CC148} + Microsoft.AspNet.FeatureModel + + + {D36288AF-8A0E-48DD-8AF8-15B72F91C70A} + Microsoft.AspNet.Abstractions + + + {A6DEB0D3-982E-4A07-8EE7-39269F192AF7} + Microsoft.AspNet.HttpFeature + + + + + \ No newline at end of file