├── .gitignore ├── .nuget ├── NuGet.Config ├── NuGet.targets └── nuget.exe ├── FileGrammar.shade ├── LICENSE.txt ├── NOTICE.txt ├── OwinHosting.sln ├── OwinHosting.sln.DotSettings ├── README.md ├── Sakefile.shade ├── Settings.StyleCop ├── _line.shade ├── build.cmd ├── build.sh └── src ├── Common.snk.gpg ├── Common.targets ├── main ├── Owin.AutoStartup │ ├── AutoStartupInfrastructure.cs │ ├── Owin.AutoStartup.HttpListener.nuspec │ ├── Owin.AutoStartup.Sources.nuspec │ ├── Owin.AutoStartup.SystemWeb.nuspec │ ├── Owin.AutoStartup.csproj │ ├── Owin.AutoStartup.nuspec │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Startup.cs.pp │ ├── packages.config │ └── web.config.transform ├── Owin.Builder │ ├── AppBuilder.cs │ ├── GlobalSuppressions.cs │ ├── NotFound.cs │ ├── Owin.Builder.Sources.nuspec │ ├── Owin.Builder.csproj │ ├── Owin.Builder.nuspec │ ├── Properties │ │ └── AssemblyInfo.cs │ └── packages.config ├── Owin.Extensions │ ├── CustomDictionary.xml │ ├── Owin.Extensions.Sources.nuspec │ ├── Owin.Extensions.csproj │ ├── Owin.Extensions.nuspec │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── StartupExtensions.Func.cs │ ├── StartupExtensions.Type.cs │ ├── StartupExtensions.cs │ └── packages.config ├── Owin.Loader │ ├── DefaultLoader.cs │ ├── GlobalSuppressions.cs │ ├── NullLoader.cs │ ├── Owin.Loader.Sources.nuspec │ ├── Owin.Loader.csproj │ ├── Owin.Loader.nuspec │ ├── Properties │ │ └── AssemblyInfo.cs │ └── packages.config ├── Owin.Startup │ ├── GlobalSuppressions.cs │ ├── IAppBuilder.cs │ ├── Owin.csproj │ ├── Owin.nuspec_archived │ └── Properties │ │ └── AssemblyInfo.cs └── Owin.Types │ ├── Extensions │ ├── OwinRequestExtensions.Forwarded..cs │ └── OwinRequestExtensions.MethodOverride.cs │ ├── Generated.tt │ ├── Generated.txt │ ├── GlobalSuppressions.cs │ ├── Helpers │ ├── OwinHelpers.Forwarded.cs │ ├── OwinHelpers.Header.cs │ ├── OwinHelpers.MethodOverride.cs │ └── OwinHelpers.Uri.cs │ ├── Owin.Types.Sources.nuspec │ ├── Owin.Types.csproj │ ├── Owin.Types.nuspec │ ├── OwinConstants.cs │ ├── OwinOpaque.Generated.cs │ ├── OwinOpaque.Spec-Opaque.cs │ ├── OwinOpaqueParameters.Generated.cs │ ├── OwinOpaqueParameters.cs │ ├── OwinRequest.Generated.cs │ ├── OwinRequest.Spec-CommonKeys.cs │ ├── OwinRequest.Spec-Opaque.cs │ ├── OwinRequest.Spec-Owin.cs │ ├── OwinRequest.Spec-WebSocket.cs │ ├── OwinRequest.cs │ ├── OwinResponse.Generated.cs │ ├── OwinResponse.Spec-Owin.cs │ ├── OwinResponse.Spec-SendFile.cs │ ├── OwinResponse.cs │ ├── OwinWebSocket.Generated.cs │ ├── OwinWebSocket.Spec-WebSocket.cs │ ├── OwinWebSocket.cs │ ├── OwinWebSocketParameters.Generated.cs │ ├── OwinWebSocketParameters.Spec-WebSocket.cs │ ├── OwinWebSocketParameters.cs │ ├── OwinWebSocketReceiveMessage.cs │ └── Properties │ └── AssemblyInfo.cs └── test ├── MiddlewareConvention1 ├── Alpha.cs ├── App_Packages │ └── TaskHelpers.Sources.0.2 │ │ ├── TaskHelpers.cs │ │ └── TaskHelpersExtensions.cs ├── Gamma.cs ├── MiddlewareConvention1.csproj ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── MiddlewareConvention2 ├── App_Packages │ └── TaskHelpers.Sources.0.2 │ │ ├── TaskHelpers.cs │ │ └── TaskHelpersExtensions.cs ├── Beta.cs ├── Delta.cs ├── MiddlewareConvention2.csproj ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── Owin.Builder.Tests ├── AppBuilderTests.cs ├── App_Packages │ └── TaskHelpers.Sources.0.2 │ │ ├── TaskHelpers.cs │ │ └── TaskHelpersExtensions.cs ├── ConventionsTests.cs ├── Owin.Builder.Tests.csproj ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── Owin.Loader.Tests ├── Class1.cs ├── Owin.Loader.Tests.csproj ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── Owin.Types.Tests ├── Owin.Types.Tests.csproj ├── OwinHeadersTests.cs ├── OwinHelpersForwardedTests.cs ├── OwinHelpersMethodOverrideTests.cs ├── OwinRequestTests.cs ├── OwinResponseSendFileTests.cs ├── OwinResponseTests.cs ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── StartupConvention1 ├── Properties │ └── AssemblyInfo.cs ├── Startup.cs ├── StartupConvention1.csproj ├── Web.Debug.config ├── Web.Release.config ├── Web.config └── packages.config ├── StartupConvention2 ├── Properties │ └── AssemblyInfo.cs ├── Startup.cs ├── StartupConvention2.csproj ├── Web.Debug.config ├── Web.Release.config └── Web.config └── Utils ├── OwinHelper.cs ├── Properties └── AssemblyInfo.cs └── Utils.csproj /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | obj 3 | *.suo 4 | *.user 5 | _ReSharper.* 6 | *.DS_Store 7 | *.userprefs 8 | *.pidb 9 | TestResult.xml 10 | nugetkey 11 | packages 12 | target 13 | StyleCop.Cache 14 | TestResults/* 15 | *.snk 16 | -------------------------------------------------------------------------------- /.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.nuget/nuget.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owin-contrib/owin-hosting/e592ab4fc96d98adbfd2303793f7f2cc6fdf26a3/.nuget/nuget.exe -------------------------------------------------------------------------------- /FileGrammar.shade: -------------------------------------------------------------------------------- 1 | use namespace='Spark.Parser' 2 | use assembly='Spark' 3 | functions 4 | @{ 5 | public class FileGrammar : Spark.Parser.Code.CodeGrammar 6 | { 7 | public FileGrammar() 8 | { 9 | var ws = Ch((char)' ', (char)'\t', (char)'\r', (char)'\n'); 10 | 11 | var usingHunk = Build( 12 | "using", 13 | Ch("using") 14 | .And(Rep1(ws)) 15 | .And(Str(Rep1(ChNot(';')))) 16 | .And(Ch(';')), 17 | hit => new Hunk { Namespace = hit.Left.Down }); 18 | 19 | var whitespaceHunk = Build("whitespace", 20 | Rep1(ws), 21 | hit => new Hunk()); 22 | 23 | var namespaceHunk = Build( 24 | "namespace", 25 | Ch("namespace") 26 | .And(Rep1(ws)) 27 | .And(Str(Rep1(ChNot('{')))) 28 | .And(Ch('{')) 29 | .And(Str(LimitedExpression(Ch("}")))) 30 | .And(Ch('}')), 31 | hit => new Hunk { Namespace = hit.Left.Left.Left.Down, Code = hit.Left.Down }); 32 | 33 | var hunk = usingHunk.Or(namespaceHunk); 34 | 35 | var garbageHunk = Build( 36 | "garbage", 37 | Rep1(Ch(ch => true).Unless(hunk)), 38 | hit => new Hunk()); 39 | 40 | var hunks = Rep(hunk.Or(garbageHunk)); 41 | Hunks = hunks; 42 | } 43 | 44 | public ParseAction> Hunks { get; set; } 45 | 46 | public class Hunk 47 | { 48 | public Position Position { get; set; } 49 | public string Type { get; set; } 50 | public string Text { get; set; } 51 | public string Namespace { get; set; } 52 | public string Code { get; set; } 53 | } 54 | 55 | ParseAction Str(ParseAction parser) 56 | { 57 | return pos => 58 | { 59 | var result = parser(pos); 60 | return result == null ? null : new ParseResult(result.Rest, pos.Peek(result.Rest.Offset - pos.Offset)); 61 | }; 62 | } 63 | ParseAction Build(string type, ParseAction parser, Func builder) 64 | { 65 | return pos => 66 | { 67 | var result = parser(pos); 68 | if (result == null) return null; 69 | 70 | var hunk = builder(result.Value); 71 | hunk.Position = pos; 72 | hunk.Type = type; 73 | hunk.Text = pos.Peek(result.Rest.Offset - pos.Offset); 74 | return new ParseResult(result.Rest, hunk); 75 | }; 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | OWIN hosting components 2 | Copyright 2012 Louis DeJardin 3 | Copyright 2012 Chris Ross 4 | -------------------------------------------------------------------------------- /OwinHosting.sln.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | 0AB5F10C-F0AD-47AD-AF23-AE80CDB7A19C/d:App_Packages 3 | 0AF835A6-8181-46DB-A17E-C765FA07A5A0/d:App_Packages 4 | 7F67B407-628C-403D-9235-EEE6AF64D32A/d:App_Packages 5 | <?xml version="1.0" encoding="utf-16"?><Profile name="Owin-Hosting"><CSUpdateFileHeader>True</CSUpdateFileHeader><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings></Profile> 6 | Licensed to Monkey Square, Inc. under one or more contributor 7 | license agreements. See the NOTICE file distributed with 8 | this work or additional information regarding copyright 9 | ownership. Monkey Square, Inc. licenses this file to you 10 | under the Apache License, Version 2.0 (the "License"); you 11 | may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, 17 | software distributed under the License is distributed on an 18 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 19 | KIND, either express or implied. See the License for the 20 | specific language governing permissions and limitations 21 | under the License. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | owin-hosting 2 | ============ 3 | 4 | OWIN hosting components -------------------------------------------------------------------------------- /Sakefile.shade: -------------------------------------------------------------------------------- 1 | 2 | var PROJECT='OWIN startup components' 3 | var VERSION='0.7' 4 | var FULL_VERSION='${VERSION}-alpha' 5 | var AUTHORS='${PROJECT} contributors' 6 | 7 | var BASE_DIR='${Directory.GetCurrentDirectory()}' 8 | var TARGET_DIR='${Path.Combine(BASE_DIR, "target")}' 9 | var BUILD_DIR='${Path.Combine(TARGET_DIR, "build")}' 10 | var TEST_DIR='${Path.Combine(TARGET_DIR, "test")}' 11 | 12 | var NUGET_DEPLOY='http://www.myget.org/F/owin/' 13 | 14 | var BUILD_PROJECTS='${Files.Include("src/main/**/*.csproj")}' 15 | 16 | -// include range of standard general targets. run "sake targets" to display 17 | use-standard-lifecycle 18 | 19 | -// include sets of standard work targets. features include 'nuget,xunit,nunit' 20 | use-standard-goals features='nuget,xunit' 21 | 22 | -// additional work targets are defined below 23 | 24 | #release 25 | @{ 26 | // To publish, call `build release deploy` 27 | NUGET_DEPLOY = ''; 28 | FULL_VERSION = VERSION; 29 | } 30 | 31 | -// override nuget-package to pin OWIN to 1.0 32 | #nuget-package target='package' description='Create NuGet packages' 33 | for each='var file in Files.Include("target/build/**/*.nuspec")' 34 | var baseName='${Path.GetFileNameWithoutExtension(file)}' 35 | var packageVersion='${FULL_VERSION}' 36 | set packageVersion='1.0' if='file.EndsWith("Owin.nuspec")' 37 | 38 | nuget-pack nuspecFile='${file}' outputDir='${TARGET_DIR}' extra='-NoPackageAnalysis -Properties "id=${baseName};authors=${AUTHORS}"' 39 | 40 | #nuget-deploy target='deploy' description='Upload NuGet packages to gallery' 41 | var extra='' 42 | set extra='${extra} -Source ${NUGET_DEPLOY}' if='!string.IsNullOrEmpty(NUGET_DEPLOY)' 43 | nuget-push each='var nupkgFile in Files.Include("target/*.nupkg").Exclude("target/Owin.1.0.nupkg")' 44 | 45 | #sources-package-prepare target='package-prepare' 46 | for each='var file in Files.Include("src/**/*.Sources.nuspec")' 47 | var projectDir='${Path.GetDirectoryName(file)}' 48 | var projectName='${Path.GetFileName(projectDir)}' 49 | 50 | copy sourceDir='${projectDir}' include='**/*.cs' exclude='**/App_Packages/**/*' outputDir='${BUILD_DIR}\${projectName}' overwrite='${true}' 51 | copy sourceDir='.' include='LICENSE.txt' outputDir='${BUILD_DIR}\${projectName}' overwrite='${true}' 52 | copy sourceDir='.' include='NOTICE.txt' outputDir='${BUILD_DIR}\${projectName}' overwrite='${true}' 53 | 54 | for each='var deleteFile in Files.Include(BUILD_DIR + "/" + projectName + "/**/AssemblyInfo.cs")' -File.Delete(deleteFile); 55 | 56 | var files='${new Dictionary>()}' 57 | 58 | use import='FileGrammar' 59 | update-file each='var updateFile in Files.Include(BUILD_DIR + "/" + projectName + "/**/*.cs")' 60 | @{ 61 | updateText = updateText 62 | .Replace("public static partial class", "internal static partial class") 63 | .Replace("public static class", "internal static class") 64 | .Replace("public class", "internal class") 65 | .Replace("public struct", "internal struct") 66 | .Replace("public partial struct", "internal partial struct") 67 | .Replace("public enum", "internal enum") 68 | .Replace("public delegate", "internal delegate") 69 | .Replace("public interface", "internal interface") 70 | .Replace(" /// ", " // "); 71 | 72 | var hunks = new FileGrammar().Hunks(new Position(new SourceContext(updateText, 0, updateFile))); 73 | files.Add(updateFile, hunks.Value); 74 | } 75 | 76 | var groups="${files.GroupBy(kv => Path.GetDirectoryName(kv.Key) + '\\' + Path.GetFileName(kv.Key).Split((char)'.').First())}" 77 | for each="var group in groups" 78 | test if='group.Count() == 1' 79 | log info='Skipping single file group ${group.Key}' 80 | else 81 | log info='Output group ${group.Key} has ${group.Count()} parts' 82 | var allHunks='${group.SelectMany(kv=>kv.Value)}' 83 | var allNamespaces='${allHunks.Where(x=>x.Type=="using").Select(x=>x.Namespace).Distinct().OrderBy(x=>(x.Contains("=")?"1":"0")+ x)}' 84 | var allCode='${allHunks.Where(x=>x.Type=="namespace")}' 85 | content var='newCode' 86 | for each='var ns in allNamespaces' line|using !{ns}; 87 | line| 88 | line|namespace !{allCode.First().Namespace.Trim()} 89 | line|{ 90 | for each='var code in allCode' 91 | line|#region !{Path.GetFileNameWithoutExtension(code.Position.SourceContext.FileName)} 92 | |!{code.Code} 93 | line|#endregion 94 | line| 95 | line|} 96 | for each='var kv in group' -File.Delete(kv.Key); 97 | -File.WriteAllText(group.Key + ".cs", newCode); 98 | 99 | -------------------------------------------------------------------------------- /_line.shade: -------------------------------------------------------------------------------- 1 | render 2 | |!{"\r\n"} 3 | -------------------------------------------------------------------------------- /build.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd %~dp0 3 | 4 | set EnableNuGetPackageRestore=true 5 | ".nuget\NuGet.exe" install Sake -version 0.2 -o packages 6 | for /f "tokens=*" %%G in ('dir /AD /ON /B "packages\Sake.*"') do set __sake__=%%G 7 | "packages\%__sake__%\tools\Sake.exe" -I src/build -f Sakefile.shade %* 8 | set __sake__= 9 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export EnableNuGetPackageRestore=true 4 | mono --runtime=v4.0 ".nuget/NuGet.exe" install Sake -pre -o packages 5 | mono $(find packages/Sake.*/tools/Sake.exe|sort -r|head -n1) -f Sakefile.shade -I src/build "$@" 6 | 7 | -------------------------------------------------------------------------------- /src/Common.snk.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owin-contrib/owin-hosting/e592ab4fc96d98adbfd2303793f7f2cc6fdf26a3/src/Common.snk.gpg -------------------------------------------------------------------------------- /src/Common.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ..\..\Common.snk 5 | true 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/main/Owin.AutoStartup/Owin.AutoStartup.HttpListener.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | $authors$ 7 | $authors$ 8 | https://github.com/owin-contrib/owin-hosting/blob/master/LICENSE.txt 9 | https://github.com/owin-contrib/owin-hosting/ 10 | false 11 | OWIN common builder sources 12 | OWIN 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/main/Owin.AutoStartup/Owin.AutoStartup.Sources.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | $authors$ 7 | $authors$ 8 | https://github.com/owin-contrib/owin-hosting/blob/master/LICENSE.txt 9 | https://github.com/owin-contrib/owin-hosting/ 10 | false 11 | OWIN auto startup 12 | OWIN 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/Owin.AutoStartup/Owin.AutoStartup.SystemWeb.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | $authors$ 7 | $authors$ 8 | https://github.com/owin-contrib/owin-hosting/blob/master/LICENSE.txt 9 | https://github.com/owin-contrib/owin-hosting/ 10 | false 11 | OWIN common builder sources 12 | OWIN 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/Owin.AutoStartup/Owin.AutoStartup.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {5F97C4CD-31D3-4AC7-A5AB-E0E4D0B79849} 8 | Library 9 | Properties 10 | Owin.AutoStartup 11 | Owin.AutoStartup 12 | v4.0 13 | 512 14 | ..\..\..\ 15 | true 16 | 17 | 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | ..\..\..\packages\Owin.1.0\lib\net40\Owin.dll 37 | 38 | 39 | 40 | 41 | 42 | 43 | PreserveNewest 44 | 45 | 46 | PreserveNewest 47 | 48 | 49 | 50 | 51 | 52 | PreserveNewest 53 | 54 | 55 | PreserveNewest 56 | 57 | 58 | 59 | 60 | PreserveNewest 61 | 62 | 63 | 64 | 65 | 72 | -------------------------------------------------------------------------------- /src/main/Owin.AutoStartup/Owin.AutoStartup.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | $authors$ 7 | $authors$ 8 | https://github.com/owin-contrib/owin-hosting/blob/master/LICENSE.txt 9 | https://github.com/owin-contrib/owin-hosting/ 10 | false 11 | OWIN auto startup 12 | OWIN 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/Owin.AutoStartup/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Owin.AutoStartup")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCulture("")] 12 | 13 | // Setting ComVisible to false makes the types in this assembly not visible 14 | // to COM components. If you need to access a type in this assembly from 15 | // COM, set the ComVisible attribute to true on that type. 16 | [assembly: ComVisible(false)] 17 | 18 | // The following GUID is for the ID of the typelib if this project is exposed to COM 19 | [assembly: Guid("84a6388d-059a-454c-b2c8-4a06bff00d23")] 20 | 21 | [assembly: AssemblyVersion("0.7")] 22 | [assembly: AssemblyFileVersion("0.7")] 23 | [assembly: AssemblyInformationalVersion("0.7-alpha")] 24 | [assembly: CLSCompliant(true)] 25 | -------------------------------------------------------------------------------- /src/main/Owin.AutoStartup/Startup.cs.pp: -------------------------------------------------------------------------------- 1 | using System; 2 | using Owin; 3 | using Owin.AutoStartup; 4 | 5 | namespace $rootnamespace$ 6 | { 7 | public partial class Startup 8 | { 9 | public IServiceProvider ServiceProvider { get; set; } 10 | 11 | public Startup() 12 | { 13 | } 14 | 15 | public Startup(IServiceProvider serviceProvider) 16 | { 17 | ServiceProvider = serviceProvider; 18 | } 19 | 20 | public void AutoConfiguration(IAppBuilder app) 21 | { 22 | AutoStartupInfrastructure.ExecuteConfigurationMethods(this, app); 23 | } 24 | 25 | public void Post050_ExecuteOwinAutoStartups(IAppBuilder app) 26 | { 27 | AutoStartupInfrastructure.ExecuteOwinAutoStartups(ServiceProvider, app); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/Owin.AutoStartup/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/main/Owin.AutoStartup/web.config.transform: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/Owin.Builder/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Owin", Justification = "Project name")] 18 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Owin", Scope = "namespace", Target = "Owin.Builder", Justification = "Project name")] 19 | -------------------------------------------------------------------------------- /src/main/Owin.Builder/NotFound.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System.Collections.Generic; 19 | using System.Threading.Tasks; 20 | 21 | namespace Owin.Builder 22 | { 23 | /// 24 | /// Simple object used by AppBuilder as seed OWIN callable if the 25 | /// builder.Properties["builder.DefaultApp"] is not set 26 | /// 27 | internal class NotFound 28 | { 29 | private static readonly Task Completed = CreateCompletedTask(); 30 | 31 | private static Task CreateCompletedTask() 32 | { 33 | var tcs = new TaskCompletionSource(); 34 | tcs.SetResult(null); 35 | return tcs.Task; 36 | } 37 | 38 | public Task Invoke(IDictionary env) 39 | { 40 | env["owin.ResponseStatusCode"] = 404; 41 | return Completed; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/Owin.Builder/Owin.Builder.Sources.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | $authors$ 7 | $authors$ 8 | https://github.com/owin-contrib/owin-hosting/blob/master/LICENSE.txt 9 | https://github.com/owin-contrib/owin-hosting/ 10 | false 11 | OWIN common builder sources 12 | OWIN 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/Owin.Builder/Owin.Builder.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {2DCFACC8-AFD4-4FBA-8A89-9ACDC5CF4964} 9 | Library 10 | Properties 11 | Owin.Builder 12 | Owin.Builder 13 | v4.0 14 | 512 15 | ..\..\..\ 16 | true 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | true 27 | AllRules.ruleset 28 | 29 | 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | false 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | False 47 | ..\..\..\packages\Owin.1.0\lib\net40\Owin.dll 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 73 | -------------------------------------------------------------------------------- /src/main/Owin.Builder/Owin.Builder.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | $authors$ 7 | $authors$ 8 | https://github.com/owin-contrib/owin-hosting/blob/master/LICENSE.txt 9 | https://github.com/owin-contrib/owin-hosting/ 10 | false 11 | OWIN common builder 12 | OWIN 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/Owin.Builder/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Reflection; 20 | using System.Runtime.InteropServices; 21 | 22 | // General Information about an assembly is controlled through the following 23 | // set of attributes. Change these attribute values to modify the information 24 | // associated with an assembly. 25 | [assembly: AssemblyTitle("Owin.Builder")] 26 | [assembly: AssemblyDescription("")] 27 | [assembly: AssemblyConfiguration("")] 28 | [assembly: AssemblyCulture("")] 29 | 30 | // Setting ComVisible to false makes the types in this assembly not visible 31 | // to COM components. If you need to access a type in this assembly from 32 | // COM, set the ComVisible attribute to true on that type. 33 | [assembly: ComVisible(false)] 34 | 35 | // The following GUID is for the ID of the typelib if this project is exposed to COM 36 | [assembly: Guid("e1720c2c-61dd-4759-82fb-33a4eeaf6ed1")] 37 | 38 | [assembly: AssemblyVersion("0.7")] 39 | [assembly: AssemblyFileVersion("0.7")] 40 | [assembly: AssemblyInformationalVersion("0.7-alpha")] 41 | [assembly: CLSCompliant(false)] 42 | -------------------------------------------------------------------------------- /src/main/Owin.Builder/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/main/Owin.Extensions/CustomDictionary.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Owin 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/main/Owin.Extensions/Owin.Extensions.Sources.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | $authors$ 7 | $authors$ 8 | https://github.com/owin-contrib/owin-hosting/blob/master/LICENSE.txt 9 | https://github.com/owin-contrib/owin-hosting/ 10 | false 11 | OWIN common extensions sources 12 | OWIN 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/main/Owin.Extensions/Owin.Extensions.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {EB90CB5C-13D4-4E8A-AB69-839A99E9066A} 8 | Library 9 | Properties 10 | Owin.Extensions 11 | Owin.Extensions 12 | v4.0 13 | 512 14 | ..\..\..\ 15 | true 16 | 17 | 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | true 26 | AllRules.ruleset 27 | 28 | 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | false 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | False 46 | ..\..\..\packages\Owin.1.0\lib\net40\Owin.dll 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | Designer 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | {06b11480-240f-4efb-aa6c-8eb354adcf83} 75 | Owin.Types 76 | 77 | 78 | 79 | 80 | 81 | 88 | -------------------------------------------------------------------------------- /src/main/Owin.Extensions/Owin.Extensions.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | $authors$ 7 | $authors$ 8 | https://github.com/owin-contrib/owin-hosting/blob/master/LICENSE.txt 9 | https://github.com/owin-contrib/owin-hosting/ 10 | false 11 | OWIN common extensions 12 | OWIN 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/main/Owin.Extensions/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Reflection; 20 | using System.Runtime.InteropServices; 21 | 22 | // General Information about an assembly is controlled through the following 23 | // set of attributes. Change these attribute values to modify the information 24 | // associated with an assembly. 25 | [assembly: AssemblyTitle("Owin.Extensions")] 26 | [assembly: AssemblyDescription("")] 27 | [assembly: AssemblyConfiguration("")] 28 | [assembly: AssemblyCulture("")] 29 | 30 | // Setting ComVisible to false makes the types in this assembly not visible 31 | // to COM components. If you need to access a type in this assembly from 32 | // COM, set the ComVisible attribute to true on that type. 33 | [assembly: ComVisible(false)] 34 | 35 | // The following GUID is for the ID of the typelib if this project is exposed to COM 36 | [assembly: Guid("3a75a18a-bf36-4a96-b4b9-ebd88ed8c85b")] 37 | 38 | [assembly: AssemblyVersion("0.7")] 39 | [assembly: AssemblyFileVersion("0.7")] 40 | [assembly: AssemblyInformationalVersion("0.7-alpha")] 41 | [assembly: CLSCompliant(true)] 42 | -------------------------------------------------------------------------------- /src/main/Owin.Extensions/StartupExtensions.Type.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Diagnostics.CodeAnalysis; 20 | 21 | namespace Owin 22 | { 23 | public static partial class StartupExtensions 24 | { 25 | [SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "By design")] 26 | public static IAppBuilder UseType(this IAppBuilder builder, params object[] args) 27 | { 28 | if (builder == null) 29 | { 30 | throw new ArgumentNullException("builder"); 31 | } 32 | 33 | return builder.Use(typeof(TMiddleware), args); 34 | } 35 | 36 | public static IAppBuilder UseType(this IAppBuilder builder, Type type, params object[] args) 37 | { 38 | if (builder == null) 39 | { 40 | throw new ArgumentNullException("builder"); 41 | } 42 | if (type == null) 43 | { 44 | throw new ArgumentNullException("type"); 45 | } 46 | 47 | return builder.Use(type, args); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/Owin.Extensions/StartupExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Diagnostics.CodeAnalysis; 20 | using System.Threading.Tasks; 21 | using Owin.Types; 22 | using AppFunc = System.Func, System.Threading.Tasks.Task>; 23 | 24 | namespace Owin 25 | { 26 | public static partial class StartupExtensions 27 | { 28 | public static void Run(this IAppBuilder builder, object app) 29 | { 30 | if (builder == null) 31 | { 32 | throw new ArgumentNullException("builder"); 33 | } 34 | 35 | builder.Use(new Func(ignored => app)); 36 | } 37 | 38 | [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "By design")] 39 | public static AppFunc Build(this IAppBuilder builder) 40 | { 41 | return builder.Build(); 42 | } 43 | 44 | public static TApp Build(this IAppBuilder builder) 45 | { 46 | if (builder == null) 47 | { 48 | throw new ArgumentNullException("builder"); 49 | } 50 | 51 | return (TApp)builder.Build(typeof(TApp)); 52 | } 53 | 54 | [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix", Justification = "By design")] 55 | [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "By design")] 56 | public static AppFunc BuildNew(this IAppBuilder builder, Action configuration) 57 | { 58 | if (builder == null) 59 | { 60 | throw new ArgumentNullException("builder"); 61 | } 62 | if (configuration == null) 63 | { 64 | throw new ArgumentNullException("configuration"); 65 | } 66 | 67 | return builder.BuildNew(configuration); 68 | } 69 | 70 | [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix", Justification = "By design")] 71 | public static TApp BuildNew(this IAppBuilder builder, Action configuration) 72 | { 73 | if (builder == null) 74 | { 75 | throw new ArgumentNullException("builder"); 76 | } 77 | if (configuration == null) 78 | { 79 | throw new ArgumentNullException("configuration"); 80 | } 81 | 82 | IAppBuilder nested = builder.New(); 83 | configuration(nested); 84 | return nested.Build(); 85 | } 86 | 87 | [SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily", Justification = "False positive")] 88 | public static void AddSignatureConversion( 89 | this IAppBuilder builder, 90 | Delegate conversion) 91 | { 92 | if (builder == null) 93 | { 94 | throw new ArgumentNullException("builder"); 95 | } 96 | 97 | object value; 98 | if (builder.Properties.TryGetValue("builder.AddSignatureConversion", out value) && 99 | value is Action) 100 | { 101 | ((Action)value).Invoke(conversion); 102 | } 103 | else 104 | { 105 | throw new MissingMethodException(builder.GetType().FullName, "AddSignatureConversion"); 106 | } 107 | } 108 | 109 | [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "By design")] 110 | public static IAppBuilder UseOwin( 111 | this IAppBuilder builder, 112 | Func, Task> process) 113 | { 114 | return builder.UseFunc(next => env => process(new OwinRequest(env), new OwinResponse(env), () => next(env))); 115 | } 116 | 117 | //[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "By design")] 118 | //public static IAppBuilder UseOwin( 119 | // this IAppBuilder builder, 120 | // Func process) 121 | //{ 122 | // return builder.UseFunc(_ => env => process(new OwinRequest(env), new OwinResponse(env))); 123 | //} 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/main/Owin.Extensions/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/main/Owin.Loader/GlobalSuppressions.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owin-contrib/owin-hosting/e592ab4fc96d98adbfd2303793f7f2cc6fdf26a3/src/main/Owin.Loader/GlobalSuppressions.cs -------------------------------------------------------------------------------- /src/main/Owin.Loader/NullLoader.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Diagnostics.CodeAnalysis; 20 | 21 | namespace Owin.Loader 22 | { 23 | public class NullLoader 24 | { 25 | private static readonly NullLoader Singleton = new NullLoader(); 26 | 27 | [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "By design")] 28 | public static Func> Instance 29 | { 30 | get { return Singleton.Load; } 31 | } 32 | 33 | public Action Load(string startup) 34 | { 35 | return null; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/Owin.Loader/Owin.Loader.Sources.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | $authors$ 7 | $authors$ 8 | https://github.com/owin-contrib/owin-hosting/blob/master/LICENSE.txt 9 | https://github.com/owin-contrib/owin-hosting/ 10 | false 11 | OWIN common loader sources 12 | OWIN 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/Owin.Loader/Owin.Loader.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {DF967ED4-C320-421C-859C-81034EFF615E} 9 | Library 10 | Properties 11 | Owin.Loader 12 | Owin.Loader 13 | v4.0 14 | 512 15 | ..\..\..\ 16 | true 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | true 27 | AllRules.ruleset 28 | 29 | 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | false 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | False 47 | ..\..\..\packages\Owin.1.0\lib\net40\Owin.dll 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 78 | -------------------------------------------------------------------------------- /src/main/Owin.Loader/Owin.Loader.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | $authors$ 7 | $authors$ 8 | https://github.com/owin-contrib/owin-hosting/blob/master/LICENSE.txt 9 | https://github.com/owin-contrib/owin-hosting/ 10 | false 11 | OWIN common loader 12 | OWIN 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/Owin.Loader/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Reflection; 20 | using System.Runtime.InteropServices; 21 | 22 | // General Information about an assembly is controlled through the following 23 | // set of attributes. Change these attribute values to modify the information 24 | // associated with an assembly. 25 | [assembly: AssemblyTitle("Owin.Loader")] 26 | [assembly: AssemblyDescription("")] 27 | [assembly: AssemblyConfiguration("")] 28 | [assembly: AssemblyCulture("")] 29 | 30 | // Setting ComVisible to false makes the types in this assembly not visible 31 | // to COM components. If you need to access a type in this assembly from 32 | // COM, set the ComVisible attribute to true on that type. 33 | [assembly: ComVisible(false)] 34 | 35 | // The following GUID is for the ID of the typelib if this project is exposed to COM 36 | [assembly: Guid("dff310ba-b3ec-434c-9c42-18f199b872b8")] 37 | 38 | [assembly: AssemblyVersion("0.7")] 39 | [assembly: AssemblyFileVersion("0.7")] 40 | [assembly: CLSCompliant(false)] 41 | -------------------------------------------------------------------------------- /src/main/Owin.Loader/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/main/Owin.Startup/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Owin", Justification = "Project name")] 18 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Owin", Scope = "namespace", Target = "Owin", Justification = "Project name")] 19 | -------------------------------------------------------------------------------- /src/main/Owin.Startup/IAppBuilder.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Collections.Generic; 20 | using System.Diagnostics.CodeAnalysis; 21 | 22 | namespace Owin 23 | { 24 | /// 25 | /// This interface may be passed to web site's Startup code. It enables the 26 | /// site author to add middleware to an OWIN pipeline, typically ending with 27 | /// the OWIN adapter for the web framework their site is build upon. 28 | /// 29 | public interface IAppBuilder 30 | { 31 | /// 32 | /// Contains arbitrary properties which may added, examined, and modified by 33 | /// components during the startup sequence. 34 | /// 35 | IDictionary Properties { get; } 36 | 37 | /// 38 | /// Adds a middleware node to the OWIN function pipeline. The middleware are 39 | /// invoked in the order they are added: the first middleware passed to Use will 40 | /// be the outermost function, and the last middleware passed to Use will be the 41 | /// innermost. 42 | /// 43 | /// 44 | /// The middleware parameter determines which behavior is being chained into the 45 | /// pipeline. 46 | /// 47 | /// If the middleware given to Use is a Delegate, then it will be invoked with the "next app" in 48 | /// the chain as the first parameter. If the delegate takes more than the single argument, 49 | /// then the additional values must be provided to Use in the args array. 50 | /// 51 | /// If the middleware given to Use is a Type, then the public constructor will be 52 | /// invoked with the "next app" in the chain as the first parameter. The resulting object 53 | /// must have a public Invoke method. If the object has constructors which take more than 54 | /// the single "next app" argument, then additional values may be provided in the args array. 55 | /// 56 | /// 57 | /// Any additional args passed to Use will be passed as additional values, following the "next app" 58 | /// parameter, when the OWIN call pipeline is build. 59 | /// 60 | /// They are passed as additional parameters if the middleware parameter is a Delegate, or as additional 61 | /// constructor arguments if the middle parameter is a Type. 62 | /// 63 | /// 64 | /// The IAppBuilder itself is returned. This enables you to chain your use statements together. 65 | /// 66 | IAppBuilder Use(object middleware, params object[] args); 67 | 68 | /// 69 | /// The Build is called at the point when all of the middleware should be chained 70 | /// together. This is typically done by the hosting component which created the app builder, 71 | /// and does not need to be called by the startup method if the IAppBuilder is passed in. 72 | /// 73 | /// 74 | /// The Type argument indicates which calling convention should be returned, and 75 | /// is typically typeof() for the OWIN 76 | /// calling convention. 77 | /// 78 | /// 79 | /// Returns an instance of the pipeline's entry point. This object may be safely cast to the 80 | /// type which was provided 81 | /// 82 | object Build(Type returnType); 83 | 84 | /// 85 | /// The New method creates a new instance of an IAppBuilder. This is needed to create 86 | /// a tree structure in your processing, rather than a linear pipeline. The new instance share the 87 | /// same Properties, but will be created with a new, empty middleware list. 88 | /// 89 | /// To create a tangent pipeline you would first call New, followed by several calls to Use on 90 | /// the new builder, ending with a call to Build on the new builder. The return value from Build 91 | /// will be the entry-point to your tangent pipeline. This entry-point may now be added to the 92 | /// main pipeline as an argument to a switching middleware, which will either call the tangent 93 | /// pipeline or the "next app", based on something in the request. 94 | /// 95 | /// That said - all of that work is typically hidden by a middleware like Map, which will do that 96 | /// for you. 97 | /// 98 | /// The new instance of the IAppBuilder implementation 99 | [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "New", Justification = "By design")] 100 | IAppBuilder New(); 101 | } 102 | } -------------------------------------------------------------------------------- /src/main/Owin.Startup/Owin.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {480FD49E-9C69-4FCE-B93A-3E65AFBF82D9} 9 | Library 10 | Properties 11 | Owin 12 | Owin 13 | v4.0 14 | 512 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | true 25 | AllRules.ruleset 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | false 37 | 38 | 39 | Owin.snk 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 62 | -------------------------------------------------------------------------------- /src/main/Owin.Startup/Owin.nuspec_archived: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | 1.0 6 | OWIN 7 | $authors$ 8 | $authors$ 9 | https://github.com/owin-contrib/owin-hosting/blob/master/LICENSE.txt 10 | https://github.com/owin-contrib/owin-hosting/ 11 | false 12 | OWIN IAppBuilder startup interface 13 | OWIN 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/main/Owin.Startup/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Reflection; 20 | using System.Runtime.InteropServices; 21 | 22 | // General Information about an assembly is controlled through the following 23 | // set of attributes. Change these attribute values to modify the information 24 | // associated with an assembly. 25 | [assembly: AssemblyTitle("Owin")] 26 | [assembly: AssemblyDescription("OWIN IAppBuilder startup interface")] 27 | [assembly: AssemblyConfiguration("")] 28 | [assembly: AssemblyCulture("")] 29 | 30 | // Setting ComVisible to false makes the types in this assembly not visible 31 | // to COM components. If you need to access a type in this assembly from 32 | // COM, set the ComVisible attribute to true on that type. 33 | [assembly: ComVisible(false)] 34 | 35 | // The following GUID is for the ID of the typelib if this project is exposed to COM 36 | [assembly: Guid("149c31a5-6619-4d1b-af47-d4d8a27fe99d")] 37 | 38 | [assembly: AssemblyVersion(@"1.0")] 39 | [assembly: AssemblyFileVersion(@"1.0")] 40 | [assembly: CLSCompliant(true)] 41 | -------------------------------------------------------------------------------- /src/main/Owin.Types/Extensions/OwinRequestExtensions.Forwarded..cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Owin.Types.Helpers; 3 | 4 | namespace Owin.Types.Extensions 5 | { 6 | public static partial class OwinRequestExtensions 7 | { 8 | public static string GetForwardedScheme(this OwinRequest request) 9 | { 10 | return OwinHelpers.GetForwardedScheme(request); 11 | } 12 | 13 | public static string GetForwardedHost(this OwinRequest request) 14 | { 15 | return OwinHelpers.GetForwardedHost(request); 16 | } 17 | 18 | public static Uri GetForwardedUri(this OwinRequest request) 19 | { 20 | return OwinHelpers.GetForwardedUri(request); 21 | } 22 | 23 | public static OwinRequest ApplyForwardedScheme(this OwinRequest request) 24 | { 25 | return OwinHelpers.ApplyForwardedScheme(request); 26 | } 27 | 28 | public static OwinRequest ApplyForwardedHost(this OwinRequest request) 29 | { 30 | return OwinHelpers.ApplyForwardedHost(request); 31 | } 32 | 33 | public static OwinRequest ApplyForwardedUri(this OwinRequest request) 34 | { 35 | return OwinHelpers.ApplyForwardedUri(request); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/Owin.Types/Extensions/OwinRequestExtensions.MethodOverride.cs: -------------------------------------------------------------------------------- 1 | using Owin.Types.Helpers; 2 | 3 | namespace Owin.Types.Extensions 4 | { 5 | public static partial class OwinRequestExtensions 6 | { 7 | public static string GetMethodOverride(this OwinRequest request) 8 | { 9 | return OwinHelpers.GetMethodOverride(request); 10 | } 11 | 12 | public static OwinRequest ApplyMethodOverride(this OwinRequest request) 13 | { 14 | return OwinHelpers.ApplyMethodOverride(request); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/Owin.Types/Generated.txt: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/main/Owin.Types/Helpers/OwinHelpers.Forwarded.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Owin.Types.Helpers 5 | { 6 | public static partial class OwinHelpers 7 | { 8 | public static string GetForwardedScheme(OwinRequest request) 9 | { 10 | var headers = request.Headers; 11 | 12 | var forwardedSsl = GetHeader(headers, "X-Forwarded-Ssl"); 13 | if (forwardedSsl != null && string.Equals(forwardedSsl, "on", StringComparison.OrdinalIgnoreCase)) 14 | { 15 | return "https"; 16 | } 17 | 18 | var forwardedScheme = GetHeader(headers, "X-Forwarded-Scheme"); 19 | if (!string.IsNullOrWhiteSpace(forwardedScheme)) 20 | { 21 | return forwardedScheme; 22 | } 23 | 24 | var forwardedProto = GetHeaderSplit(headers, "X-Forwarded-Proto"); 25 | if (forwardedProto != null) 26 | { 27 | forwardedScheme = forwardedProto.FirstOrDefault(); 28 | if (!string.IsNullOrWhiteSpace(forwardedScheme)) 29 | { 30 | return forwardedScheme; 31 | } 32 | } 33 | 34 | return request.Scheme; 35 | } 36 | 37 | public static string GetForwardedHost(OwinRequest request) 38 | { 39 | var headers = request.Headers; 40 | 41 | var forwardedHost = GetHeaderSplit(headers, "X-Forwarded-Host"); 42 | if (forwardedHost != null) 43 | { 44 | return forwardedHost.Last(); 45 | } 46 | 47 | var host = GetHeader(headers, "Host"); 48 | if (!string.IsNullOrWhiteSpace(host)) 49 | { 50 | return host; 51 | } 52 | 53 | var localIpAddress = request.LocalIpAddress ?? "localhost"; 54 | var localPort = request.LocalPort; 55 | return string.IsNullOrWhiteSpace(localPort) ? localIpAddress : (localIpAddress + ":" + localPort); 56 | } 57 | 58 | public static Uri GetForwardedUri(OwinRequest request) 59 | { 60 | var queryString = request.QueryString; 61 | 62 | return string.IsNullOrWhiteSpace(queryString) 63 | ? new Uri(GetForwardedScheme(request) + "://" + GetForwardedHost(request) + request.PathBase + request.Path) 64 | : new Uri(GetForwardedScheme(request) + "://" + GetForwardedHost(request) + request.PathBase + request.Path + "?" + queryString); 65 | } 66 | 67 | public static OwinRequest ApplyForwardedScheme(OwinRequest request) 68 | { 69 | request.Scheme = GetForwardedScheme(request); 70 | return request; 71 | } 72 | 73 | public static OwinRequest ApplyForwardedHost(OwinRequest request) 74 | { 75 | request.Host = GetForwardedHost(request); 76 | return request; 77 | } 78 | 79 | public static OwinRequest ApplyForwardedUri(OwinRequest request) 80 | { 81 | return ApplyForwardedHost(ApplyForwardedScheme(request)); 82 | } 83 | 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/Owin.Types/Helpers/OwinHelpers.Header.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace Owin.Types.Helpers 6 | { 7 | public static partial class OwinHelpers 8 | { 9 | public static string GetHeader(IDictionary headers, string key) 10 | { 11 | string[] values = GetHeaderUnmodified(headers, key); 12 | return values == null ? null : string.Join(",", values); 13 | } 14 | 15 | public static IEnumerable GetHeaderSplit(IDictionary headers, string key) 16 | { 17 | string[] values = GetHeaderUnmodified(headers,key); 18 | return values == null ? null : values.SelectMany(SplitHeader); 19 | } 20 | 21 | public static string[] GetHeaderUnmodified(IDictionary headers, string key) 22 | { 23 | string[] values; 24 | return headers.TryGetValue(key, out values) ? values : null; 25 | } 26 | 27 | private static readonly Func SplitHeader = header => header.Split(new[] { ',' }); 28 | 29 | public static void SetHeader(IDictionary headers, string key, string value) 30 | { 31 | headers[key] = new[] { value }; 32 | } 33 | 34 | public static void SetHeaderJoined(IDictionary headers, string key, params string[] values) 35 | { 36 | headers[key] = new[] { string.Join(",", values) }; 37 | } 38 | 39 | public static void SetHeaderJoined(IDictionary headers, string key, IEnumerable values) 40 | { 41 | SetHeaderJoined(headers, key, values.ToArray()); 42 | } 43 | 44 | public static void SetHeaderUnmodified(IDictionary headers, string key, params string[] values) 45 | { 46 | headers[key] = values; 47 | } 48 | 49 | public static void SetHeaderUnmodified(IDictionary headers, string key, IEnumerable values) 50 | { 51 | headers[key] = values.ToArray(); 52 | } 53 | 54 | public static void AddHeader(IDictionary headers, string key, string value) 55 | { 56 | AddHeaderUnmodified(headers, key, value); 57 | } 58 | 59 | public static void AddHeaderJoined(IDictionary headers, string key, params string[] values) 60 | { 61 | var existing = GetHeaderUnmodified(headers, key); 62 | if (existing == null) 63 | { 64 | SetHeaderJoined(headers, key, values); 65 | } 66 | else 67 | { 68 | SetHeaderJoined(headers, key, existing.Concat(values)); 69 | } 70 | } 71 | 72 | public static void AddHeaderJoined(IDictionary headers, string key, IEnumerable values) 73 | { 74 | var existing = GetHeaderUnmodified(headers, key); 75 | SetHeaderJoined(headers, key, existing == null ? values : existing.Concat(values)); 76 | } 77 | 78 | public static void AddHeaderUnmodified(IDictionary headers, string key, params string[] values) 79 | { 80 | var existing = GetHeaderUnmodified(headers, key); 81 | if (existing == null) 82 | { 83 | SetHeaderUnmodified(headers, key, values); 84 | } 85 | else 86 | { 87 | SetHeaderUnmodified(headers, key, existing.Concat(values)); 88 | } 89 | } 90 | 91 | public static void AddHeaderUnmodified(IDictionary headers, string key, IEnumerable values) 92 | { 93 | var existing = GetHeaderUnmodified(headers, key); 94 | SetHeaderUnmodified(headers, key, existing == null ? values : existing.Concat(values)); 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/Owin.Types/Helpers/OwinHelpers.MethodOverride.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Owin.Types.Helpers 5 | { 6 | public static partial class OwinHelpers 7 | { 8 | public static string GetMethodOverride(OwinRequest request) 9 | { 10 | var method = request.Method; 11 | if (!string.Equals("POST", method, StringComparison.OrdinalIgnoreCase)) 12 | { 13 | // override has no effect on POST 14 | return method; 15 | } 16 | 17 | var methodOverride = GetHeader(request.Headers, "X-Http-Method-Override"); 18 | if (string.IsNullOrEmpty(methodOverride)) 19 | { 20 | return method; 21 | } 22 | 23 | return methodOverride; 24 | } 25 | 26 | public static OwinRequest ApplyMethodOverride(OwinRequest request) 27 | { 28 | request.Method = GetMethodOverride(request); 29 | return request; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/Owin.Types/Helpers/OwinHelpers.Uri.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Owin.Types.Helpers 4 | { 5 | public static partial class OwinHelpers 6 | { 7 | public static string GetHost(OwinRequest request) 8 | { 9 | var headers = request.Headers; 10 | 11 | var host = GetHeader(headers, "Host"); 12 | if (!string.IsNullOrWhiteSpace(host)) 13 | { 14 | return host; 15 | } 16 | 17 | var localIpAddress = request.LocalIpAddress ?? "localhost"; 18 | var localPort = request.LocalPort; 19 | return string.IsNullOrWhiteSpace(localPort) ? localIpAddress : (localIpAddress + ":" + localPort); 20 | } 21 | 22 | public static Uri GetUri(OwinRequest request) 23 | { 24 | var queryString = request.QueryString; 25 | 26 | return string.IsNullOrWhiteSpace(queryString) 27 | ? new Uri(request.Scheme + "://" + GetHost(request) + request.PathBase + request.Path) 28 | : new Uri(request.Scheme + "://" + GetHost(request) + request.PathBase + request.Path + "?" + queryString); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/Owin.Types/Owin.Types.Sources.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | $authors$ 7 | $authors$ 8 | https://github.com/owin-contrib/owin-hosting/blob/master/LICENSE.txt 9 | https://github.com/owin-contrib/owin-hosting/ 10 | false 11 | OWIN types 12 | OWIN 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/Owin.Types/Owin.Types.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {06B11480-240F-4EFB-AA6C-8EB354ADCF83} 8 | Library 9 | Properties 10 | Owin.Types 11 | Owin.Types 12 | v4.0 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | AllRules.ruleset 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | TextTemplatingFileGenerator 73 | Generated.txt 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | True 84 | True 85 | Generated.tt 86 | 87 | 88 | 89 | 90 | 91 | 98 | -------------------------------------------------------------------------------- /src/main/Owin.Types/Owin.Types.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | $authors$ 7 | $authors$ 8 | https://github.com/owin-contrib/owin-hosting/blob/master/LICENSE.txt 9 | https://github.com/owin-contrib/owin-hosting/ 10 | false 11 | OWIN types 12 | OWIN 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/Owin.Types/OwinOpaque.Generated.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System.Collections.Generic; 19 | 20 | namespace Owin.Types 21 | { 22 | public partial struct OwinOpaque 23 | { 24 | private readonly IDictionary _dictionary; 25 | 26 | public OwinOpaque(IDictionary dictionary) 27 | { 28 | _dictionary = dictionary; 29 | } 30 | 31 | public IDictionary Dictionary 32 | { 33 | get { return _dictionary; } 34 | } 35 | 36 | #region Value-type equality 37 | public bool Equals(OwinOpaque other) 38 | { 39 | return Equals(_dictionary, other._dictionary); 40 | } 41 | 42 | public override bool Equals(object obj) 43 | { 44 | return obj is OwinOpaque && Equals((OwinOpaque)obj); 45 | } 46 | 47 | public override int GetHashCode() 48 | { 49 | return (_dictionary != null ? _dictionary.GetHashCode() : 0); 50 | } 51 | 52 | public static bool operator ==(OwinOpaque left, OwinOpaque right) 53 | { 54 | return left.Equals(right); 55 | } 56 | 57 | public static bool operator !=(OwinOpaque left, OwinOpaque right) 58 | { 59 | return !left.Equals(right); 60 | } 61 | #endregion 62 | 63 | public T Get(string key) 64 | { 65 | object value; 66 | return _dictionary.TryGetValue(key, out value) ? (T)value : default(T); 67 | } 68 | 69 | public OwinOpaque Set(string key, object value) 70 | { 71 | _dictionary[key] = value; 72 | return this; 73 | } 74 | 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/Owin.Types/OwinOpaque.Spec-Opaque.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System.IO; 19 | using System.Threading; 20 | 21 | namespace Owin.Types 22 | { 23 | public partial struct OwinOpaque 24 | { 25 | public string Version 26 | { 27 | get { return Get(OwinConstants.Opaque.Version); } 28 | set { Set(OwinConstants.Opaque.Version, value); } 29 | } 30 | 31 | public CancellationToken CallCancelled 32 | { 33 | get { return Get(OwinConstants.Opaque.CallCancelled); } 34 | set { Set(OwinConstants.Opaque.CallCancelled, value); } 35 | } 36 | 37 | public Stream Stream 38 | { 39 | get { return Get(OwinConstants.Opaque.Stream); } 40 | set { Set(OwinConstants.Opaque.Stream, value); } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/Owin.Types/OwinOpaqueParameters.Generated.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System.Collections.Generic; 19 | 20 | namespace Owin.Types 21 | { 22 | public partial struct OwinOpaqueParameters 23 | { 24 | private readonly IDictionary _dictionary; 25 | 26 | public OwinOpaqueParameters(IDictionary dictionary) 27 | { 28 | _dictionary = dictionary; 29 | } 30 | 31 | public IDictionary Dictionary 32 | { 33 | get { return _dictionary; } 34 | } 35 | 36 | #region Value-type equality 37 | public bool Equals(OwinOpaqueParameters other) 38 | { 39 | return Equals(_dictionary, other._dictionary); 40 | } 41 | 42 | public override bool Equals(object obj) 43 | { 44 | return obj is OwinOpaqueParameters && Equals((OwinOpaqueParameters)obj); 45 | } 46 | 47 | public override int GetHashCode() 48 | { 49 | return (_dictionary != null ? _dictionary.GetHashCode() : 0); 50 | } 51 | 52 | public static bool operator ==(OwinOpaqueParameters left, OwinOpaqueParameters right) 53 | { 54 | return left.Equals(right); 55 | } 56 | 57 | public static bool operator !=(OwinOpaqueParameters left, OwinOpaqueParameters right) 58 | { 59 | return !left.Equals(right); 60 | } 61 | #endregion 62 | 63 | public T Get(string key) 64 | { 65 | object value; 66 | return _dictionary.TryGetValue(key, out value) ? (T)value : default(T); 67 | } 68 | 69 | public OwinOpaqueParameters Set(string key, object value) 70 | { 71 | _dictionary[key] = value; 72 | return this; 73 | } 74 | 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/Owin.Types/OwinOpaqueParameters.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Collections.Concurrent; 20 | 21 | namespace Owin.Types 22 | { 23 | public partial struct OwinOpaqueParameters 24 | { 25 | public static OwinOpaqueParameters Create() 26 | { 27 | return new OwinOpaqueParameters(new ConcurrentDictionary(StringComparer.Ordinal)); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/Owin.Types/OwinRequest.Generated.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Linq; 20 | using System.Collections.Generic; 21 | 22 | namespace Owin.Types 23 | { 24 | public partial struct OwinRequest 25 | { 26 | private readonly IDictionary _dictionary; 27 | 28 | public OwinRequest(IDictionary dictionary) 29 | { 30 | _dictionary = dictionary; 31 | } 32 | 33 | public IDictionary Dictionary 34 | { 35 | get { return _dictionary; } 36 | } 37 | 38 | #region Value-type equality 39 | public bool Equals(OwinRequest other) 40 | { 41 | return Equals(_dictionary, other._dictionary); 42 | } 43 | 44 | public override bool Equals(object obj) 45 | { 46 | return obj is OwinRequest && Equals((OwinRequest)obj); 47 | } 48 | 49 | public override int GetHashCode() 50 | { 51 | return (_dictionary != null ? _dictionary.GetHashCode() : 0); 52 | } 53 | 54 | public static bool operator ==(OwinRequest left, OwinRequest right) 55 | { 56 | return left.Equals(right); 57 | } 58 | 59 | public static bool operator !=(OwinRequest left, OwinRequest right) 60 | { 61 | return !left.Equals(right); 62 | } 63 | #endregion 64 | 65 | public T Get(string key) 66 | { 67 | object value; 68 | return _dictionary.TryGetValue(key, out value) ? (T)value : default(T); 69 | } 70 | 71 | public OwinRequest Set(string key, object value) 72 | { 73 | _dictionary[key] = value; 74 | return this; 75 | } 76 | 77 | 78 | public string GetHeader(string key) 79 | { 80 | return Helpers.OwinHelpers.GetHeader(Headers, key); 81 | } 82 | 83 | public IEnumerable GetHeaderSplit(string key) 84 | { 85 | return Helpers.OwinHelpers.GetHeaderSplit(Headers, key); 86 | } 87 | 88 | public string[] GetHeaderUnmodified(string key) 89 | { 90 | return Helpers.OwinHelpers.GetHeaderUnmodified(Headers, key); 91 | } 92 | 93 | public OwinRequest SetHeader(string key, string value) 94 | { 95 | Helpers.OwinHelpers.SetHeader(Headers, key, value); 96 | return this; 97 | } 98 | 99 | public OwinRequest SetHeaderJoined(string key, params string[] values) 100 | { 101 | Helpers.OwinHelpers.SetHeaderJoined(Headers, key, values); 102 | return this; 103 | } 104 | 105 | public OwinRequest SetHeaderJoined(string key, IEnumerable values) 106 | { 107 | Helpers.OwinHelpers.SetHeaderJoined(Headers, key, values); 108 | return this; 109 | } 110 | 111 | public OwinRequest SetHeaderUnmodified(string key, params string[] values) 112 | { 113 | Helpers.OwinHelpers.SetHeaderUnmodified(Headers, key, values); 114 | return this; 115 | } 116 | 117 | public OwinRequest SetHeaderUnmodified(string key, IEnumerable values) 118 | { 119 | Helpers.OwinHelpers.SetHeaderUnmodified(Headers, key, values); 120 | return this; 121 | } 122 | 123 | public OwinRequest AddHeader(string key, string value) 124 | { 125 | Helpers.OwinHelpers.AddHeader(Headers, key, value); 126 | return this; 127 | } 128 | 129 | public OwinRequest AddHeaderJoined(string key, params string[] values) 130 | { 131 | Helpers.OwinHelpers.AddHeaderJoined(Headers, key, values); 132 | return this; 133 | } 134 | 135 | public OwinRequest AddHeaderJoined(string key, IEnumerable values) 136 | { 137 | Helpers.OwinHelpers.AddHeaderJoined(Headers, key, values); 138 | return this; 139 | } 140 | 141 | public OwinRequest AddHeaderUnmodified(string key, params string[] values) 142 | { 143 | Helpers.OwinHelpers.AddHeaderUnmodified(Headers, key, values); 144 | return this; 145 | } 146 | 147 | public OwinRequest AddHeaderUnmodified(string key, IEnumerable values) 148 | { 149 | Helpers.OwinHelpers.AddHeaderUnmodified(Headers, key, values); 150 | return this; 151 | } 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /src/main/Owin.Types/OwinRequest.Spec-CommonKeys.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.IO; 20 | 21 | namespace Owin.Types 22 | { 23 | public partial struct OwinRequest 24 | { 25 | public string RemoteIpAddress 26 | { 27 | get { return Get(OwinConstants.CommonKeys.RemoteIpAddress); } 28 | set { Set(OwinConstants.CommonKeys.RemoteIpAddress, value); } 29 | } 30 | 31 | public string RemotePort 32 | { 33 | get { return Get(OwinConstants.CommonKeys.RemotePort); } 34 | set { Set(OwinConstants.CommonKeys.RemotePort, value); } 35 | } 36 | 37 | public string LocalIpAddress 38 | { 39 | get { return Get(OwinConstants.CommonKeys.LocalIpAddress); } 40 | set { Set(OwinConstants.CommonKeys.LocalIpAddress, value); } 41 | } 42 | 43 | public string LocalPort 44 | { 45 | get { return Get(OwinConstants.CommonKeys.LocalPort); } 46 | set { Set(OwinConstants.CommonKeys.LocalPort, value); } 47 | } 48 | 49 | public bool IsLocal 50 | { 51 | get { return Get(OwinConstants.CommonKeys.IsLocal); } 52 | set { Set(OwinConstants.CommonKeys.IsLocal, value); } 53 | } 54 | 55 | public TextWriter TraceOutput 56 | { 57 | get { return Get(OwinConstants.CommonKeys.TraceOutput); } 58 | set { Set(OwinConstants.CommonKeys.TraceOutput, value); } 59 | } 60 | 61 | public Action, object> OnSendingHeaders 62 | { 63 | get { return Get, object>>(OwinConstants.CommonKeys.OnSendingHeaders); } 64 | set { Set(OwinConstants.CommonKeys.OnSendingHeaders, value); } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/Owin.Types/OwinRequest.Spec-Opaque.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Threading.Tasks; 20 | using UpgradeDelegate = System.Action, System.Func, System.Threading.Tasks.Task>>; 21 | 22 | namespace Owin.Types 23 | { 24 | public partial struct OwinRequest 25 | { 26 | public bool CanUpgrade 27 | { 28 | get { return UpgradeDelegate != null; } 29 | } 30 | 31 | public UpgradeDelegate UpgradeDelegate 32 | { 33 | get { return Get(OwinConstants.Opaque.Upgrade); } 34 | } 35 | 36 | public void Upgrade( 37 | OwinOpaqueParameters parameters, 38 | Func callback) 39 | { 40 | var upgrade = UpgradeDelegate; 41 | if (upgrade == null) 42 | { 43 | throw new NotSupportedException(OwinConstants.Opaque.Upgrade); 44 | } 45 | UpgradeDelegate.Invoke(parameters.Dictionary, opaque => callback(new OwinOpaque(opaque))); 46 | } 47 | 48 | public void Upgrade( 49 | Func callback) 50 | { 51 | Upgrade(OwinOpaqueParameters.Create(), callback); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/Owin.Types/OwinRequest.Spec-Owin.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System.Collections.Generic; 19 | using System.IO; 20 | using System.Threading; 21 | 22 | namespace Owin.Types 23 | { 24 | public partial struct OwinRequest 25 | { 26 | public string OwinVersion 27 | { 28 | get { return Get(OwinConstants.OwinVersion); } 29 | set { Set(OwinConstants.OwinVersion, value); } 30 | } 31 | 32 | public CancellationToken CallCancelled 33 | { 34 | get { return Get(OwinConstants.CallCancelled); } 35 | set { Set(OwinConstants.CallCancelled, value); } 36 | } 37 | 38 | public string Scheme 39 | { 40 | get { return Get(OwinConstants.RequestScheme); } 41 | set { Set(OwinConstants.RequestScheme, value); } 42 | } 43 | 44 | public string Method 45 | { 46 | get { return Get(OwinConstants.RequestMethod); } 47 | set { Set(OwinConstants.RequestMethod, value); } 48 | } 49 | 50 | public string PathBase 51 | { 52 | get { return Get(OwinConstants.RequestPathBase); } 53 | set { Set(OwinConstants.RequestPathBase, value); } 54 | } 55 | 56 | public string Path 57 | { 58 | get { return Get(OwinConstants.RequestPath); } 59 | set { Set(OwinConstants.RequestPath, value); } 60 | } 61 | 62 | public string QueryString 63 | { 64 | get { return Get(OwinConstants.RequestQueryString); } 65 | set { Set(OwinConstants.RequestQueryString, value); } 66 | } 67 | 68 | public string Protocol 69 | { 70 | get { return Get(OwinConstants.RequestProtocol); } 71 | set { Set(OwinConstants.RequestProtocol, value); } 72 | } 73 | 74 | public IDictionary Headers 75 | { 76 | get { return Get>(OwinConstants.RequestHeaders); } 77 | set { Set(OwinConstants.RequestHeaders, value); } 78 | } 79 | 80 | public Stream Body 81 | { 82 | get { return Get(OwinConstants.RequestBody); } 83 | set { Set(OwinConstants.RequestBody, value); } 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/Owin.Types/OwinRequest.Spec-WebSocket.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Threading.Tasks; 20 | using AcceptDelegate = System.Action, System.Func, System.Threading.Tasks.Task>>; 21 | 22 | namespace Owin.Types 23 | { 24 | public partial struct OwinRequest 25 | { 26 | public bool CanAccept 27 | { 28 | get { return AcceptDelegate != null; } 29 | } 30 | 31 | public AcceptDelegate AcceptDelegate 32 | { 33 | get { return Get(OwinConstants.WebSocket.Accept); } 34 | } 35 | 36 | public void Accept( 37 | OwinWebSocketParameters parameters, 38 | Func callback) 39 | { 40 | var accept = AcceptDelegate; 41 | if (accept == null) 42 | { 43 | throw new NotSupportedException(OwinConstants.WebSocket.Accept); 44 | } 45 | accept.Invoke( 46 | parameters.Dictionary, 47 | webSocket => callback(new OwinWebSocket(webSocket))); 48 | } 49 | 50 | public void Accept( 51 | string subProtocol, 52 | Func callback) 53 | { 54 | Accept(OwinWebSocketParameters.Create(subProtocol), callback); 55 | } 56 | 57 | public void Accept( 58 | Func callback) 59 | { 60 | Accept(OwinWebSocketParameters.Create(), callback); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/Owin.Types/OwinRequest.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Collections.Concurrent; 20 | using Owin.Types.Helpers; 21 | 22 | namespace Owin.Types 23 | { 24 | public partial struct OwinRequest 25 | { 26 | public static OwinRequest Create() 27 | { 28 | var environment = new ConcurrentDictionary(StringComparer.Ordinal); 29 | environment[OwinConstants.RequestHeaders] = 30 | new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); 31 | environment[OwinConstants.ResponseHeaders] = 32 | new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); 33 | return new OwinRequest(environment); 34 | } 35 | 36 | public string Host 37 | { 38 | get { return OwinHelpers.GetHost(this); } 39 | set { SetHeader("Host", value); } 40 | } 41 | 42 | public Uri Uri 43 | { 44 | get { return OwinHelpers.GetUri(this); } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/Owin.Types/OwinResponse.Generated.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Linq; 20 | using System.Collections.Generic; 21 | 22 | namespace Owin.Types 23 | { 24 | public partial struct OwinResponse 25 | { 26 | private readonly IDictionary _dictionary; 27 | 28 | public OwinResponse(IDictionary dictionary) 29 | { 30 | _dictionary = dictionary; 31 | } 32 | 33 | public IDictionary Dictionary 34 | { 35 | get { return _dictionary; } 36 | } 37 | 38 | #region Value-type equality 39 | public bool Equals(OwinResponse other) 40 | { 41 | return Equals(_dictionary, other._dictionary); 42 | } 43 | 44 | public override bool Equals(object obj) 45 | { 46 | return obj is OwinResponse && Equals((OwinResponse)obj); 47 | } 48 | 49 | public override int GetHashCode() 50 | { 51 | return (_dictionary != null ? _dictionary.GetHashCode() : 0); 52 | } 53 | 54 | public static bool operator ==(OwinResponse left, OwinResponse right) 55 | { 56 | return left.Equals(right); 57 | } 58 | 59 | public static bool operator !=(OwinResponse left, OwinResponse right) 60 | { 61 | return !left.Equals(right); 62 | } 63 | #endregion 64 | 65 | public T Get(string key) 66 | { 67 | object value; 68 | return _dictionary.TryGetValue(key, out value) ? (T)value : default(T); 69 | } 70 | 71 | public OwinResponse Set(string key, object value) 72 | { 73 | _dictionary[key] = value; 74 | return this; 75 | } 76 | 77 | 78 | public string GetHeader(string key) 79 | { 80 | return Helpers.OwinHelpers.GetHeader(Headers, key); 81 | } 82 | 83 | public IEnumerable GetHeaderSplit(string key) 84 | { 85 | return Helpers.OwinHelpers.GetHeaderSplit(Headers, key); 86 | } 87 | 88 | public string[] GetHeaderUnmodified(string key) 89 | { 90 | return Helpers.OwinHelpers.GetHeaderUnmodified(Headers, key); 91 | } 92 | 93 | public OwinResponse SetHeader(string key, string value) 94 | { 95 | Helpers.OwinHelpers.SetHeader(Headers, key, value); 96 | return this; 97 | } 98 | 99 | public OwinResponse SetHeaderJoined(string key, params string[] values) 100 | { 101 | Helpers.OwinHelpers.SetHeaderJoined(Headers, key, values); 102 | return this; 103 | } 104 | 105 | public OwinResponse SetHeaderJoined(string key, IEnumerable values) 106 | { 107 | Helpers.OwinHelpers.SetHeaderJoined(Headers, key, values); 108 | return this; 109 | } 110 | 111 | public OwinResponse SetHeaderUnmodified(string key, params string[] values) 112 | { 113 | Helpers.OwinHelpers.SetHeaderUnmodified(Headers, key, values); 114 | return this; 115 | } 116 | 117 | public OwinResponse SetHeaderUnmodified(string key, IEnumerable values) 118 | { 119 | Helpers.OwinHelpers.SetHeaderUnmodified(Headers, key, values); 120 | return this; 121 | } 122 | 123 | public OwinResponse AddHeader(string key, string value) 124 | { 125 | Helpers.OwinHelpers.AddHeader(Headers, key, value); 126 | return this; 127 | } 128 | 129 | public OwinResponse AddHeaderJoined(string key, params string[] values) 130 | { 131 | Helpers.OwinHelpers.AddHeaderJoined(Headers, key, values); 132 | return this; 133 | } 134 | 135 | public OwinResponse AddHeaderJoined(string key, IEnumerable values) 136 | { 137 | Helpers.OwinHelpers.AddHeaderJoined(Headers, key, values); 138 | return this; 139 | } 140 | 141 | public OwinResponse AddHeaderUnmodified(string key, params string[] values) 142 | { 143 | Helpers.OwinHelpers.AddHeaderUnmodified(Headers, key, values); 144 | return this; 145 | } 146 | 147 | public OwinResponse AddHeaderUnmodified(string key, IEnumerable values) 148 | { 149 | Helpers.OwinHelpers.AddHeaderUnmodified(Headers, key, values); 150 | return this; 151 | } 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /src/main/Owin.Types/OwinResponse.Spec-Owin.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System.Collections.Generic; 19 | using System.IO; 20 | using System.Threading; 21 | 22 | namespace Owin.Types 23 | { 24 | public partial struct OwinResponse 25 | { 26 | public string OwinVersion 27 | { 28 | get { return Get(OwinConstants.OwinVersion); } 29 | set { Set(OwinConstants.OwinVersion, value); } 30 | } 31 | 32 | public CancellationToken CallCancelled 33 | { 34 | get { return Get(OwinConstants.CallCancelled); } 35 | set { Set(OwinConstants.CallCancelled, value); } 36 | } 37 | 38 | public int StatusCode 39 | { 40 | get { return Get(OwinConstants.ResponseStatusCode); } 41 | set { Set(OwinConstants.ResponseStatusCode, value); } 42 | } 43 | 44 | public string ReasonPhrase 45 | { 46 | get { return Get(OwinConstants.ResponseReasonPhrase); } 47 | set { Set(OwinConstants.ResponseReasonPhrase, value); } 48 | } 49 | 50 | public string Protocol 51 | { 52 | get { return Get(OwinConstants.ResponseProtocol); } 53 | set { Set(OwinConstants.ResponseProtocol, value); } 54 | } 55 | 56 | public IDictionary Headers 57 | { 58 | get { return Get>(OwinConstants.ResponseHeaders); } 59 | set { Set(OwinConstants.ResponseHeaders, value); } 60 | } 61 | 62 | public Stream Body 63 | { 64 | get { return Get(OwinConstants.ResponseBody); } 65 | set { Set(OwinConstants.ResponseBody, value); } 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/Owin.Types/OwinResponse.Spec-SendFile.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Threading; 20 | using System.Threading.Tasks; 21 | using SendFileAsyncDelegate = System.Func; 22 | 23 | namespace Owin.Types 24 | { 25 | public partial struct OwinResponse 26 | { 27 | public bool CanSendFile 28 | { 29 | get { return SendFileAsyncDelegate != null; } 30 | } 31 | 32 | public SendFileAsyncDelegate SendFileAsyncDelegate 33 | { 34 | get { return Get(OwinConstants.SendFiles.SendAsync); } 35 | set { Set(OwinConstants.SendFiles.SendAsync, value); } 36 | } 37 | 38 | public Task SendFileAsync(string filePath, long offset, long? count, CancellationToken cancel) 39 | { 40 | var sendFile = SendFileAsyncDelegate; 41 | if (sendFile == null) 42 | { 43 | throw new NotSupportedException(OwinConstants.SendFiles.SendAsync); 44 | } 45 | return sendFile.Invoke(filePath, offset, count, cancel); 46 | } 47 | 48 | public Task SendFileAsync(string filePath, long offset, long? count) 49 | { 50 | return SendFileAsync(filePath, offset, count, CancellationToken.None); 51 | } 52 | 53 | public Task SendFileAsync(string filePath, CancellationToken cancel) 54 | { 55 | return SendFileAsync(filePath, 0, null, cancel); 56 | } 57 | 58 | public Task SendFileAsync(string filePath) 59 | { 60 | return SendFileAsync(filePath, 0, null, CancellationToken.None); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/Owin.Types/OwinResponse.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | namespace Owin.Types 18 | { 19 | public partial struct OwinResponse 20 | { 21 | public OwinResponse(OwinRequest request) 22 | { 23 | _dictionary = request.Dictionary; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/Owin.Types/OwinWebSocket.Generated.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System.Collections.Generic; 19 | 20 | namespace Owin.Types 21 | { 22 | public partial struct OwinWebSocket 23 | { 24 | private readonly IDictionary _dictionary; 25 | 26 | public OwinWebSocket(IDictionary dictionary) 27 | { 28 | _dictionary = dictionary; 29 | } 30 | 31 | public IDictionary Dictionary 32 | { 33 | get { return _dictionary; } 34 | } 35 | 36 | #region Value-type equality 37 | public bool Equals(OwinWebSocket other) 38 | { 39 | return Equals(_dictionary, other._dictionary); 40 | } 41 | 42 | public override bool Equals(object obj) 43 | { 44 | return obj is OwinWebSocket && Equals((OwinWebSocket)obj); 45 | } 46 | 47 | public override int GetHashCode() 48 | { 49 | return (_dictionary != null ? _dictionary.GetHashCode() : 0); 50 | } 51 | 52 | public static bool operator ==(OwinWebSocket left, OwinWebSocket right) 53 | { 54 | return left.Equals(right); 55 | } 56 | 57 | public static bool operator !=(OwinWebSocket left, OwinWebSocket right) 58 | { 59 | return !left.Equals(right); 60 | } 61 | #endregion 62 | 63 | public T Get(string key) 64 | { 65 | object value; 66 | return _dictionary.TryGetValue(key, out value) ? (T)value : default(T); 67 | } 68 | 69 | public OwinWebSocket Set(string key, object value) 70 | { 71 | _dictionary[key] = value; 72 | return this; 73 | } 74 | 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/Owin.Types/OwinWebSocket.Spec-WebSocket.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System.Threading; 19 | using SendAsyncDelegate = System.Func, int, bool, System.Threading.CancellationToken, System.Threading.Tasks.Task>; 20 | using ReceiveAsyncDelegate = System.Func, System.Threading.CancellationToken, System.Threading.Tasks.Task>>; 21 | using CloseAsyncDelegate = System.Func; 22 | 23 | namespace Owin.Types 24 | { 25 | public partial struct OwinWebSocket 26 | { 27 | public SendAsyncDelegate SendAsyncDelegate 28 | { 29 | get { return Get(OwinConstants.WebSocket.SendAsync); } 30 | set { Set(OwinConstants.WebSocket.SendAsync, value); } 31 | } 32 | 33 | public ReceiveAsyncDelegate ReceiveAsyncDelegate 34 | { 35 | get { return Get(OwinConstants.WebSocket.ReceiveAsync); } 36 | set { Set(OwinConstants.WebSocket.ReceiveAsync, value); } 37 | } 38 | 39 | public CloseAsyncDelegate CloseAsyncDelegate 40 | { 41 | get { return Get(OwinConstants.WebSocket.CloseAsync); } 42 | set { Set(OwinConstants.WebSocket.CloseAsync, value); } 43 | } 44 | 45 | public string Version 46 | { 47 | get { return Get(OwinConstants.WebSocket.Version); } 48 | set { Set(OwinConstants.WebSocket.Version, value); } 49 | } 50 | 51 | public CancellationToken CallCancelled 52 | { 53 | get { return Get(OwinConstants.WebSocket.CallCancelled); } 54 | set { Set(OwinConstants.WebSocket.CallCancelled, value); } 55 | } 56 | 57 | public int ClientCloseStatus 58 | { 59 | get { return Get(OwinConstants.WebSocket.ClientCloseStatus); } 60 | set { Set(OwinConstants.WebSocket.ClientCloseStatus, value); } 61 | } 62 | 63 | public string ClientCloseDescription 64 | { 65 | get { return Get(OwinConstants.WebSocket.ClientCloseDescription); } 66 | set { Set(OwinConstants.WebSocket.ClientCloseDescription, value); } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/Owin.Types/OwinWebSocket.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Threading; 20 | using System.Threading.Tasks; 21 | 22 | namespace Owin.Types 23 | { 24 | public partial struct OwinWebSocket 25 | { 26 | public Task SendAsync(ArraySegment data, int messageType, bool endOfMessage, CancellationToken cancel) 27 | { 28 | return SendAsyncDelegate.Invoke(data, messageType, endOfMessage, cancel); 29 | } 30 | 31 | public Task ReceiveAsync(ArraySegment buffer, CancellationToken cancel) 32 | { 33 | //TODO: avoid ContinueWith when completed synchronously 34 | return ReceiveAsyncDelegate.Invoke(buffer, cancel) 35 | .ContinueWith(tuple => new OwinWebSocketReceiveMessage(tuple.Result)); 36 | } 37 | 38 | public Task CloseAsync(int closeStatus, string closeDescription, CancellationToken cancel) 39 | { 40 | return CloseAsyncDelegate.Invoke(closeStatus, closeDescription, cancel); 41 | } 42 | 43 | public Task CloseAsync(int closeStatus, CancellationToken cancel) 44 | { 45 | return CloseAsyncDelegate.Invoke(closeStatus, null, cancel); 46 | } 47 | 48 | public Task CloseAsync(CancellationToken cancel) 49 | { 50 | return CloseAsyncDelegate.Invoke(0, null, cancel); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/Owin.Types/OwinWebSocketParameters.Generated.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System.Collections.Generic; 19 | 20 | namespace Owin.Types 21 | { 22 | public partial struct OwinWebSocketParameters 23 | { 24 | private readonly IDictionary _dictionary; 25 | 26 | public OwinWebSocketParameters(IDictionary dictionary) 27 | { 28 | _dictionary = dictionary; 29 | } 30 | 31 | public IDictionary Dictionary 32 | { 33 | get { return _dictionary; } 34 | } 35 | 36 | #region Value-type equality 37 | public bool Equals(OwinWebSocketParameters other) 38 | { 39 | return Equals(_dictionary, other._dictionary); 40 | } 41 | 42 | public override bool Equals(object obj) 43 | { 44 | return obj is OwinWebSocketParameters && Equals((OwinWebSocketParameters)obj); 45 | } 46 | 47 | public override int GetHashCode() 48 | { 49 | return (_dictionary != null ? _dictionary.GetHashCode() : 0); 50 | } 51 | 52 | public static bool operator ==(OwinWebSocketParameters left, OwinWebSocketParameters right) 53 | { 54 | return left.Equals(right); 55 | } 56 | 57 | public static bool operator !=(OwinWebSocketParameters left, OwinWebSocketParameters right) 58 | { 59 | return !left.Equals(right); 60 | } 61 | #endregion 62 | 63 | public T Get(string key) 64 | { 65 | object value; 66 | return _dictionary.TryGetValue(key, out value) ? (T)value : default(T); 67 | } 68 | 69 | public OwinWebSocketParameters Set(string key, object value) 70 | { 71 | _dictionary[key] = value; 72 | return this; 73 | } 74 | 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/Owin.Types/OwinWebSocketParameters.Spec-WebSocket.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | namespace Owin.Types 18 | { 19 | public partial struct OwinWebSocketParameters 20 | { 21 | public string SubProtocol 22 | { 23 | get { return Get(OwinConstants.WebSocket.SubProtocol); } 24 | set { Set(OwinConstants.WebSocket.SubProtocol, value); } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/Owin.Types/OwinWebSocketParameters.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Collections.Concurrent; 20 | 21 | namespace Owin.Types 22 | { 23 | public partial struct OwinWebSocketParameters 24 | { 25 | public static OwinWebSocketParameters Create() 26 | { 27 | return new OwinWebSocketParameters(new ConcurrentDictionary(StringComparer.Ordinal)); 28 | } 29 | 30 | public static OwinWebSocketParameters Create(string subProtocol) 31 | { 32 | return new OwinWebSocketParameters(new ConcurrentDictionary(StringComparer.Ordinal)) 33 | { 34 | SubProtocol = subProtocol 35 | }; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/Owin.Types/OwinWebSocketReceiveMessage.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | 20 | namespace Owin.Types 21 | { 22 | public partial struct OwinWebSocketReceiveMessage 23 | { 24 | private readonly Tuple _tuple; 25 | 26 | public OwinWebSocketReceiveMessage(Tuple tuple) 27 | { 28 | _tuple = tuple; 29 | } 30 | 31 | public int MessageType { get { return _tuple.Item1; } } 32 | public bool EndOfMessage { get { return _tuple.Item2; } } 33 | public int Count { get { return _tuple.Item3; } } 34 | 35 | #region Value-type equality 36 | public bool Equals(OwinWebSocketReceiveMessage other) 37 | { 38 | return Equals(_tuple, other._tuple); 39 | } 40 | 41 | public override bool Equals(object obj) 42 | { 43 | return obj is OwinWebSocketReceiveMessage && Equals((OwinWebSocketReceiveMessage)obj); 44 | } 45 | 46 | public override int GetHashCode() 47 | { 48 | return (_tuple != null ? _tuple.GetHashCode() : 0); 49 | } 50 | 51 | public static bool operator ==(OwinWebSocketReceiveMessage left, OwinWebSocketReceiveMessage right) 52 | { 53 | return left.Equals(right); 54 | } 55 | 56 | public static bool operator !=(OwinWebSocketReceiveMessage left, OwinWebSocketReceiveMessage right) 57 | { 58 | return !left.Equals(right); 59 | } 60 | #endregion 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/Owin.Types/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Reflection; 20 | using System.Runtime.InteropServices; 21 | 22 | // General Information about an assembly is controlled through the following 23 | // set of attributes. Change these attribute values to modify the information 24 | // associated with an assembly. 25 | [assembly: AssemblyTitle("Owin.Types")] 26 | [assembly: AssemblyDescription("")] 27 | [assembly: AssemblyConfiguration("")] 28 | [assembly: AssemblyCulture("")] 29 | 30 | // Setting ComVisible to false makes the types in this assembly not visible 31 | // to COM components. If you need to access a type in this assembly from 32 | // COM, set the ComVisible attribute to true on that type. 33 | [assembly: ComVisible(false)] 34 | 35 | // The following GUID is for the ID of the typelib if this project is exposed to COM 36 | [assembly: Guid("dd53aa0b-5d4b-4efd-9d44-094ed213c992")] 37 | 38 | [assembly: AssemblyVersion("0.7")] 39 | [assembly: AssemblyFileVersion("0.7")] 40 | [assembly: AssemblyInformationalVersion("0.7-alpha")] 41 | [assembly: CLSCompliant(true)] 42 | -------------------------------------------------------------------------------- /src/test/MiddlewareConvention1/Alpha.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Collections.Generic; 20 | using System.IO; 21 | using System.Threading.Tasks; 22 | using MiddlewareConvention1; 23 | using Utils; 24 | 25 | namespace Owin 26 | { 27 | public static partial class Extensions 28 | { 29 | public static IAppBuilder UseAlpha(this IAppBuilder builder, string arg1, string arg2) 30 | { 31 | return builder.UseFunc(Alpha.Invoke, arg1, arg2); 32 | } 33 | } 34 | } 35 | 36 | namespace MiddlewareConvention1 37 | { 38 | using AppFunc = Func, Task>; 39 | 40 | public class Alpha 41 | { 42 | public static AppFunc Invoke(AppFunc app, string arg1, string arg2) 43 | { 44 | return env => 45 | { 46 | var helper = new OwinHelper(env); 47 | if (helper.RequestPath.StartsWith(arg1, StringComparison.OrdinalIgnoreCase)) 48 | { 49 | helper.ResponseHeaders["Content-Type"] = new[] { "text/plain" }; 50 | using (var writer = new StreamWriter(helper.OutputStream)) 51 | { 52 | writer.Write(arg2); 53 | } 54 | return TaskHelpers.Completed(); 55 | } 56 | 57 | // to pass along the request, call the next app 58 | return app(env); 59 | }; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/test/MiddlewareConvention1/Gamma.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Collections.Generic; 20 | using System.IO; 21 | using System.Threading.Tasks; 22 | using MiddlewareConvention1; 23 | using Utils; 24 | 25 | namespace Owin 26 | { 27 | public static partial class Extensions 28 | { 29 | public static IAppBuilder UseGamma(this IAppBuilder builder, string arg1, string arg2) 30 | { 31 | return builder.Use(typeof(Gamma), arg1, arg2); 32 | } 33 | } 34 | } 35 | 36 | namespace MiddlewareConvention1 37 | { 38 | using AppFunc = Func, Task>; 39 | 40 | public class Gamma 41 | { 42 | readonly AppFunc _app; 43 | readonly string _arg1; 44 | readonly string _arg2; 45 | 46 | public Gamma(AppFunc app, string arg1, string arg2) 47 | { 48 | _app = app; 49 | _arg1 = arg1; 50 | _arg2 = arg2; 51 | } 52 | 53 | public Task Invoke(IDictionary env) 54 | { 55 | var helper = new OwinHelper(env); 56 | if (helper.RequestPath.StartsWith(_arg1, StringComparison.OrdinalIgnoreCase)) 57 | { 58 | helper.ResponseHeaders["Content-Type"] = new[] { "text/plain" }; 59 | using (var writer = new StreamWriter(helper.OutputStream)) 60 | { 61 | writer.Write(_arg2); 62 | } 63 | return TaskHelpers.Completed(); 64 | } 65 | 66 | // to pass along the request, call the next app 67 | return _app(env); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/test/MiddlewareConvention1/MiddlewareConvention1.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {0AB5F10C-F0AD-47AD-AF23-AE80CDB7A19C} 9 | Library 10 | Properties 11 | MiddlewareConvention1 12 | MiddlewareConvention1 13 | v4.0 14 | 512 15 | ..\..\..\ 16 | true 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | False 38 | ..\..\..\packages\Owin.1.0\lib\net40\Owin.dll 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | {eb90cb5c-13d4-4e8a-ab69-839a99e9066a} 53 | Owin.Extensions 54 | 55 | 56 | {0BF71599-B6C3-4825-9169-B809971A7ED7} 57 | Utils 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 72 | -------------------------------------------------------------------------------- /src/test/MiddlewareConvention1/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Reflection; 20 | using System.Runtime.InteropServices; 21 | 22 | // General Information about an assembly is controlled through the following 23 | // set of attributes. Change these attribute values to modify the information 24 | // associated with an assembly. 25 | [assembly: AssemblyTitle("MiddlewareConvention1")] 26 | [assembly: AssemblyDescription("")] 27 | [assembly: AssemblyConfiguration("")] 28 | [assembly: AssemblyCulture("")] 29 | 30 | // Setting ComVisible to false makes the types in this assembly not visible 31 | // to COM components. If you need to access a type in this assembly from 32 | // COM, set the ComVisible attribute to true on that type. 33 | [assembly: ComVisible(false)] 34 | 35 | // The following GUID is for the ID of the typelib if this project is exposed to COM 36 | [assembly: Guid("4d3afdfb-8bea-4a9a-8bee-8b80e2decd4f")] 37 | 38 | [assembly: AssemblyVersion("0.7")] 39 | [assembly: AssemblyFileVersion("0.7")] 40 | [assembly: AssemblyInformationalVersion("0.7-alpha")] 41 | [assembly: CLSCompliant(true)] 42 | -------------------------------------------------------------------------------- /src/test/MiddlewareConvention1/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/test/MiddlewareConvention2/Beta.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Collections.Generic; 20 | using System.IO; 21 | using System.Threading.Tasks; 22 | using Utils; 23 | 24 | namespace MiddlewareConvention2 25 | { 26 | using AppFunc = Func, Task>; 27 | 28 | public class Beta 29 | { 30 | public static Func Invoke(string arg1, string arg2) 31 | { 32 | return app => env => 33 | { 34 | var helper = new OwinHelper(env); 35 | if (helper.RequestPath.StartsWith(arg1, StringComparison.OrdinalIgnoreCase)) 36 | { 37 | helper.ResponseHeaders["Content-Type"] = new[] { "text/plain" }; 38 | using (var writer = new StreamWriter(helper.OutputStream)) 39 | { 40 | writer.Write(arg2); 41 | } 42 | return TaskHelpers.Completed(); 43 | } 44 | 45 | // to pass along the request, call the next app 46 | return app(env); 47 | }; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/MiddlewareConvention2/Delta.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Collections.Generic; 20 | using System.IO; 21 | using System.Threading.Tasks; 22 | using Utils; 23 | 24 | namespace MiddlewareConvention2 25 | { 26 | using AppFunc = Func, Task>; 27 | 28 | public class Delta 29 | { 30 | readonly AppFunc _app; 31 | readonly string _arg1; 32 | readonly string _arg2; 33 | 34 | public Delta(AppFunc app, string arg1, string arg2) 35 | { 36 | _app = app; 37 | _arg1 = arg1; 38 | _arg2 = arg2; 39 | } 40 | 41 | public Task Invoke(IDictionary env) 42 | { 43 | var helper = new OwinHelper(env); 44 | if (helper.RequestPath.StartsWith(_arg1, StringComparison.OrdinalIgnoreCase)) 45 | { 46 | helper.ResponseHeaders["Content-Type"] = new[] { "text/plain" }; 47 | using (var writer = new StreamWriter(helper.OutputStream)) 48 | { 49 | writer.Write(_arg2); 50 | } 51 | return TaskHelpers.Completed(); 52 | } 53 | 54 | // to pass along the request, call the next app 55 | return _app(env); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/test/MiddlewareConvention2/MiddlewareConvention2.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {7F67B407-628C-403D-9235-EEE6AF64D32A} 9 | Library 10 | Properties 11 | MiddlewareConvention2 12 | MiddlewareConvention2 13 | v4.0 14 | 512 15 | ..\..\..\ 16 | true 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | {0BF71599-B6C3-4825-9169-B809971A7ED7} 49 | Utils 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 64 | -------------------------------------------------------------------------------- /src/test/MiddlewareConvention2/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Reflection; 20 | using System.Runtime.InteropServices; 21 | 22 | // General Information about an assembly is controlled through the following 23 | // set of attributes. Change these attribute values to modify the information 24 | // associated with an assembly. 25 | [assembly: AssemblyTitle("MiddlewareConvention2")] 26 | [assembly: AssemblyDescription("")] 27 | [assembly: AssemblyConfiguration("")] 28 | [assembly: AssemblyCulture("")] 29 | 30 | // Setting ComVisible to false makes the types in this assembly not visible 31 | // to COM components. If you need to access a type in this assembly from 32 | // COM, set the ComVisible attribute to true on that type. 33 | [assembly: ComVisible(false)] 34 | 35 | // The following GUID is for the ID of the typelib if this project is exposed to COM 36 | [assembly: Guid("029c81e0-67fe-41f3-99cc-4f76740c94a1")] 37 | 38 | [assembly: AssemblyVersion("0.7")] 39 | [assembly: AssemblyFileVersion("0.7")] 40 | [assembly: AssemblyInformationalVersion("0.7-alpha")] 41 | [assembly: CLSCompliant(true)] 42 | -------------------------------------------------------------------------------- /src/test/MiddlewareConvention2/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/test/Owin.Builder.Tests/ConventionsTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Xunit; 6 | 7 | namespace Owin.Builder.Tests 8 | { 9 | public class ConventionsTests 10 | { 11 | [Fact] 12 | public void StartupConvetion1Success() 13 | { 14 | IAppBuilder builder = new AppBuilder(); 15 | new StartupConvention1.Startup().Configuration(builder); 16 | builder.Build(); 17 | } 18 | 19 | [Fact] 20 | public void StartupConvetion2Success() 21 | { 22 | IAppBuilder builder = new AppBuilder(); 23 | new StartupConvention2.Startup().Configuration(builder.Properties); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/Owin.Builder.Tests/Owin.Builder.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {0AF835A6-8181-46DB-A17E-C765FA07A5A0} 9 | Library 10 | Properties 11 | Owin.Builder.Tests 12 | Owin.Builder.Tests 13 | v4.0 14 | 512 15 | ..\..\..\ 16 | true 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | False 39 | ..\..\..\packages\Owin.1.0\lib\net40\Owin.dll 40 | 41 | 42 | ..\..\..\packages\Shouldly.1.1.1.1\lib\35\Shouldly.dll 43 | 44 | 45 | 46 | 47 | ..\..\..\packages\xunit.1.9.1\lib\net20\xunit.dll 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | {2DCFACC8-AFD4-4FBA-8A89-9ACDC5CF4964} 63 | Owin.Builder 64 | 65 | 66 | {eb90cb5c-13d4-4e8a-ab69-839a99e9066a} 67 | Owin.Extensions 68 | 69 | 70 | {e8b6b07d-e8aa-4c5c-ab5c-bb1e10723c88} 71 | StartupConvention1 72 | 73 | 74 | {23008f98-f199-40ee-a9e6-9269e67a70bd} 75 | StartupConvention2 76 | 77 | 78 | {0BF71599-B6C3-4825-9169-B809971A7ED7} 79 | Utils 80 | 81 | 82 | 83 | 84 | 91 | -------------------------------------------------------------------------------- /src/test/Owin.Builder.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Reflection; 20 | using System.Runtime.InteropServices; 21 | 22 | // General Information about an assembly is controlled through the following 23 | // set of attributes. Change these attribute values to modify the information 24 | // associated with an assembly. 25 | [assembly: AssemblyTitle("Owin.Builder.Tests")] 26 | [assembly: AssemblyDescription("")] 27 | [assembly: AssemblyConfiguration("")] 28 | [assembly: AssemblyCulture("")] 29 | 30 | // Setting ComVisible to false makes the types in this assembly not visible 31 | // to COM components. If you need to access a type in this assembly from 32 | // COM, set the ComVisible attribute to true on that type. 33 | [assembly: ComVisible(false)] 34 | 35 | // The following GUID is for the ID of the typelib if this project is exposed to COM 36 | [assembly: Guid("d3c3bb13-3b5a-458f-baf8-15fceb6106bd")] 37 | 38 | [assembly: AssemblyVersion("0.7")] 39 | [assembly: AssemblyFileVersion("0.7")] 40 | [assembly: AssemblyInformationalVersion("0.7-alpha")] 41 | [assembly: CLSCompliant(true)] 42 | -------------------------------------------------------------------------------- /src/test/Owin.Builder.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/test/Owin.Loader.Tests/Owin.Loader.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {13785347-FC73-4D0E-9DCA-300DD87C308E} 9 | Library 10 | Properties 11 | Owin.Loader.Tests 12 | Owin.Loader.Tests 13 | v4.0 14 | 512 15 | ..\..\..\ 16 | true 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | ..\..\..\packages\xunit.1.9.1\lib\net20\xunit.dll 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 63 | -------------------------------------------------------------------------------- /src/test/Owin.Loader.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Reflection; 20 | using System.Runtime.InteropServices; 21 | 22 | // General Information about an assembly is controlled through the following 23 | // set of attributes. Change these attribute values to modify the information 24 | // associated with an assembly. 25 | [assembly: AssemblyTitle("Owin.Loader.Tests")] 26 | [assembly: AssemblyDescription("")] 27 | [assembly: AssemblyConfiguration("")] 28 | [assembly: AssemblyCulture("")] 29 | 30 | // Setting ComVisible to false makes the types in this assembly not visible 31 | // to COM components. If you need to access a type in this assembly from 32 | // COM, set the ComVisible attribute to true on that type. 33 | [assembly: ComVisible(false)] 34 | 35 | // The following GUID is for the ID of the typelib if this project is exposed to COM 36 | [assembly: Guid("84658dd6-1dd7-46ce-858c-3d5bf8d64d9e")] 37 | 38 | [assembly: AssemblyVersion("0.7")] 39 | [assembly: AssemblyFileVersion("0.7")] 40 | [assembly: AssemblyInformationalVersion("0.7-alpha")] 41 | [assembly: CLSCompliant(true)] 42 | -------------------------------------------------------------------------------- /src/test/Owin.Loader.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/test/Owin.Types.Tests/Owin.Types.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {79EFA752-FC41-4245-B6FD-69C826E6E47C} 8 | Library 9 | Properties 10 | Owin.Types.Tests 11 | Owin.Types.Tests 12 | v4.0 13 | 512 14 | ..\..\..\ 15 | true 16 | 17 | 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | ..\..\..\packages\Shouldly.1.1.1.1\lib\35\Shouldly.dll 37 | 38 | 39 | 40 | 41 | 42 | ..\..\..\packages\xunit.1.9.1\lib\net20\xunit.dll 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | {06B11480-240F-4EFB-AA6C-8EB354ADCF83} 60 | Owin.Types 61 | 62 | 63 | 64 | 65 | 72 | -------------------------------------------------------------------------------- /src/test/Owin.Types.Tests/OwinHelpersMethodOverrideTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Owin.Types.Extensions; 3 | using Shouldly; 4 | using Xunit; 5 | 6 | namespace Owin.Types.Tests 7 | { 8 | public class OwinHelpersMethodOverrideTests 9 | { 10 | private static OwinRequest Create(Action setup) 11 | { 12 | var request = OwinRequest.Create(); 13 | setup(request); 14 | return request; 15 | } 16 | 17 | [Fact] 18 | public void RequestMethodUsedIfAvailable() 19 | { 20 | Create(req => req.Method = "one") 21 | .GetMethodOverride() 22 | .ShouldBe("one"); 23 | Create(req => req.Method = "GET") 24 | .GetMethodOverride() 25 | .ShouldBe("GET"); 26 | Create(req => req.Method = "POST") 27 | .GetMethodOverride() 28 | .ShouldBe("POST"); 29 | Create(req => req.Method = "PUT") 30 | .GetMethodOverride() 31 | .ShouldBe("PUT"); 32 | } 33 | 34 | [Fact] 35 | public void MethodOverrideReplacesPostMethod() 36 | { 37 | Create(req => req 38 | .SetHeader("X-Http-Method-Override", "PUT") 39 | .Set(OwinConstants.RequestMethod, "POST")) 40 | .GetMethodOverride() 41 | .ShouldBe("PUT"); 42 | Create(req => req 43 | .SetHeader("X-Http-Method-Override", "GET") 44 | .Set(OwinConstants.RequestMethod, "POST")) 45 | .GetMethodOverride() 46 | .ShouldBe("GET"); 47 | Create(req => req 48 | .SetHeader("X-Http-Method-Override", "x") 49 | .Set(OwinConstants.RequestMethod, "POST")) 50 | .GetMethodOverride() 51 | .ShouldBe("x"); 52 | } 53 | 54 | [Fact] 55 | public void MethodDoesNotReplaceOtherMethods() 56 | { 57 | Create(req => req 58 | .SetHeader("X-Http-Method-Override", "x") 59 | .Set(OwinConstants.RequestMethod, "PUT")) 60 | .GetMethodOverride() 61 | .ShouldBe("PUT"); 62 | Create(req => req 63 | .SetHeader("X-Http-Method-Override", "x") 64 | .Set(OwinConstants.RequestMethod, "GET")) 65 | .GetMethodOverride() 66 | .ShouldBe("GET"); 67 | Create(req => req 68 | .SetHeader("X-Http-Method-Override", "x") 69 | .Set(OwinConstants.RequestMethod, "CUSTOM")) 70 | .GetMethodOverride() 71 | .ShouldBe("CUSTOM"); 72 | } 73 | 74 | [Fact] 75 | public void ApplyMethodOverrideChangesMethodOnlyWhenPost() 76 | { 77 | Create(req => req 78 | .SetHeader("X-Http-Method-Override", "PUT") 79 | .Set(OwinConstants.RequestMethod, "POST")) 80 | .ApplyMethodOverride() 81 | .Method.ShouldBe("PUT"); 82 | Create(req => req 83 | .SetHeader("X-Http-Method-Override", "GET") 84 | .Set(OwinConstants.RequestMethod, "POST")) 85 | .ApplyMethodOverride() 86 | .Method.ShouldBe("GET"); 87 | Create(req => req 88 | .SetHeader("X-Http-Method-Override", "x") 89 | .Set(OwinConstants.RequestMethod, "POST")) 90 | .ApplyMethodOverride() 91 | .Method.ShouldBe("x"); 92 | Create(req => req 93 | .SetHeader("X-Http-Method-Override", "x") 94 | .Set(OwinConstants.RequestMethod, "PUT")) 95 | .ApplyMethodOverride() 96 | .Method.ShouldBe("PUT"); 97 | Create(req => req 98 | .SetHeader("X-Http-Method-Override", "x") 99 | .Set(OwinConstants.RequestMethod, "GET")) 100 | .ApplyMethodOverride() 101 | .Method.ShouldBe("GET"); 102 | Create(req => req 103 | .SetHeader("X-Http-Method-Override", "x") 104 | .Set(OwinConstants.RequestMethod, "CUSTOM")) 105 | .ApplyMethodOverride() 106 | .Method.ShouldBe("CUSTOM"); 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /src/test/Owin.Types.Tests/OwinResponseSendFileTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using Shouldly; 3 | using Xunit; 4 | 5 | namespace Owin.Types.Tests 6 | { 7 | public class OwinResponseSendFileTests 8 | { 9 | [Fact] 10 | public void SendAsyncKeyDeterminesIfYouCanCallSendFileAsync() 11 | { 12 | var res = new OwinResponse(OwinRequest.Create()); 13 | res.CanSendFile.ShouldBe(false); 14 | res.SendFileAsyncDelegate = (a, b, c, d) => null; 15 | res.CanSendFile.ShouldBe(true); 16 | } 17 | 18 | [Fact] 19 | public void CallingMethodInvokesDelegate() 20 | { 21 | var res = new OwinResponse(OwinRequest.Create()); 22 | res.CanSendFile.ShouldBe(false); 23 | 24 | string aa = null; 25 | long bb = 0; 26 | long? cc = null; 27 | CancellationToken dd = CancellationToken.None; 28 | 29 | var cts = new CancellationTokenSource(); 30 | 31 | res.SendFileAsyncDelegate = (a, b, c, d) => 32 | { 33 | aa = a; 34 | bb = b; 35 | cc = c; 36 | dd = d; 37 | return null; 38 | }; 39 | res.SendFileAsync("one", 2, 3, cts.Token); 40 | aa.ShouldBe("one"); 41 | bb.ShouldBe(2); 42 | cc.ShouldBe(3); 43 | dd.ShouldBe(cts.Token); 44 | 45 | res.SendFileAsync("four"); 46 | aa.ShouldBe("four"); 47 | bb.ShouldBe(0); 48 | cc.ShouldBe(null); 49 | dd.ShouldBe(CancellationToken.None); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/test/Owin.Types.Tests/OwinResponseTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading; 6 | using Shouldly; 7 | using Xunit; 8 | 9 | namespace Owin.Types.Tests 10 | { 11 | public class OwinResponseTests 12 | { 13 | [Fact] 14 | public void ItStronglyTypesOwinKeys() 15 | { 16 | var headers = new Dictionary(StringComparer.InvariantCultureIgnoreCase) 17 | { 18 | {"alpha", new []{"beta", "gamma"}} 19 | }; 20 | var body = new MemoryStream(new byte[] { 65, 66, 67, 68 }); 21 | var cts = new CancellationTokenSource(); 22 | var env = new Dictionary(StringComparer.Ordinal) 23 | { 24 | {"owin.ResponseStatusCode", 1}, 25 | {"owin.ResponseReasonPhrase", "two"}, 26 | {"owin.ResponseProtocol", "three"}, 27 | {"owin.ResponseHeaders", headers}, 28 | {"owin.ResponseBody", body}, 29 | {"owin.Version", "1.0"}, 30 | {"owin.CallCancelled", cts.Token}, 31 | }; 32 | 33 | var res = new OwinResponse(env); 34 | res.StatusCode.ShouldBe(1); 35 | res.ReasonPhrase.ShouldBe("two"); 36 | res.Protocol.ShouldBe("three"); 37 | res.Headers.ShouldBeSameAs(headers); 38 | res.Body.ShouldBeSameAs(body); 39 | res.OwinVersion.ShouldBe("1.0"); 40 | res.CallCancelled.ShouldBe(cts.Token); 41 | } 42 | 43 | [Fact] 44 | public void SettersModifyEnvironment() 45 | { 46 | var headers = new Dictionary(StringComparer.InvariantCultureIgnoreCase) 47 | { 48 | {"alpha", new []{"beta", "gamma"}} 49 | }; 50 | var body = new MemoryStream(new byte[] { 65, 66, 67, 68 }); 51 | var cts = new CancellationTokenSource(); 52 | 53 | var env = new Dictionary(StringComparer.Ordinal); 54 | var res = new OwinResponse(env) 55 | { 56 | StatusCode = 1, 57 | ReasonPhrase = "two", 58 | Protocol = "three", 59 | Headers = headers, 60 | Body = body, 61 | OwinVersion = "1.0", 62 | CallCancelled = cts.Token 63 | }; 64 | env["owin.ResponseStatusCode"].ShouldBe(1); 65 | env["owin.ResponseReasonPhrase"].ShouldBe("two"); 66 | env["owin.ResponseProtocol"].ShouldBe("three"); 67 | env["owin.ResponseHeaders"].ShouldBe(headers); 68 | env["owin.ResponseBody"].ShouldBe(body); 69 | env["owin.Version"].ShouldBe("1.0"); 70 | env["owin.CallCancelled"].ShouldBe(cts.Token); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/test/Owin.Types.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyTitle("Owin.Types.Tests")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("Owin.Types.Tests")] 14 | [assembly: AssemblyCopyright("Copyright © 2013")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | 18 | // Setting ComVisible to false makes the types in this assembly not visible 19 | // to COM components. If you need to access a type in this assembly from 20 | // COM, set the ComVisible attribute to true on that type. 21 | [assembly: ComVisible(false)] 22 | 23 | // The following GUID is for the ID of the typelib if this project is exposed to COM 24 | [assembly: Guid("be3fa57e-add2-49cd-8ab9-8bbd4aaa2b48")] 25 | 26 | [assembly: AssemblyVersion("0.7")] 27 | [assembly: AssemblyFileVersion("0.7")] 28 | [assembly: AssemblyInformationalVersion("0.7-alpha")] 29 | [assembly: CLSCompliant(true)] 30 | -------------------------------------------------------------------------------- /src/test/Owin.Types.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/test/StartupConvention1/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Reflection; 20 | using System.Runtime.InteropServices; 21 | 22 | // General Information about an assembly is controlled through the following 23 | // set of attributes. Change these attribute values to modify the information 24 | // associated with an assembly. 25 | [assembly: AssemblyTitle("StartupConvention1")] 26 | [assembly: AssemblyDescription("")] 27 | [assembly: AssemblyConfiguration("")] 28 | [assembly: AssemblyCulture("")] 29 | 30 | // Setting ComVisible to false makes the types in this assembly not visible 31 | // to COM components. If you need to access a type in this assembly from 32 | // COM, set the ComVisible attribute to true on that type. 33 | [assembly: ComVisible(false)] 34 | 35 | // The following GUID is for the ID of the typelib if this project is exposed to COM 36 | [assembly: Guid("bfb0f32e-e86b-42da-8e6c-47765ca08b99")] 37 | 38 | [assembly: AssemblyVersion("0.7")] 39 | [assembly: AssemblyFileVersion("0.7")] 40 | [assembly: AssemblyInformationalVersion("0.7-alpha")] 41 | [assembly: CLSCompliant(true)] 42 | -------------------------------------------------------------------------------- /src/test/StartupConvention1/Startup.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Collections.Generic; 20 | using System.Threading.Tasks; 21 | using MiddlewareConvention1; 22 | using MiddlewareConvention2; 23 | using Owin; 24 | 25 | namespace StartupConvention1 26 | { 27 | using AppFunc = Func, Task>; 28 | 29 | public class Startup 30 | { 31 | public void Configuration(IAppBuilder builder) 32 | { 33 | builder.UseAlpha("a", "b"); 34 | 35 | builder.UseFunc(app => Alpha.Invoke(app, "a", "b")); 36 | 37 | builder.UseFunc(Alpha.Invoke, "a", "b"); 38 | 39 | builder.Use(Beta.Invoke("a", "b")); 40 | 41 | builder.UseFunc(Beta.Invoke, "a", "b"); 42 | 43 | builder.UseGamma("a", "b"); 44 | 45 | builder.Use(typeof(Gamma), "a", "b"); 46 | 47 | builder.UseType("a", "b"); 48 | 49 | builder.UseFunc(app => new Gamma(app, "a", "b").Invoke); 50 | 51 | builder.Use(typeof(Delta), "a", "b"); 52 | 53 | builder.UseType("a", "b"); 54 | 55 | builder.UseFunc(app => new Delta(app, "a", "b").Invoke); 56 | 57 | builder.Run(this); 58 | } 59 | 60 | public Task Invoke(IDictionary env) 61 | { 62 | throw new NotImplementedException(); 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /src/test/StartupConvention1/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /src/test/StartupConvention1/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /src/test/StartupConvention1/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/test/StartupConvention1/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/test/StartupConvention2/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Reflection; 20 | using System.Runtime.InteropServices; 21 | 22 | // General Information about an assembly is controlled through the following 23 | // set of attributes. Change these attribute values to modify the information 24 | // associated with an assembly. 25 | [assembly: AssemblyTitle("StartupConvention2")] 26 | [assembly: AssemblyDescription("")] 27 | [assembly: AssemblyConfiguration("")] 28 | [assembly: AssemblyCulture("")] 29 | 30 | // Setting ComVisible to false makes the types in this assembly not visible 31 | // to COM components. If you need to access a type in this assembly from 32 | // COM, set the ComVisible attribute to true on that type. 33 | [assembly: ComVisible(false)] 34 | 35 | // The following GUID is for the ID of the typelib if this project is exposed to COM 36 | [assembly: Guid("81292e3d-bc31-470e-b3b0-ea18c192e74c")] 37 | 38 | [assembly: AssemblyVersion("0.7")] 39 | [assembly: AssemblyFileVersion("0.7")] 40 | [assembly: AssemblyInformationalVersion("0.7-alpha")] 41 | [assembly: CLSCompliant(true)] 42 | -------------------------------------------------------------------------------- /src/test/StartupConvention2/Startup.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Collections.Generic; 20 | using System.IO; 21 | using System.Threading.Tasks; 22 | using MiddlewareConvention1; 23 | using MiddlewareConvention2; 24 | 25 | namespace StartupConvention2 26 | { 27 | using AppFunc = Func, Task>; 28 | 29 | public class Startup 30 | { 31 | public AppFunc Configuration(IDictionary properties) 32 | { 33 | AppFunc app = Main; 34 | 35 | app = Alpha.Invoke(app, "One", "Two"); 36 | 37 | app = Beta.Invoke("Three", "Four").Invoke(app); 38 | 39 | app = new Gamma(app, "Five", "Six").Invoke; 40 | 41 | app = new Delta(app, "Seven", "Eight").Invoke; 42 | 43 | return app; 44 | } 45 | 46 | public Task Main(IDictionary env) 47 | { 48 | throw new NotImplementedException(); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /src/test/StartupConvention2/StartupConvention2.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 8 | 9 | 2.0 10 | {23008F98-F199-40EE-A9E6-9269E67A70BD} 11 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 12 | Library 13 | Properties 14 | StartupConvention2 15 | StartupConvention2 16 | v4.0 17 | false 18 | 19 | 20 | 4.0 21 | 22 | 23 | 24 | true 25 | full 26 | false 27 | bin\ 28 | DEBUG;TRACE 29 | prompt 30 | 4 31 | 32 | 33 | pdbonly 34 | true 35 | bin\ 36 | TRACE 37 | prompt 38 | 4 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | Web.config 48 | 49 | 50 | Web.config 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | {0AB5F10C-F0AD-47AD-AF23-AE80CDB7A19C} 60 | MiddlewareConvention1 61 | 62 | 63 | {7F67B407-628C-403D-9235-EEE6AF64D32A} 64 | MiddlewareConvention2 65 | 66 | 67 | 68 | 10.0 69 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | False 79 | True 80 | 36464 81 | / 82 | 83 | 84 | False 85 | False 86 | 87 | 88 | False 89 | 90 | 91 | 92 | 93 | 100 | -------------------------------------------------------------------------------- /src/test/StartupConvention2/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /src/test/StartupConvention2/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /src/test/StartupConvention2/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/test/Utils/OwinHelper.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Collections.Generic; 20 | using System.IO; 21 | 22 | namespace Utils 23 | { 24 | public class OwinHelper 25 | { 26 | public IDictionary Env { get; private set; } 27 | 28 | public OwinHelper(IDictionary env) 29 | { 30 | Env = env; 31 | } 32 | 33 | public OwinHelper() 34 | { 35 | Env = new Dictionary 36 | { 37 | {"owin.RequestHeaders",new Dictionary(StringComparer.OrdinalIgnoreCase)}, 38 | {"owin.ResponseHeaders",new Dictionary(StringComparer.OrdinalIgnoreCase)}, 39 | }; 40 | } 41 | 42 | public string RequestPath 43 | { 44 | get { return Get("owin.RequestPath"); } 45 | } 46 | 47 | public IDictionary ResponseHeaders 48 | { 49 | get { return Get>("owin.ResponseHeaders"); } 50 | } 51 | 52 | public Stream OutputStream 53 | { 54 | get { return Get("owin.ResponseBody"); } 55 | } 56 | 57 | public int ResponseStatusCode 58 | { 59 | get { return Get("owin.ResponseStatusCode"); } 60 | } 61 | 62 | T Get(string key) 63 | { 64 | object value; 65 | return Env.TryGetValue(key, out value) ? (T)value : default(T); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/test/Utils/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Monkey Square, Inc. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work or additional information regarding copyright 4 | // ownership. Monkey Square, Inc. licenses this file to you 5 | // under the Apache License, Version 2.0 (the "License"); you 6 | // may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | using System; 19 | using System.Reflection; 20 | using System.Runtime.InteropServices; 21 | 22 | // General Information about an assembly is controlled through the following 23 | // set of attributes. Change these attribute values to modify the information 24 | // associated with an assembly. 25 | [assembly: AssemblyTitle("Utils")] 26 | [assembly: AssemblyDescription("")] 27 | [assembly: AssemblyConfiguration("")] 28 | [assembly: AssemblyCulture("")] 29 | 30 | // Setting ComVisible to false makes the types in this assembly not visible 31 | // to COM components. If you need to access a type in this assembly from 32 | // COM, set the ComVisible attribute to true on that type. 33 | [assembly: ComVisible(false)] 34 | 35 | // The following GUID is for the ID of the typelib if this project is exposed to COM 36 | [assembly: Guid("7c2786b8-ad84-401d-addf-e255f7debd32")] 37 | 38 | [assembly: AssemblyVersion("0.7")] 39 | [assembly: AssemblyFileVersion("0.7")] 40 | [assembly: AssemblyInformationalVersion("0.7-alpha")] 41 | [assembly: CLSCompliant(true)] 42 | -------------------------------------------------------------------------------- /src/test/Utils/Utils.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {0BF71599-B6C3-4825-9169-B809971A7ED7} 9 | Library 10 | Properties 11 | Utils 12 | Utils 13 | v4.0 14 | 512 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 54 | --------------------------------------------------------------------------------