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
4633f88f
Commit
4633f88f
authored
Jan 04, 2016
by
titanium007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
close connection each request
parent
dfc356cd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
12 deletions
+14
-12
TcpConnectionManager.cs
Titanium.Web.Proxy/Http/TcpConnectionManager.cs
+10
-9
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+4
-3
No files found.
Titanium.Web.Proxy/Http/TcpConnectionManager.cs
View file @
4633f88f
...
@@ -20,7 +20,7 @@ namespace Titanium.Web.Proxy.Http
...
@@ -20,7 +20,7 @@ namespace Titanium.Web.Proxy.Http
internal
class
TcpConnectionManager
internal
class
TcpConnectionManager
{
{
static
ConcurrentDictionary
<
string
,
ConcurrentStack
<
TcpConnection
>>
ConnectionCache
=
new
ConcurrentDictionary
<
string
,
Concurrent
Stack
<
TcpConnection
>>();
static
Dictionary
<
string
,
Stack
<
TcpConnection
>>
ConnectionCache
=
new
Dictionary
<
string
,
Stack
<
TcpConnection
>>();
public
static
TcpConnection
GetClient
(
string
Hostname
,
int
port
,
bool
IsSecure
)
public
static
TcpConnection
GetClient
(
string
Hostname
,
int
port
,
bool
IsSecure
)
{
{
...
@@ -28,17 +28,18 @@ namespace Titanium.Web.Proxy.Http
...
@@ -28,17 +28,18 @@ namespace Titanium.Web.Proxy.Http
TcpConnection
client
;
TcpConnection
client
;
lock
(
ConnectionCache
)
lock
(
ConnectionCache
)
{
{
Concurrent
Stack
<
TcpConnection
>
connections
;
Stack
<
TcpConnection
>
connections
;
if
(!
ConnectionCache
.
TryGetValue
(
key
,
out
connections
))
if
(!
ConnectionCache
.
TryGetValue
(
key
,
out
connections
))
{
{
return
CreateClient
(
Hostname
,
port
,
IsSecure
);
return
CreateClient
(
Hostname
,
port
,
IsSecure
);
}
}
if
(
connections
.
Count
>
0
)
if
(!
connections
.
TryPop
(
out
client
))
{
{
return
CreateClient
(
Hostname
,
port
,
IsSecure
);
client
=
connections
.
Pop
(
);
}
}
else
return
CreateClient
(
Hostname
,
port
,
IsSecure
);
}
}
return
client
;
return
client
;
}
}
...
@@ -73,13 +74,13 @@ namespace Titanium.Web.Proxy.Http
...
@@ -73,13 +74,13 @@ namespace Titanium.Web.Proxy.Http
var
key
=
string
.
Concat
(
Hostname
,
":"
,
port
,
":"
,
IsSecure
);
var
key
=
string
.
Concat
(
Hostname
,
":"
,
port
,
":"
,
IsSecure
);
lock
(
ConnectionCache
)
lock
(
ConnectionCache
)
{
{
Concurrent
Stack
<
TcpConnection
>
connections
;
Stack
<
TcpConnection
>
connections
;
if
(!
ConnectionCache
.
TryGetValue
(
key
,
out
connections
))
if
(!
ConnectionCache
.
TryGetValue
(
key
,
out
connections
))
{
{
connections
=
new
Concurrent
Stack
<
TcpConnection
>();
connections
=
new
Stack
<
TcpConnection
>();
connections
.
Push
(
Client
);
connections
.
Push
(
Client
);
ConnectionCache
.
Try
Add
(
key
,
connections
);
ConnectionCache
.
Add
(
key
,
connections
);
}
}
connections
.
Push
(
Client
);
connections
.
Push
(
Client
);
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
4633f88f
...
@@ -247,9 +247,10 @@ namespace Titanium.Web.Proxy
...
@@ -247,9 +247,10 @@ namespace Titanium.Web.Proxy
Dispose
(
client
,
clientStream
,
clientStreamReader
,
clientStreamWriter
,
args
);
Dispose
(
client
,
clientStream
,
clientStreamReader
,
clientStreamWriter
,
args
);
return
;
return
;
}
}
args
.
ProxySession
.
ProxyClient
.
Client
.
Close
();
//if (args.ProxySession.ProxyClient.Client.Connected)
// if (args.ProxySession.ProxyClient.Client.Connected)
// TcpConnectionManager.AddClient(args.ProxySession.Request.RequestUri.Host, args.ProxySession.Request.RequestUri.Port, args.IsHttps, args.ProxySession.ProxyClient);
// TcpConnectionManager.AddClient(args.ProxySession.Request.RequestUri.Host, args.ProxySession.Request.RequestUri.Port, args.IsHttps, args.ProxySession.ProxyClient);
// // read the next request
// // read the next request
httpCmd
=
clientStreamReader
.
ReadLine
();
httpCmd
=
clientStreamReader
.
ReadLine
();
...
...
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