Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Titanium-Web-Proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Titanium-Web-Proxy
Commits
5d778739
Commit
5d778739
authored
Mar 08, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize compression factory
parent
f9c7ba4e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
+11
-6
CompressionFactory.cs
Titanium.Web.Proxy/Compression/CompressionFactory.cs
+10
-4
ResponseHandler.cs
Titanium.Web.Proxy/ResponseHandler.cs
+1
-2
No files found.
Titanium.Web.Proxy/Compression/CompressionFactory.cs
View file @
5d778739
namespace
Titanium.Web.Proxy.Compression
using
System
;
namespace
Titanium.Web.Proxy.Compression
{
{
/// <summary>
/// <summary>
/// A factory to generate the compression methods based on the type of compression
/// A factory to generate the compression methods based on the type of compression
/// </summary>
/// </summary>
internal
class
CompressionFactory
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
)
switch
(
type
)
{
{
case
"gzip"
:
case
"gzip"
:
return
new
GZipCompression
()
;
return
gzip
.
Value
;
case
"deflate"
:
case
"deflate"
:
return
new
DeflateCompression
()
;
return
deflate
.
Value
;
default
:
default
:
return
null
;
return
null
;
}
}
...
...
Titanium.Web.Proxy/ResponseHandler.cs
View file @
5d778739
...
@@ -122,8 +122,7 @@ namespace Titanium.Web.Proxy
...
@@ -122,8 +122,7 @@ namespace Titanium.Web.Proxy
/// <returns></returns>
/// <returns></returns>
private
async
Task
<
byte
[
]>
GetCompressedResponseBody
(
string
encodingType
,
byte
[]
responseBodyStream
)
private
async
Task
<
byte
[
]>
GetCompressedResponseBody
(
string
encodingType
,
byte
[]
responseBodyStream
)
{
{
var
compressionFactory
=
new
CompressionFactory
();
var
compressor
=
CompressionFactory
.
GetCompression
(
encodingType
);
var
compressor
=
compressionFactory
.
Create
(
encodingType
);
return
await
compressor
.
Compress
(
responseBodyStream
);
return
await
compressor
.
Compress
(
responseBodyStream
);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment