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
f221ccaa
Unverified
Commit
f221ccaa
authored
May 12, 2018
by
justcoding121
Committed by
GitHub
May 12, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #438 from justcoding121/master
remove version & connect from cache key
parents
8fdadb17
20921442
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
13 deletions
+9
-13
TcpConnectionFactory.cs
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+6
-9
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+3
-4
No files found.
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
f221ccaa
...
...
@@ -43,22 +43,19 @@ namespace Titanium.Web.Proxy.Network.Tcp
internal
ProxyServer
server
{
get
;
set
;
}
internal
string
GetConnectionCacheKey
(
string
remoteHostName
,
int
remotePort
,
Version
httpVersion
,
bool
isHttps
,
List
<
SslApplicationProtocol
>
applicationProtocols
,
bool
isConnect
,
bool
isHttps
,
List
<
SslApplicationProtocol
>
applicationProtocols
,
ProxyServer
proxyServer
,
IPEndPoint
upStreamEndPoint
,
ExternalProxy
externalProxy
)
{
//http version is ignored since its an application level decision b/w HTTP 1.0/1.1
//also when doing connect request MS Edge browser sends http 1.0 but uses 1.1 after server sends 1.1 its response.
//That can create cache miss for same server connection unneccessarily expecially when prefetcing with Connect.
//http version 2 is separated using applicationProtocols below.
var
cacheKeyBuilder
=
new
StringBuilder
(
$"
{
remoteHostName
}
-
{
remotePort
}
"
+
//when creating Tcp client if isHttps is true then isConnect won't matter
//using {isHttps||isConnect} will prevent getting different cacheKeys
//in Explicit client handler for prefetch and in Request handler
//when checking for changed cache key!
$"-
{
isHttps
}
-
{
isHttps
||
isConnect
}
-"
);
var
cacheKeyBuilder
=
new
StringBuilder
(
$"
{
remoteHostName
}
-
{
remotePort
}
-"
+
//when creating Tcp client isConnect won't matter
$"
{
isHttps
}
-"
);
if
(
applicationProtocols
!=
null
)
{
foreach
(
var
protocol
in
applicationProtocols
)
foreach
(
var
protocol
in
applicationProtocols
.
OrderBy
(
x
=>
x
)
)
{
cacheKeyBuilder
.
Append
(
$"
{
protocol
}
-"
);
}
...
...
@@ -92,7 +89,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
CancellationToken
cancellationToken
)
{
var
cacheKey
=
GetConnectionCacheKey
(
remoteHostName
,
remotePort
,
httpVersion
,
isHttps
,
applicationProtocols
,
isConnect
,
isHttps
,
applicationProtocols
,
proxyServer
,
upStreamEndPoint
,
externalProxy
);
if
(
proxyServer
.
EnableConnectionPool
)
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
f221ccaa
...
...
@@ -192,7 +192,7 @@ namespace Titanium.Web.Proxy
// only gets hit when connection pool is disabled.
// or when prefetch task has a unexpectedly different connection.
if
(
serverConnection
!=
null
&&
(
await
getConnectionCacheKey
(
args
,
false
,
&&
(
await
getConnectionCacheKey
(
args
,
clientConnection
.
NegotiatedApplicationProtocol
)
!=
serverConnection
.
CacheKey
))
{
...
...
@@ -475,7 +475,7 @@ namespace Titanium.Web.Proxy
/// <param name="isConnect">Is this a CONNECT request.</param>
/// <param name="applicationProtocol"></param>
/// <returns></returns>
private
async
Task
<
string
>
getConnectionCacheKey
(
SessionEventArgsBase
args
,
bool
isConnect
,
private
async
Task
<
string
>
getConnectionCacheKey
(
SessionEventArgsBase
args
,
SslApplicationProtocol
applicationProtocol
)
{
List
<
SslApplicationProtocol
>
applicationProtocols
=
null
;
...
...
@@ -497,8 +497,7 @@ namespace Titanium.Web.Proxy
return
tcpConnectionFactory
.
GetConnectionCacheKey
(
args
.
WebSession
.
Request
.
RequestUri
.
Host
,
args
.
WebSession
.
Request
.
RequestUri
.
Port
,
args
.
WebSession
.
Request
.
HttpVersion
,
isHttps
,
applicationProtocols
,
isConnect
,
isHttps
,
applicationProtocols
,
this
,
args
.
WebSession
.
UpStreamEndPoint
??
UpStreamEndPoint
,
customUpStreamProxy
??
(
isHttps
?
UpStreamHttpsProxy
:
UpStreamHttpProxy
));
}
...
...
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