Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
Added packages for OWIN to solve #13
Browse files Browse the repository at this point in the history
  • Loading branch information
azzlack committed Jan 28, 2016
1 parent a68c7e3 commit 5bde23c
Show file tree
Hide file tree
Showing 19 changed files with 692 additions and 295 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>Microsoft.AspNet.WebApi.Extensions.Compression.Server.Owin</id>
<version>2.0.0</version>
<title>OWIN support for Microsoft.AspNet.WebApi.Extensions.Compression.Server</title>
<authors>Ove Andersen</authors>
<owners>EyeCatch</owners>
<description>Package for supporting OWIN when using Microsoft ASP.NET Web API Compression Support</description>
<summary>Package for supporting OWIN when using Microsoft ASP.NET Web API Compression Support.</summary>
<language>en-US</language>
<projectUrl>https://github.com/azzlack/Microsoft.AspNet.WebApi.MessageHandlers.Compression</projectUrl>
<iconUrl>http://www.eyecatch.no/favicon.ico</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<licenseUrl>http://www.eyecatch.no/licenses/apache-20/</licenseUrl>
<copyright>Copyright EyeCatch 2016</copyright>
<dependencies>
<dependency id="Microsoft.AspNet.WebApi.Owin" version="5.2.0" />
<dependency id="Microsoft.AspNet.WebApi.Extensions.Compression.Server" version="2.0.0" />
</dependencies>
<references></references>
<tags>aspnet webapi aspnetwebapi http compression gzip deflate eyecatch</tags>
</metadata>
<files>
<file src="..\..\src\Server.Owin\bin\Release\Microsoft.AspNet.WebApi.Extensions.Compression.Server.Owin.dll" target="lib\net45" />
<file src="..\..\src\Server.Owin\bin\Release\Microsoft.AspNet.WebApi.Extensions.Compression.Server.Owin.pdb" target="lib\net45" />
<file src="..\..\src\Server.Owin\**\*.cs" exclude="**\obj\**\*.*" target="src" />
</files>
</package>
14 changes: 6 additions & 8 deletions src/Client/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
using System.Resources;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Resources;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Microsoft.AspNet.WebApi.MessageHandlers.Compression")]
[assembly: AssemblyDescription("Module for ASP.NET Web API that enables GZip and Deflate support for incoming and outgoing requests")]
[assembly: AssemblyTitle("System.Net.Http.Extensions.Compression.Client")]
[assembly: AssemblyDescription("Module for Microsoft HTTP Client that enables GZip and Deflate support for incoming and outgoing requests")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("EyeCatch")]
[assembly: AssemblyProduct("Microsoft.AspNet.WebApi.MessageHandlers.Compression")]
[assembly: AssemblyCopyright("Copyright © EyeCatch 2014")]
[assembly: AssemblyProduct("System.Net.Http.Extensions.Compression.Client")]
[assembly: AssemblyCopyright("Copyright © EyeCatch 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]
Expand Down
8 changes: 8 additions & 0 deletions src/Microsoft.AspNet.WebApi.MessageHandlers.Compression.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Server\Server.csp
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core", "Core\Core.csproj", "{B7534554-AB6C-44AC-BF34-424DBE596216}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server.Owin", "Server.Owin\Server.Owin.csproj", "{DAA0A504-7ED7-4906-9D6B-FB566AE47084}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -42,6 +44,12 @@ Global
{B7534554-AB6C-44AC-BF34-424DBE596216}.Release|Any CPU.Build.0 = Release|Any CPU
{B7534554-AB6C-44AC-BF34-424DBE596216}.Test|Any CPU.ActiveCfg = Test|Any CPU
{B7534554-AB6C-44AC-BF34-424DBE596216}.Test|Any CPU.Build.0 = Test|Any CPU
{DAA0A504-7ED7-4906-9D6B-FB566AE47084}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DAA0A504-7ED7-4906-9D6B-FB566AE47084}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DAA0A504-7ED7-4906-9D6B-FB566AE47084}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DAA0A504-7ED7-4906-9D6B-FB566AE47084}.Release|Any CPU.Build.0 = Release|Any CPU
{DAA0A504-7ED7-4906-9D6B-FB566AE47084}.Test|Any CPU.ActiveCfg = Test|Any CPU
{DAA0A504-7ED7-4906-9D6B-FB566AE47084}.Test|Any CPU.Build.0 = Test|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

This file was deleted.

