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
989b6cad
Commit
989b6cad
authored
Mar 01, 2018
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
do not change headers in transparent mode
parent
f11b6b60
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
19 deletions
+33
-19
SessionEventArgs.cs
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
+3
-1
HttpResponseWriter.cs
Titanium.Web.Proxy/Helpers/HttpResponseWriter.cs
+0
-1
HttpWebClient.cs
Titanium.Web.Proxy/Http/HttpWebClient.cs
+4
-4
ProxyAuthorizationHandler.cs
Titanium.Web.Proxy/ProxyAuthorizationHandler.cs
+1
-0
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+20
-12
ResponseHandler.cs
Titanium.Web.Proxy/ResponseHandler.cs
+5
-1
No files found.
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
View file @
989b6cad
...
...
@@ -96,7 +96,9 @@ namespace Titanium.Web.Proxy.EventArguments
/// </summary>
public
event
EventHandler
<
MultipartRequestPartSentEventArgs
>
MultipartRequestPartSent
;
public
ProxyEndPoint
LocalEndPoint
;
public
ProxyEndPoint
LocalEndPoint
{
get
;
}
public
bool
IsTransparent
=>
LocalEndPoint
is
TransparentProxyEndPoint
;
/// <summary>
/// Constructor to initialize the proxy
...
...
Titanium.Web.Proxy/Helpers/HttpResponseWriter.cs
View file @
989b6cad
...
...
@@ -20,7 +20,6 @@ namespace Titanium.Web.Proxy.Helpers
public
async
Task
WriteResponseAsync
(
Response
response
,
bool
flush
=
true
)
{
await
WriteResponseStatusAsync
(
response
.
HttpVersion
,
response
.
StatusCode
,
response
.
StatusDescription
);
response
.
Headers
.
FixProxyHeaders
();
await
WriteHeadersAsync
(
response
.
Headers
,
flush
);
}
...
...
Titanium.Web.Proxy/Http/HttpWebClient.cs
View file @
989b6cad
...
...
@@ -79,7 +79,7 @@ namespace Titanium.Web.Proxy.Http
/// Prepare and send the http(s) request
/// </summary>
/// <returns></returns>
internal
async
Task
SendRequest
(
bool
enable100ContinueBehaviour
)
internal
async
Task
SendRequest
(
bool
enable100ContinueBehaviour
,
bool
isTransparent
)
{
var
upstreamProxy
=
ServerConnection
.
UpStreamProxy
;
...
...
@@ -89,12 +89,12 @@ namespace Titanium.Web.Proxy.Http
//prepare the request & headers
await
writer
.
WriteLineAsync
(
Request
.
CreateRequestLine
(
Request
.
Method
,
useUpstreamProxy
?
Request
.
OriginalUrl
:
Request
.
RequestUri
.
PathAndQuery
,
useUpstreamProxy
||
isTransparent
?
Request
.
OriginalUrl
:
Request
.
RequestUri
.
PathAndQuery
,
Request
.
HttpVersion
));
//Send Authentication to Upstream proxy if needed
if
(
upstreamProxy
!=
null
if
(
!
isTransparent
&&
upstreamProxy
!=
null
&&
ServerConnection
.
IsHttps
==
false
&&
!
string
.
IsNullOrEmpty
(
upstreamProxy
.
UserName
)
&&
upstreamProxy
.
Password
!=
null
)
...
...
@@ -106,7 +106,7 @@ namespace Titanium.Web.Proxy.Http
//write request headers
foreach
(
var
header
in
Request
.
Headers
)
{
if
(
header
.
Name
!=
KnownHeaders
.
ProxyAuthorization
)
if
(
isTransparent
||
header
.
Name
!=
KnownHeaders
.
ProxyAuthorization
)
{
await
header
.
WriteToStreamAsync
(
writer
);
}
...
...
Titanium.Web.Proxy/ProxyAuthorizationHandler.cs
View file @
989b6cad
...
...
@@ -76,6 +76,7 @@ namespace Titanium.Web.Proxy
response
.
Headers
.
AddHeader
(
KnownHeaders
.
ProxyAuthenticate
,
$"Basic realm=\"
{
ProxyRealm
}
\""
);
response
.
Headers
.
AddHeader
(
KnownHeaders
.
ProxyConnection
,
KnownHeaders
.
ProxyConnectionClose
);
response
.
Headers
.
FixProxyHeaders
();
await
clientStreamWriter
.
WriteResponseAsync
(
response
);
return
response
;
}
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
989b6cad
...
...
@@ -106,8 +106,11 @@ namespace Titanium.Web.Proxy
}
//write back successfull CONNECT response
connectArgs
.
WebSession
.
Response
=
ConnectResponse
.
CreateSuccessfullConnectResponse
(
version
);
await
clientStreamWriter
.
WriteResponseAsync
(
connectArgs
.
WebSession
.
Response
);
var
response
=
ConnectResponse
.
CreateSuccessfullConnectResponse
(
version
);
response
.
Headers
.
FixProxyHeaders
();
connectArgs
.
WebSession
.
Response
=
response
;
await
clientStreamWriter
.
WriteResponseAsync
(
response
);
var
clientHelloInfo
=
await
SslTools
.
PeekClientHello
(
clientStream
);
bool
isClientHello
=
clientHelloInfo
!=
null
;
...
...
@@ -401,14 +404,14 @@ namespace Titanium.Web.Proxy
args
.
ProxyClient
.
ClientStreamWriter
=
clientStreamWriter
;
//proxy authorization check
if
(
httpsConnectHostname
==
null
&&
await
CheckAuthorization
(
clientStreamWriter
,
args
)
==
false
)
if
(
!
args
.
IsTransparent
&&
httpsConnectHostname
==
null
&&
await
CheckAuthorization
(
clientStreamWriter
,
args
)
==
false
)
{
break
;
}
PrepareRequestHeaders
(
args
.
WebSession
.
Request
.
Headers
);
if
(!
isTransparentEndPoint
)
{
PrepareRequestHeaders
(
args
.
WebSession
.
Request
.
Headers
);
args
.
WebSession
.
Request
.
Host
=
args
.
WebSession
.
Request
.
RequestUri
.
Authority
;
}
...
...
@@ -447,6 +450,8 @@ namespace Titanium.Web.Proxy
connection
=
await
GetServerConnection
(
args
,
false
);
}
var
response
=
args
.
WebSession
.
Response
;
//if upgrading to websocket then relay the requet without reading the contents
if
(
args
.
WebSession
.
Request
.
UpgradeToWebSocket
)
{
...
...
@@ -457,13 +462,16 @@ namespace Titanium.Web.Proxy
string
httpStatus
=
await
connection
.
StreamReader
.
ReadLineAsync
();
Response
.
ParseResponseLine
(
httpStatus
,
out
var
responseVersion
,
out
int
responseStatusCode
,
out
string
responseStatusDescription
);
args
.
WebSession
.
R
esponse
.
HttpVersion
=
responseVersion
;
args
.
WebSession
.
R
esponse
.
StatusCode
=
responseStatusCode
;
args
.
WebSession
.
R
esponse
.
StatusDescription
=
responseStatusDescription
;
r
esponse
.
HttpVersion
=
responseVersion
;
r
esponse
.
StatusCode
=
responseStatusCode
;
r
esponse
.
StatusDescription
=
responseStatusDescription
;
await
HeaderParser
.
ReadHeaders
(
connection
.
StreamReader
,
args
.
WebSession
.
R
esponse
.
Headers
);
await
HeaderParser
.
ReadHeaders
(
connection
.
StreamReader
,
r
esponse
.
Headers
);
await
clientStreamWriter
.
WriteResponseAsync
(
args
.
WebSession
.
Response
);
if
(!
args
.
IsTransparent
)
{
await
clientStreamWriter
.
WriteResponseAsync
(
response
);
}
//If user requested call back then do it
if
(
BeforeResponse
!=
null
&&
!
args
.
WebSession
.
Response
.
ResponseLocked
)
...
...
@@ -483,7 +491,7 @@ namespace Titanium.Web.Proxy
await
HandleHttpSessionRequestInternal
(
connection
,
args
);
//if connection is closing exit
if
(
args
.
WebSession
.
R
esponse
.
KeepAlive
==
false
)
if
(
r
esponse
.
KeepAlive
==
false
)
{
break
;
}
...
...
@@ -522,7 +530,7 @@ namespace Titanium.Web.Proxy
if
(
request
.
ExpectContinue
)
{
args
.
WebSession
.
SetConnection
(
connection
);
await
args
.
WebSession
.
SendRequest
(
Enable100ContinueBehaviour
);
await
args
.
WebSession
.
SendRequest
(
Enable100ContinueBehaviour
,
args
.
IsTransparent
);
}
//If 100 continue was the response inform that to the client
...
...
@@ -546,7 +554,7 @@ namespace Titanium.Web.Proxy
if
(!
request
.
ExpectContinue
)
{
args
.
WebSession
.
SetConnection
(
connection
);
await
args
.
WebSession
.
SendRequest
(
Enable100ContinueBehaviour
);
await
args
.
WebSession
.
SendRequest
(
Enable100ContinueBehaviour
,
args
.
IsTransparent
);
}
//check if content-length is > 0
...
...
Titanium.Web.Proxy/ResponseHandler.cs
View file @
989b6cad
...
...
@@ -70,7 +70,11 @@ namespace Titanium.Web.Proxy
//Write back response status to client
await
clientStreamWriter
.
WriteResponseStatusAsync
(
response
.
HttpVersion
,
response
.
StatusCode
,
response
.
StatusDescription
);
response
.
Headers
.
FixProxyHeaders
();
if
(!
args
.
IsTransparent
)
{
response
.
Headers
.
FixProxyHeaders
();
}
if
(
response
.
IsBodyRead
)
{
bool
isChunked
=
response
.
IsChunked
;
...
...
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