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
a9412640
Commit
a9412640
authored
Apr 16, 2019
by
justcoding121
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into beta
parents
61da8091
b309fc21
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
13 deletions
+3
-13
HttpWriter.cs
src/Titanium.Web.Proxy/Helpers/HttpWriter.cs
+3
-13
No files found.
src/Titanium.Web.Proxy/Helpers/HttpWriter.cs
View file @
a9412640
...
...
@@ -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
);
...
...
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