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
c9bbbd19
Commit
c9bbbd19
authored
Jul 20, 2019
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
do not throw exception in fillbuffer (only when it called on an already closed stream)
parent
efae2199
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
19 deletions
+40
-19
MainWindow.xaml.cs
examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml.cs
+9
-0
CustomBufferedStream.cs
....Web.Proxy/StreamExtended/Network/CustomBufferedStream.cs
+31
-19
No files found.
examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml.cs
View file @
c9bbbd19
...
@@ -159,6 +159,11 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -159,6 +159,11 @@ namespace Titanium.Web.Proxy.Examples.Wpf
{
{
e
.
HttpClient
.
Request
.
KeepBody
=
true
;
e
.
HttpClient
.
Request
.
KeepBody
=
true
;
await
e
.
GetRequestBody
();
await
e
.
GetRequestBody
();
if
(
item
==
SelectedSession
)
{
await
Dispatcher
.
InvokeAsync
(
selectedSessionChanged
);
}
}
}
}
}
...
@@ -185,6 +190,10 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -185,6 +190,10 @@ namespace Titanium.Web.Proxy.Examples.Wpf
await
e
.
GetResponseBody
();
await
e
.
GetResponseBody
();
await
Dispatcher
.
InvokeAsync
(()
=>
{
item
.
Update
();
});
await
Dispatcher
.
InvokeAsync
(()
=>
{
item
.
Update
();
});
if
(
item
==
SelectedSession
)
{
await
Dispatcher
.
InvokeAsync
(
selectedSessionChanged
);
}
}
}
}
}
}
}
...
...
src/Titanium.Web.Proxy/StreamExtended/Network/CustomBufferedStream.cs
View file @
c9bbbd19
using
System
;
using
System
;
using
System.Diagnostics
;
using
System.Diagnostics
;
using
System.IO
;
using
System.IO
;
using
System.Net.Sockets
;
using
System.Text
;
using
System.Text
;
using
System.Threading
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
...
@@ -450,7 +451,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
...
@@ -450,7 +451,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
{
{
if
(
closed
)
if
(
closed
)
{
{
return
false
;
throw
new
Exception
(
"Stream is already closed"
)
;
}
}
if
(
bufferLength
>
0
)
if
(
bufferLength
>
0
)
...
@@ -462,17 +463,23 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
...
@@ -462,17 +463,23 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
bufferPos
=
0
;
bufferPos
=
0
;
int
readBytes
=
baseStream
.
Read
(
streamBuffer
,
bufferLength
,
streamBuffer
.
Length
-
bufferLength
);
bool
result
=
false
;
bool
result
=
readBytes
>
0
;
try
if
(
result
)
{
{
OnDataRead
(
streamBuffer
,
bufferLength
,
readBytes
);
int
readBytes
=
baseStream
.
Read
(
streamBuffer
,
bufferLength
,
streamBuffer
.
Length
-
bufferLength
);
bufferLength
+=
readBytes
;
result
=
readBytes
>
0
;
if
(
result
)
{
OnDataRead
(
streamBuffer
,
bufferLength
,
readBytes
);
bufferLength
+=
readBytes
;
}
}
}
else
finally
{
{
closed
=
true
;
if
(!
result
)
throw
new
EndOfStreamException
();
{
closed
=
true
;
}
}
}
return
result
;
return
result
;
...
@@ -488,7 +495,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
...
@@ -488,7 +495,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
{
{
if
(
closed
)
if
(
closed
)
{
{
return
false
;
throw
new
Exception
(
"Stream is already closed"
)
;
}
}
if
(
bufferLength
>
0
)
if
(
bufferLength
>
0
)
...
@@ -506,18 +513,23 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
...
@@ -506,18 +513,23 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
bufferPos
=
0
;
bufferPos
=
0
;
int
readBytes
=
await
baseStream
.
ReadAsync
(
streamBuffer
,
bufferLength
,
bytesToRead
,
cancellationToken
);
bool
result
=
false
;
bool
result
=
readBytes
>
0
;
try
if
(
result
)
{
{
OnDataRead
(
streamBuffer
,
bufferLength
,
readBytes
);
int
readBytes
=
await
baseStream
.
ReadAsync
(
streamBuffer
,
bufferLength
,
bytesToRead
,
cancellationToken
);
bufferLength
+=
readBytes
;
result
=
readBytes
>
0
;
if
(
result
)
{
OnDataRead
(
streamBuffer
,
bufferLength
,
readBytes
);
bufferLength
+=
readBytes
;
}
}
}
else
finally
{
{
closed
=
true
;
if
(!
result
)
{
// do not throw exception here
closed
=
true
;
}
}
}
return
result
;
return
result
;
...
...
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