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

Commit 51e29b6

Browse files
committed
Forgot to add compression support for Brotli in last commit.
1 parent af09eb0 commit 51e29b6

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

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

Lines changed: 8 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,13 @@ 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+
if (!RunTime.IsWindows)
24+
{
25+
throw new PlatformNotSupportedException("BrotliSharpLib currently supports only Windows.");
26+
}
27+
28+
return new BrotliSharpLib.BrotliStream(stream, CompressionMode.Compress, leaveOpen);
2129
default:
2230
throw new Exception($"Unsupported compression mode: {type}");
2331
}

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

Lines changed: 6 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
@@ -19,6 +20,11 @@ internal static Stream Create(string type, Stream stream, bool leaveOpen = true)
1920
case KnownHeaders.ContentEncodingDeflate:
2021
return new DeflateStream(stream, CompressionMode.Decompress, leaveOpen);
2122
case KnownHeaders.ContentEncodingBrotli:
23+
if(!RunTime.IsWindows)
24+
{
25+
throw new PlatformNotSupportedException("BrotliSharpLib currently supports only Windows.");
26+
}
27+
2228
return new BrotliSharpLib.BrotliStream(stream, CompressionMode.Decompress, leaveOpen);
2329
default:
2430
throw new Exception($"Unsupported decompression mode: {type}");

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

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

1515
<ItemGroup>
16-
<PackageReference Include="BrotliSharpLib" Version="0.3.1" />
16+
<PackageReference Include="CloudVeil.BrotliSharpLib" Version="0.3.1" />
1717
<PackageReference Include="Portable.BouncyCastle" Version="1.8.2" />
1818
<PackageReference Include="StreamExtended" Version="1.0.179" />
1919
</ItemGroup>

0 commit comments

Comments
 (0)