Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

Commit 0d5a98d

Browse files
Merge pull request #498 from kfreezen/add-brotli-compression-2
Add brotli compression for windows
2 parents bf98361 + 158534b commit 0d5a98d

File tree

5 files changed

+9
-0
lines changed

5 files changed

+9
-0
lines changed

src/Titanium.Web.Proxy/Compression/CompressionFactory.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.IO;
33
using System.IO.Compression;
4+
using Titanium.Web.Proxy.Helpers;
45
using Titanium.Web.Proxy.Http;
56

67
namespace Titanium.Web.Proxy.Compression
@@ -18,6 +19,8 @@ internal static Stream Create(string type, Stream stream, bool leaveOpen = true)
1819
return new GZipStream(stream, CompressionMode.Compress, leaveOpen);
1920
case KnownHeaders.ContentEncodingDeflate:
2021
return new DeflateStream(stream, CompressionMode.Compress, leaveOpen);
22+
case KnownHeaders.ContentEncodingBrotli:
23+
return new BrotliSharpLib.BrotliStream(stream, CompressionMode.Compress, leaveOpen);
2124
default:
2225
throw new Exception($"Unsupported compression mode: {type}");
2326
}

src/Titanium.Web.Proxy/Compression/DecompressionFactory.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.IO;
33
using System.IO.Compression;
4+
using Titanium.Web.Proxy.Helpers;
45
using Titanium.Web.Proxy.Http;
56

67
namespace Titanium.Web.Proxy.Compression
@@ -18,6 +19,8 @@ internal static Stream Create(string type, Stream stream, bool leaveOpen = true)
1819
return new GZipStream(stream, CompressionMode.Decompress, leaveOpen);
1920
case KnownHeaders.ContentEncodingDeflate:
2021
return new DeflateStream(stream, CompressionMode.Decompress, leaveOpen);
22+
case KnownHeaders.ContentEncodingBrotli:
23+
return new BrotliSharpLib.BrotliStream(stream, CompressionMode.Decompress, leaveOpen);
2124
default:
2225
throw new Exception($"Unsupported decompression mode: {type}");
2326
}

src/Titanium.Web.Proxy/Http/KnownHeaders.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public static class KnownHeaders
3939
public const string ContentEncoding = "content-encoding";
4040
public const string ContentEncodingDeflate = "deflate";
4141
public const string ContentEncodingGzip = "gzip";
42+
public const string ContentEncodingBrotli = "br";
4243

4344
public const string Location = "Location";
4445

src/Titanium.Web.Proxy/Titanium.Web.Proxy.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
</PropertyGroup>
1414

1515
<ItemGroup>
16+
<PackageReference Include="CloudVeil.BrotliSharpLib" Version="0.3.1" />
1617
<PackageReference Include="Portable.BouncyCastle" Version="1.8.2" />
1718
<PackageReference Include="StreamExtended" Version="1.0.179" />
1819
</ItemGroup>

src/Titanium.Web.Proxy/Titanium.Web.Proxy.nuspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<dependencies>
1717
<dependency id="StreamExtended" version="1.0.179" />
1818
<dependency id="Portable.BouncyCastle" version="1.8.2" />
19+
<dependency id="BrotliSharpLib" version="0.3.1" />
1920
</dependencies>
2021
</metadata>
2122
<files>

0 commit comments

Comments
 (0)