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
01a997d7
Commit
01a997d7
authored
Apr 13, 2019
by
Poppyto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Simplification : Use static Encoding.ASCII instead of doing the whole stuff
- Nuget update to last Stream-Extended
parent
a39bf493
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
14 deletions
+4
-14
HttpWriter.cs
src/Titanium.Web.Proxy/Helpers/HttpWriter.cs
+3
-13
Titanium.Web.Proxy.csproj
src/Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
+1
-1
No files found.
src/Titanium.Web.Proxy/Helpers/HttpWriter.cs
View file @
01a997d7
...
...
@@ -18,18 +18,13 @@ namespace Titanium.Web.Proxy.Helpers
private
static
readonly
byte
[]
newLine
=
ProxyConstants
.
NewLineBytes
;
private
static
readonly
Encoder
encoder
=
Encoding
.
ASCII
.
GetEncoder
();
private
readonly
char
[]
charBuffer
;
private
static
readonly
Encoding
encoder
=
Encoding
.
ASCII
;
internal
HttpWriter
(
Stream
stream
,
IBufferPool
bufferPool
,
int
bufferSize
)
{
BufferSize
=
bufferSize
;
this
.
stream
=
stream
;
this
.
bufferPool
=
bufferPool
;
// ASCII encoder max byte count is char count + 1
charBuffer
=
new
char
[
BufferSize
-
1
];
}
internal
int
BufferSize
{
get
;
}
...
...
@@ -55,12 +50,10 @@ namespace Titanium.Web.Proxy.Helpers
int
charCount
=
value
.
Length
;
if
(
charCount
<
BufferSize
-
newLineChars
)
{
value
.
CopyTo
(
0
,
charBuffer
,
0
,
charCount
);
var
buffer
=
bufferPool
.
GetBuffer
(
BufferSize
);
try
{
int
idx
=
encoder
.
GetBytes
(
charBuffer
,
0
,
charCount
,
buffer
,
0
,
true
);
int
idx
=
encoder
.
GetBytes
(
value
,
0
,
charCount
,
buffer
,
0
);
if
(
newLineChars
>
0
)
{
Buffer
.
BlockCopy
(
newLine
,
0
,
buffer
,
idx
,
newLineChars
);
...
...
@@ -76,11 +69,8 @@ namespace Titanium.Web.Proxy.Helpers
}
else
{
var
charBuffer
=
new
char
[
charCount
];
value
.
CopyTo
(
0
,
charBuffer
,
0
,
charCount
);
var
buffer
=
new
byte
[
charCount
+
newLineChars
+
1
];
int
idx
=
encoder
.
GetBytes
(
charBuffer
,
0
,
charCount
,
buffer
,
0
,
true
);
int
idx
=
encoder
.
GetBytes
(
value
,
0
,
charCount
,
buffer
,
0
);
if
(
newLineChars
>
0
)
{
Buffer
.
BlockCopy
(
newLine
,
0
,
buffer
,
idx
,
newLineChars
);
...
...
src/Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
View file @
01a997d7
...
...
@@ -15,7 +15,7 @@
<ItemGroup>
<PackageReference Include="BrotliSharpLib" Version="0.3.1" />
<PackageReference Include="Portable.BouncyCastle" Version="1.8.3.37" />
<PackageReference Include="StreamExtended" Version="1.0.
190
" />
<PackageReference Include="StreamExtended" Version="1.0.
201
" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
...
...
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