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
e951ce9c
Unverified
Commit
e951ce9c
authored
Oct 06, 2019
by
honfika
Committed by
GitHub
Oct 06, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #641 from justcoding121/master
Another fix for #638
parents
ab36896e
6d5baf39
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
24 deletions
+26
-24
HttpHelper.cs
src/Titanium.Web.Proxy/Helpers/HttpHelper.cs
+1
-1
CustomBufferedStream.cs
....Web.Proxy/StreamExtended/Network/CustomBufferedStream.cs
+25
-23
No files found.
src/Titanium.Web.Proxy/Helpers/HttpHelper.cs
View file @
e951ce9c
...
...
@@ -168,7 +168,7 @@ namespace Titanium.Web.Proxy.Helpers
{
int
peeked
=
await
clientStreamReader
.
PeekBytesAsync
(
buffer
,
i
,
i
,
lengthToCheck
-
i
,
cancellationToken
);
if
(
peeked
==
0
)
return
-
1
;
return
-
1
;
peeked
+=
i
;
...
...
src/Titanium.Web.Proxy/StreamExtended/Network/CustomBufferedStream.cs
View file @
e951ce9c
...
...
@@ -248,23 +248,22 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// <returns></returns>
public
async
Task
<
int
>
PeekByteAsync
(
int
index
,
CancellationToken
cancellationToken
=
default
)
{
if
(
Available
<=
index
)
{
await
FillBufferAsync
(
cancellationToken
);
}
// When index is greater than the buffer size
if
(
streamBuffer
.
Length
<=
index
)
{
throw
new
Exception
(
"Requested Peek index exceeds the buffer size. Consider increasing the buffer size."
);
}
// When index is greater than the buffer size
if
(
Available
<=
index
)
while
(
Available
<=
index
)
{
return
-
1
;
// When index is greater than the buffer size
bool
fillResult
=
await
FillBufferAsync
(
cancellationToken
);
if
(!
fillResult
)
{
return
-
1
;
}
}
return
streamBuffer
[
bufferPos
+
index
];
}
...
...
@@ -279,24 +278,27 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// <returns></returns>
public
async
Task
<
int
>
PeekBytesAsync
(
byte
[]
buffer
,
int
offset
,
int
index
,
int
count
,
CancellationToken
cancellationToken
=
default
)
{
if
(
Available
<=
index
)
// When index is greater than the buffer size
if
(
streamBuffer
.
Length
<=
index
+
count
)
{
await
FillBufferAsync
(
cancellationToken
);
throw
new
Exception
(
"Requested Peek index and size exceeds the buffer size. Consider increasing the buffer size."
);
}
// When index is greater than the buffer size
if
(
streamBuffer
.
Length
<=
(
index
+
count
))
while
(
Available
<=
index
)
{
throw
new
Exception
(
"Requested Peek index and size exceeds the buffer size. Consider increasing the buffer size."
);
bool
fillResult
=
await
FillBufferAsync
(
cancellationToken
);
if
(!
fillResult
)
{
return
0
;
}
}
if
(
Available
<=
(
index
+
count
)
)
if
(
Available
-
index
<
count
)
{
return
-
1
;
count
=
Available
-
index
;
}
Buffer
.
BlockCopy
(
streamBuffer
,
index
,
buffer
,
offset
,
count
);
return
count
;
}
...
...
@@ -516,6 +518,12 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
throw
new
Exception
(
"Stream is already closed"
);
}
int
bytesToRead
=
streamBuffer
.
Length
-
bufferLength
;
if
(
bytesToRead
==
0
)
{
return
false
;
}
if
(
bufferLength
>
0
)
{
// normally we fill the buffer only when it is empty, but sometimes we need more data
...
...
@@ -523,12 +531,6 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
Buffer
.
BlockCopy
(
streamBuffer
,
bufferPos
,
streamBuffer
,
0
,
bufferLength
);
}
int
bytesToRead
=
streamBuffer
.
Length
-
bufferLength
;
if
(
bytesToRead
==
0
)
{
return
false
;
}
bufferPos
=
0
;
bool
result
=
false
;
...
...
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