103 changes: 103 additions & 0 deletions src/Server.Owin/OwinServerCompressionHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
namespace Microsoft.AspNet.WebApi.Extensions.Compression.Server.Owin
{
using Microsoft.AspNet.WebApi.Extensions.Compression.Server;
using Microsoft.Owin;
using System;
using System.Net.Http;
using System.Net.Http.Extensions.Compression.Core.Interfaces;
using System.Threading;
using System.Threading.Tasks;

public class OwinServerCompressionHandler : ServerCompressionHandler
{
/// <summary>
/// Initializes a new instance of the <see cref="OwinServerCompressionHandler" /> class.
/// </summary>
/// <param name="compressors">The compressors.</param>
public OwinServerCompressionHandler(params ICompressor[] compressors)
: base(null, 860, null, compressors)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="OwinServerCompressionHandler" /> class.
/// </summary>
/// <param name="contentSizeThreshold">The content size threshold before compressing.</param>
/// <param name="compressors">The compressors.</param>
public OwinServerCompressionHandler(int contentSizeThreshold, params ICompressor[] compressors)
: base(null, contentSizeThreshold, null, compressors)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="OwinServerCompressionHandler" /> class.
/// </summary>
/// <param name="innerHandler">The inner handler.</param>
/// <param name="compressors">The compressors.</param>
public OwinServerCompressionHandler(HttpMessageHandler innerHandler, params ICompressor[] compressors)
: base(innerHandler, 860, null, compressors)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="OwinServerCompressionHandler" /> class.
/// </summary>
/// <param name="innerHandler">The inner handler.</param>
/// <param name="contentSizeThreshold">The content size threshold before compressing.</param>
/// <param name="compressors">The compressors.</param>
public OwinServerCompressionHandler(HttpMessageHandler innerHandler, int contentSizeThreshold, params ICompressor[] compressors)
: base(innerHandler, contentSizeThreshold, null, compressors)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="OwinServerCompressionHandler" /> class.
/// </summary>
/// <param name="innerHandler">The inner handler.</param>
/// <param name="contentSizeThreshold">The content size threshold before compressing.</param>
/// <param name="enableCompression">Custom delegate to enable or disable compression.</param>
/// <param name="compressors">The compressors.</param>
public OwinServerCompressionHandler(HttpMessageHandler innerHandler, int contentSizeThreshold, Predicate<HttpRequestMessage> enableCompression, params ICompressor[] compressors)
: base(innerHandler, contentSizeThreshold, enableCompression, compressors)
{
}

/// <summary>Handles the request.</summary>
/// <param name="request">The request.</param>
/// <param name="cancellationToken">A cancellation token to cancel operation.</param>
/// <returns>A Task&lt;HttpResponseMessage&gt;</returns>
public override Task<HttpRequestMessage> HandleRequest(HttpRequestMessage request, CancellationToken cancellationToken)
{
request.GetOwinContext().Response.OnSendingHeaders(
response =>
{
((IOwinResponse)response).Environment["HeadersWritten"] = true;
},
request.GetOwinContext().Response);

return base.HandleRequest(request, cancellationToken);
}

/// <summary>Handles the response.</summary>
/// <param name="request">The request.</param>
/// <param name="response">The response.</param>
/// <param name="cancellationToken">A cancellation token to cancel operation.</param>
/// <returns>The handled response.</returns>
public override async Task<HttpResponseMessage> HandleResponse(HttpRequestMessage request, HttpResponseMessage response, CancellationToken cancellationToken)
{
// Check if headers are already written, and skip processing if they are
if (request.GetOwinContext().Response.Environment.ContainsKey("HeadersWritten"))
{
bool written;
bool.TryParse(request.GetOwinContext().Response.Environment["HeadersWritten"].ToString(), out written);

if (written)
{
return response;
}
}

return await base.HandleResponse(request, response, cancellationToken);
}
}
}
35 changes: 35 additions & 0 deletions src/Server.Owin/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Microsoft.AspNet.WebApi.Extensions.Compression.Server.Owin")]
[assembly: AssemblyDescription("OWIN support for Microsoft.AspNet.WebApi.Extensions.Compression.Server")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("EyeCatch")]
[assembly: AssemblyProduct("Microsoft.AspNet.WebApi.Extensions.Compression.Server.Owin")]
[assembly: AssemblyCopyright("Copyright © EyeCatch 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("daa0a504-7ed7-4906-9d6b-fb566ae47084")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
101 changes: 101 additions & 0 deletions src/Server.Owin/Server.Owin.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DAA0A504-7ED7-4906-9D6B-FB566AE47084}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.AspNet.WebApi.Extensions.Compression.Server.Owin</RootNamespace>
<AssemblyName>Microsoft.AspNet.WebApi.Extensions.Compression.Server.Owin</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Test|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Test\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Owin, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Web.Http.Owin, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Owin.5.2.3\lib\net45\System.Web.Http.Owin.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="OwinServerCompressionHandler.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Core\Core.csproj">
<Project>{b7534554-ab6c-44ac-bf34-424dbe596216}</Project>
<Name>Core</Name>
</ProjectReference>
<ProjectReference Include="..\Server\Server.csproj">
<Project>{ee709c23-849d-43c5-9f47-0b8d8ddb43d8}</Project>
<Name>Server</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
11 changes: 11 additions & 0 deletions src/Server.Owin/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
9 changes: 9 additions & 0 deletions src/Server.Owin/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Owin" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.Owin" version="3.0.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
</packages>
Loading

0 comments on commit 5bde23c

Please sign in to comment.