Commit f2817483 authored by justcoding121's avatar justcoding121

Merge branch 'develop' into beta

parents 1651c926 5d778739
namespace Titanium.Web.Proxy.Compression
using System;
namespace Titanium.Web.Proxy.Compression
{
/// <summary>
/// A factory to generate the compression methods based on the type of compression
/// </summary>
internal class CompressionFactory
{
public ICompression Create(string type)
//cache
private static Lazy<ICompression> gzip = new Lazy<ICompression>(() => new GZipCompression());
private static Lazy<ICompression> deflate = new Lazy<ICompression>(() => new DeflateCompression());
public static ICompression GetCompression(string type)
{
switch (type)
{
case "gzip":
return new GZipCompression();
return gzip.Value;
case "deflate":
return new DeflateCompression();
return deflate.Value;
default:
return null;
}
......
......@@ -122,8 +122,7 @@ namespace Titanium.Web.Proxy
/// <returns></returns>
private async Task<byte[]> GetCompressedResponseBody(string encodingType, byte[] responseBodyStream)
{
var compressionFactory = new CompressionFactory();
var compressor = compressionFactory.Create(encodingType);
var compressor = CompressionFactory.GetCompression(encodingType);
return await compressor.Compress(responseBodyStream);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment