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
4febcb05
Commit
4febcb05
authored
Nov 30, 2019
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
less exceptions
parent
4f43bd16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
216 additions
and
63 deletions
+216
-63
ProxyTestController.cs
.../Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
+1
-1
ExplicitClientHandler.cs
src/Titanium.Web.Proxy/ExplicitClientHandler.cs
+22
-19
HttpStream.cs
src/Titanium.Web.Proxy/Helpers/HttpStream.cs
+171
-23
NullWriter.cs
src/Titanium.Web.Proxy/Helpers/NullWriter.cs
+20
-20
Net45Compatibility.cs
src/Titanium.Web.Proxy/Net45Compatibility.cs
+2
-0
No files found.
examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
View file @
4febcb05
...
@@ -26,7 +26,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -26,7 +26,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
{
{
proxyServer
=
new
ProxyServer
();
proxyServer
=
new
ProxyServer
();
proxyServer
.
EnableHttp2
=
true
;
//
proxyServer.EnableHttp2 = true;
// generate root certificate without storing it in file system
// generate root certificate without storing it in file system
//proxyServer.CertificateManager.CreateRootCertificate(false);
//proxyServer.CertificateManager.CreateRootCertificate(false);
...
...
src/Titanium.Web.Proxy/ExplicitClientHandler.cs
View file @
4febcb05
...
@@ -141,26 +141,29 @@ namespace Titanium.Web.Proxy
...
@@ -141,26 +141,29 @@ namespace Titanium.Web.Proxy
bool
http2Supported
=
false
;
bool
http2Supported
=
false
;
var
alpn
=
clientHelloInfo
.
GetAlpn
();
if
(
EnableHttp2
)
if
(
alpn
!=
null
&&
alpn
.
Contains
(
SslApplicationProtocol
.
Http2
))
{
{
// test server HTTP/2 support
var
alpn
=
clientHelloInfo
.
GetAlpn
();
try
if
(
alpn
!=
null
&&
alpn
.
Contains
(
SslApplicationProtocol
.
Http2
))
{
// todo: this is a hack, because Titanium does not support HTTP protocol changing currently
var
connection
=
await
tcpConnectionFactory
.
GetServerConnection
(
this
,
connectArgs
,
true
,
SslExtensions
.
Http2ProtocolAsList
,
true
,
cancellationToken
);
http2Supported
=
connection
.
NegotiatedApplicationProtocol
==
SslApplicationProtocol
.
Http2
;
// release connection back to pool instead of closing when connection pool is enabled.
await
tcpConnectionFactory
.
Release
(
connection
,
true
);
}
catch
(
Exception
)
{
{
// ignore
// test server HTTP/2 support
try
{
// todo: this is a hack, because Titanium does not support HTTP protocol changing currently
var
connection
=
await
tcpConnectionFactory
.
GetServerConnection
(
this
,
connectArgs
,
true
,
SslExtensions
.
Http2ProtocolAsList
,
true
,
cancellationToken
);
http2Supported
=
connection
.
NegotiatedApplicationProtocol
==
SslApplicationProtocol
.
Http2
;
// release connection back to pool instead of closing when connection pool is enabled.
await
tcpConnectionFactory
.
Release
(
connection
,
true
);
}
catch
(
Exception
)
{
// ignore
}
}
}
}
}
...
@@ -274,7 +277,7 @@ namespace Titanium.Web.Proxy
...
@@ -274,7 +277,7 @@ namespace Titanium.Web.Proxy
// If we detected that client tunnel CONNECTs without SSL by checking for empty client hello then
// If we detected that client tunnel CONNECTs without SSL by checking for empty client hello then
// this connection should not be HTTPS.
// this connection should not be HTTPS.
var
connection
=
await
tcpConnectionFactory
.
GetServerConnection
(
this
,
connectArgs
,
var
connection
=
await
tcpConnectionFactory
.
GetServerConnection
(
this
,
connectArgs
,
true
,
SslExtensions
.
Http2ProtocolAsList
,
true
,
null
,
true
,
cancellationToken
);
true
,
cancellationToken
);
try
try
...
...
src/Titanium.Web.Proxy/Helpers/HttpStream.cs
View file @
4febcb05
This diff is collapsed.
Click to expand it.
src/Titanium.Web.Proxy/Helpers/NullWriter.cs
View file @
4febcb05
...
@@ -2,33 +2,33 @@
...
@@ -2,33 +2,33 @@
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Titanium.Web.Proxy.StreamExtended.Network
;
using
Titanium.Web.Proxy.StreamExtended.Network
;
internal
class
NullWriter
:
IHttpStreamWriter
namespace
Titanium.Web.Proxy.Helpers
{
{
public
static
NullWriter
Instance
{
get
;
}
=
new
NullWriter
();
internal
class
NullWriter
:
IHttpStreamWriter
public
void
Write
(
byte
[]
buffer
,
int
offset
,
int
count
)
{
{
}
public
static
NullWriter
Instance
{
get
;
}
=
new
NullWriter
();
#if NET45
public
void
Write
(
byte
[]
buffer
,
int
offset
,
int
count
)
public
async
Task
WriteAsync
(
byte
[]
buffer
,
int
offset
,
int
count
,
CancellationToken
cancellationToken
)
{
{
}
}
public
Task
WriteAsync
(
byte
[]
buffer
,
int
offset
,
int
count
,
CancellationToken
cancellationToken
)
{
#if NET45
return
Net45Compatibility
.
CompletedTask
;
#else
#else
public
Task
WriteAsync
(
byte
[]
buffer
,
int
offset
,
int
count
,
CancellationToken
cancellationToken
)
return
Task
.
CompletedTask
;
{
return
Task
.
CompletedTask
;
}
#endif
#endif
}
public
ValueTask
WriteLineAsync
(
CancellationToken
cancellationToken
=
default
)
public
ValueTask
WriteLineAsync
(
CancellationToken
cancellationToken
=
default
)
{
{
throw
new
System
.
NotImplementedException
();
throw
new
System
.
NotImplementedException
();
}
}
public
ValueTask
WriteLineAsync
(
string
value
,
CancellationToken
cancellationToken
=
default
)
public
ValueTask
WriteLineAsync
(
string
value
,
CancellationToken
cancellationToken
=
default
)
{
{
throw
new
System
.
NotImplementedException
();
throw
new
System
.
NotImplementedException
();
}
}
}
}
}
src/Titanium.Web.Proxy/Net45Compatibility.cs
View file @
4febcb05
...
@@ -10,6 +10,8 @@ namespace Titanium.Web.Proxy
...
@@ -10,6 +10,8 @@ namespace Titanium.Web.Proxy
class
Net45Compatibility
class
Net45Compatibility
{
{
public
static
byte
[]
EmptyArray
=
new
byte
[
0
];
public
static
byte
[]
EmptyArray
=
new
byte
[
0
];
public
static
Task
CompletedTask
=
new
Task
(()
=>
{
});
}
}
}
}
#endif
#endif
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