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
8fa9ebd3
Unverified
Commit
8fa9ebd3
authored
Nov 22, 2019
by
honfika
Committed by
GitHub
Nov 22, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #677 from justcoding121/master
beta
parents
a994cb31
0366b348
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
4 deletions
+43
-4
TcpConnectionFactory.cs
src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+32
-1
ProxyServer.cs
src/Titanium.Web.Proxy/ProxyServer.cs
+6
-0
RequestHandler.cs
src/Titanium.Web.Proxy/RequestHandler.cs
+5
-3
No files found.
src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
8fa9ebd3
...
...
@@ -348,7 +348,38 @@ retry:
tcpClient
.
Client
.
SetSocketOption
(
SocketOptionLevel
.
Socket
,
SocketOptionName
.
ReuseAddress
,
true
);
}
await
tcpClient
.
ConnectAsync
(
ipAddress
,
port
);
var
connectTask
=
tcpClient
.
ConnectAsync
(
ipAddress
,
port
);
await
Task
.
WhenAny
(
connectTask
,
Task
.
Delay
(
proxyServer
.
ConnectTimeOutSeconds
*
1000
));
if
(!
connectTask
.
IsCompleted
||
!
tcpClient
.
Connected
)
{
// here we can just do some cleanup and let the loop continue since
// we will either get a connection or wind up with a null tcpClient
// which will throw
try
{
connectTask
.
Dispose
();
}
catch
{
// ignore
}
try
{
#if NET45
tcpClient
?.
Close
();
#else
tcpClient
?.
Dispose
();
#endif
tcpClient
=
null
;
}
catch
{
// ignore
}
continue
;
}
break
;
}
catch
(
Exception
e
)
...
...
src/Titanium.Web.Proxy/ProxyServer.cs
View file @
8fa9ebd3
...
...
@@ -196,6 +196,12 @@ namespace Titanium.Web.Proxy
/// </summary>
public
int
ConnectionTimeOutSeconds
{
get
;
set
;
}
=
60
;
/// <summary>
/// Seconds server connection are to wait for connection to be established.
/// Default value is 20 seconds.
/// </summary>
public
int
ConnectTimeOutSeconds
{
get
;
set
;
}
=
20
;
/// <summary>
/// Maximum number of concurrent connections per remote host in cache.
/// Only valid when connection pooling is enabled.
...
...
src/Titanium.Web.Proxy/RequestHandler.cs
View file @
8fa9ebd3
...
...
@@ -257,6 +257,8 @@ namespace Titanium.Web.Proxy
TcpServerConnection
?
serverConnection
,
SslApplicationProtocol
sslApplicationProtocol
,
CancellationToken
cancellationToken
,
CancellationTokenSource
cancellationTokenSource
)
{
args
.
HttpClient
.
Request
.
Locked
=
true
;
// a connection generator task with captured parameters via closure.
Func
<
Task
<
TcpServerConnection
>>
generator
=
()
=>
tcpConnectionFactory
.
GetServerConnection
(
this
,
args
,
isConnect
:
false
,
...
...
@@ -266,6 +268,9 @@ namespace Titanium.Web.Proxy
// for connection pool, retry fails until cache is exhausted.
return
await
retryPolicy
<
ServerConnectionException
>().
ExecuteAsync
(
async
(
connection
)
=>
{
// set the connection and send request headers
args
.
HttpClient
.
SetConnection
(
connection
);
args
.
TimeLine
[
"Connection Ready"
]
=
DateTime
.
Now
;
if
(
args
.
HttpClient
.
Request
.
UpgradeToWebSocket
)
...
...
@@ -290,12 +295,9 @@ namespace Titanium.Web.Proxy
{
var
cancellationToken
=
args
.
CancellationTokenSource
.
Token
;
var
request
=
args
.
HttpClient
.
Request
;
request
.
Locked
=
true
;
var
body
=
request
.
CompressBodyAndUpdateContentLength
();
// set the connection and send request headers
args
.
HttpClient
.
SetConnection
(
connection
);
await
args
.
HttpClient
.
SendRequest
(
Enable100ContinueBehaviour
,
args
.
IsTransparent
,
cancellationToken
);
...
...
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