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
a99ff10a
Commit
a99ff10a
authored
Apr 26, 2019
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show response data as image in test app, try-catch added to http2 test
parent
30920247
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
19 deletions
+47
-19
MainWindow.xaml
examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml
+9
-2
MainWindow.xaml.cs
examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml.cs
+19
-2
CustomBufferedStream.cs
src/StreamExtended/Network/CustomBufferedStream.cs
+2
-4
ExplicitClientHandler.cs
src/Titanium.Web.Proxy/ExplicitClientHandler.cs
+17
-11
No files found.
examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml
View file @
a99ff10a
...
@@ -36,13 +36,20 @@
...
@@ -36,13 +36,20 @@
</ListView>
</ListView>
<TabControl Grid.Column="2" Grid.Row="0">
<TabControl Grid.Column="2" Grid.Row="0">
<TabItem Header="Session">
<TabItem Header="Session">
<Grid
Background="Red"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
</Grid.RowDefinitions>
<TextBox x:Name="TextBoxRequest" Grid.Row="0" />
<TextBox x:Name="TextBoxRequest" Grid.Row="0" />
<TextBox x:Name="TextBoxResponse" Grid.Row="1" />
<TabControl Grid.Row="1">
<TabItem Header="Text">
<TextBox x:Name="TextBoxResponse" />
</TabItem>
<TabItem Header="Image">
<Image x:Name="ImageResponse" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="None" />
</TabItem>
</TabControl>
</Grid>
</Grid>
</TabItem>
</TabItem>
</TabControl>
</TabControl>
...
...
examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml.cs
View file @
a99ff10a
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
using
System.Collections.ObjectModel
;
using
System.IO
;
using
System.Linq
;
using
System.Linq
;
using
System.Net
;
using
System.Net
;
using
System.Text
;
using
System.Text
;
...
@@ -8,6 +9,7 @@ using System.Threading.Tasks;
...
@@ -8,6 +9,7 @@ using System.Threading.Tasks;
using
System.Windows
;
using
System.Windows
;
using
System.Windows.Controls
;
using
System.Windows.Controls
;
using
System.Windows.Input
;
using
System.Windows.Input
;
using
System.Windows.Media.Imaging
;
using
Titanium.Web.Proxy.EventArguments
;
using
Titanium.Web.Proxy.EventArguments
;
using
Titanium.Web.Proxy.Http
;
using
Titanium.Web.Proxy.Http
;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Models
;
...
@@ -297,7 +299,8 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -297,7 +299,8 @@ namespace Titanium.Web.Proxy.Examples.Wpf
var
session
=
SelectedSession
.
HttpClient
;
var
session
=
SelectedSession
.
HttpClient
;
var
request
=
session
.
Request
;
var
request
=
session
.
Request
;
var
data
=
(
request
.
IsBodyRead
?
request
.
Body
:
null
)
??
new
byte
[
0
];
var
fullData
=
(
request
.
IsBodyRead
?
request
.
Body
:
null
)
??
new
byte
[
0
];
var
data
=
fullData
;
bool
truncated
=
data
.
Length
>
truncateLimit
;
bool
truncated
=
data
.
Length
>
truncateLimit
;
if
(
truncated
)
if
(
truncated
)
{
{
...
@@ -313,7 +316,8 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -313,7 +316,8 @@ namespace Titanium.Web.Proxy.Examples.Wpf
TextBoxRequest
.
Text
=
sb
.
ToString
();
TextBoxRequest
.
Text
=
sb
.
ToString
();
var
response
=
session
.
Response
;
var
response
=
session
.
Response
;
data
=
(
response
.
IsBodyRead
?
response
.
Body
:
null
)
??
new
byte
[
0
];
fullData
=
(
response
.
IsBodyRead
?
response
.
Body
:
null
)
??
new
byte
[
0
];
data
=
fullData
;
truncated
=
data
.
Length
>
truncateLimit
;
truncated
=
data
.
Length
>
truncateLimit
;
if
(
truncated
)
if
(
truncated
)
{
{
...
@@ -333,6 +337,19 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -333,6 +337,19 @@ namespace Titanium.Web.Proxy.Examples.Wpf
}
}
TextBoxResponse
.
Text
=
sb
.
ToString
();
TextBoxResponse
.
Text
=
sb
.
ToString
();
try
{
using
(
MemoryStream
stream
=
new
MemoryStream
(
fullData
))
{
ImageResponse
.
Source
=
BitmapFrame
.
Create
(
stream
,
BitmapCreateOptions
.
None
,
BitmapCacheOption
.
OnLoad
);
}
}
catch
{
ImageResponse
.
Source
=
null
;
}
}
}
}
}
}
}
src/StreamExtended/Network/CustomBufferedStream.cs
View file @
a99ff10a
...
@@ -245,8 +245,7 @@ namespace StreamExtended.Network
...
@@ -245,8 +245,7 @@ namespace StreamExtended.Network
{
{
return
-
1
;
return
-
1
;
}
}
return
streamBuffer
[
bufferPos
+
index
];
return
streamBuffer
[
bufferPos
+
index
];
}
}
...
@@ -491,7 +490,7 @@ namespace StreamExtended.Network
...
@@ -491,7 +490,7 @@ namespace StreamExtended.Network
if
(
bufferLength
>
0
)
if
(
bufferLength
>
0
)
{
{
//normally we fill the buffer only when it is empty, but sometimes we need more data
//normally we fill the buffer only when it is empty, but sometimes we need more data
//move the rema
n
ining data to the beginning of the buffer
//move the remaining data to the beginning of the buffer
Buffer
.
BlockCopy
(
streamBuffer
,
bufferPos
,
streamBuffer
,
0
,
bufferLength
);
Buffer
.
BlockCopy
(
streamBuffer
,
bufferPos
,
streamBuffer
,
0
,
bufferLength
);
}
}
...
@@ -516,7 +515,6 @@ namespace StreamExtended.Network
...
@@ -516,7 +515,6 @@ namespace StreamExtended.Network
}
}
return
result
;
return
result
;
}
}
/// <summary>
/// <summary>
...
...
src/Titanium.Web.Proxy/ExplicitClientHandler.cs
View file @
a99ff10a
...
@@ -47,8 +47,7 @@ namespace Titanium.Web.Proxy
...
@@ -47,8 +47,7 @@ namespace Titanium.Web.Proxy
{
{
string
connectHostname
=
null
;
string
connectHostname
=
null
;
TunnelConnectSessionEventArgs
connectArgs
=
null
;
TunnelConnectSessionEventArgs
connectArgs
=
null
;
// Client wants to create a secure tcp tunnel (probably its a HTTPS or Websocket request)
// Client wants to create a secure tcp tunnel (probably its a HTTPS or Websocket request)
if
(
await
HttpHelper
.
IsConnectMethod
(
clientStream
)
==
1
)
if
(
await
HttpHelper
.
IsConnectMethod
(
clientStream
)
==
1
)
{
{
...
@@ -142,15 +141,22 @@ namespace Titanium.Web.Proxy
...
@@ -142,15 +141,22 @@ namespace Titanium.Web.Proxy
if
(
alpn
!=
null
&&
alpn
.
Contains
(
SslApplicationProtocol
.
Http2
))
if
(
alpn
!=
null
&&
alpn
.
Contains
(
SslApplicationProtocol
.
Http2
))
{
{
// test server HTTP/2 support
// test server HTTP/2 support
// todo: this is a hack, because Titanium does not support HTTP protocol changing currently
try
var
connection
=
await
tcpConnectionFactory
.
GetServerConnection
(
this
,
connectArgs
,
{
isConnect
:
true
,
applicationProtocols
:
SslExtensions
.
Http2ProtocolAsList
,
// todo: this is a hack, because Titanium does not support HTTP protocol changing currently
noCache
:
true
,
cancellationToken
:
cancellationToken
);
var
connection
=
await
tcpConnectionFactory
.
GetServerConnection
(
this
,
connectArgs
,
isConnect
:
true
,
applicationProtocols
:
SslExtensions
.
Http2ProtocolAsList
,
http2Supported
=
connection
.
NegotiatedApplicationProtocol
==
SslApplicationProtocol
.
Http2
;
noCache
:
true
,
cancellationToken
:
cancellationToken
);
//release connection back to pool instead of closing when connection pool is enabled.
http2Supported
=
connection
.
NegotiatedApplicationProtocol
==
await
tcpConnectionFactory
.
Release
(
connection
,
true
);
SslApplicationProtocol
.
Http2
;
//release connection back to pool instead of closing when connection pool is enabled.
await
tcpConnectionFactory
.
Release
(
connection
,
true
);
}
catch
(
Exception
ex
)
{
// ignore
}
}
}
if
(
EnableTcpServerConnectionPrefetch
)
if
(
EnableTcpServerConnectionPrefetch
)
...
...
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