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
f02a8bfd
Commit
f02a8bfd
authored
May 29, 2017
by
Jehonathan
Committed by
GitHub
May 29, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #252 from justcoding121/develop
Beta
parents
7b3b1f96
5fb387be
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
38 additions
and
23 deletions
+38
-23
ProxyTestController.cs
.../Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
+1
-2
SessionEventArgs.cs
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
+1
-2
RunTime.cs
Titanium.Web.Proxy/Helpers/RunTime.cs
+8
-7
Request.cs
Titanium.Web.Proxy/Http/Request.cs
+5
-0
CertificateManager.cs
Titanium.Web.Proxy/Network/CertificateManager.cs
+2
-2
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+7
-6
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+11
-2
ResponseHandler.cs
Titanium.Web.Proxy/ResponseHandler.cs
+1
-1
WinAuthHandler.cs
Titanium.Web.Proxy/WinAuthHandler.cs
+2
-1
No files found.
Examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
View file @
f02a8bfd
...
...
@@ -116,8 +116,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
//read request headers
var
requestHeaders
=
e
.
WebSession
.
Request
.
RequestHeaders
;
var
method
=
e
.
WebSession
.
Request
.
Method
.
ToUpper
();
if
(
method
==
"POST"
||
method
==
"PUT"
||
method
==
"PATCH"
)
if
(
e
.
WebSession
.
Request
.
HasBody
)
{
//Get/Set request body bytes
byte
[]
bodyBytes
=
await
e
.
GetRequestBody
();
...
...
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
View file @
f02a8bfd
...
...
@@ -111,8 +111,7 @@ namespace Titanium.Web.Proxy.EventArguments
private
async
Task
ReadRequestBody
()
{
//GET request don't have a request body to read
var
method
=
WebSession
.
Request
.
Method
.
ToUpper
();
if
(
method
!=
"POST"
&&
method
!=
"PUT"
&&
method
!=
"PATCH"
)
if
(!
WebSession
.
Request
.
HasBody
)
{
throw
new
BodyNotFoundException
(
"Request don't have a body. "
+
"Please verify that this request is a Http POST/PUT/PATCH and request "
+
...
...
Titanium.Web.Proxy/Helpers/RunTime.cs
View file @
f02a8bfd
...
...
@@ -7,15 +7,16 @@ namespace Titanium.Web.Proxy.Helpers
/// </summary>
internal
class
RunTime
{
private
static
Lazy
<
bool
>
isMonoRuntime
=
new
Lazy
<
bool
>(()=>
Type
.
GetType
(
"Mono.Runtime"
)
!=
null
);
/// <summary>
///
Checks if current run time is Mono
///
cache for mono runtime check
/// </summary>
/// <returns></returns>
internal
static
bool
IsRunningOnMono
()
{
return
isMonoRuntime
.
Value
;
}
private
static
Lazy
<
bool
>
isRunningOnMono
=
new
Lazy
<
bool
>(()=>
Type
.
GetType
(
"Mono.Runtime"
)
!=
null
);
/// <summary>
/// Is running on Mono?
/// </summary>
internal
static
bool
IsRunningOnMono
=>
isRunningOnMono
.
Value
;
}
}
Titanium.Web.Proxy/Http/Request.cs
View file @
f02a8bfd
...
...
@@ -26,6 +26,11 @@ namespace Titanium.Web.Proxy.Http
/// </summary>
public
Version
HttpVersion
{
get
;
set
;
}
/// <summary>
/// Has request body?
/// </summary>
public
bool
HasBody
=>
Method
==
"POST"
||
Method
==
"PUT"
||
Method
==
"PATCH"
;
/// <summary>
/// Request Http hostanem
/// </summary>
...
...
Titanium.Web.Proxy/Network/CertificateManager.cs
View file @
f02a8bfd
...
...
@@ -39,7 +39,7 @@ namespace Titanium.Web.Proxy.Network
set
{
//For Mono only Bouncy Castle is supported
if
(
RunTime
.
IsRunningOnMono
()
)
if
(
RunTime
.
IsRunningOnMono
)
{
value
=
CertificateEngine
.
BouncyCastle
;
}
...
...
@@ -226,7 +226,7 @@ namespace Titanium.Web.Proxy.Network
/// <returns></returns>
public
bool
TrustRootCertificateAsAdministrator
()
{
if
(
RunTime
.
IsRunningOnMono
()
)
if
(
RunTime
.
IsRunningOnMono
)
{
return
false
;
}
...
...
Titanium.Web.Proxy/ProxyServer.cs
View file @
f02a8bfd
...
...
@@ -348,7 +348,7 @@ namespace Titanium.Web.Proxy
/// <param name="endPoint"></param>
public
void
SetAsSystemHttpProxy
(
ExplicitProxyEndPoint
endPoint
)
{
if
(
RunTime
.
IsRunningOnMono
()
)
if
(
RunTime
.
IsRunningOnMono
)
{
throw
new
Exception
(
"Mono Runtime do not support system proxy settings."
);
}
...
...
@@ -375,7 +375,7 @@ namespace Titanium.Web.Proxy
/// <param name="endPoint"></param>
public
void
SetAsSystemHttpsProxy
(
ExplicitProxyEndPoint
endPoint
)
{
if
(
RunTime
.
IsRunningOnMono
()
)
if
(
RunTime
.
IsRunningOnMono
)
{
throw
new
Exception
(
"Mono Runtime do not support system proxy settings."
);
}
...
...
@@ -416,7 +416,7 @@ namespace Titanium.Web.Proxy
/// </summary>
public
void
DisableSystemHttpProxy
()
{
if
(
RunTime
.
IsRunningOnMono
()
)
if
(
RunTime
.
IsRunningOnMono
)
{
throw
new
Exception
(
"Mono Runtime do not support system proxy settings."
);
}
...
...
@@ -429,7 +429,7 @@ namespace Titanium.Web.Proxy
/// </summary>
public
void
DisableSystemHttpsProxy
()
{
if
(
RunTime
.
IsRunningOnMono
()
)
if
(
RunTime
.
IsRunningOnMono
)
{
throw
new
Exception
(
"Mono Runtime do not support system proxy settings."
);
}
...
...
@@ -442,7 +442,7 @@ namespace Titanium.Web.Proxy
/// </summary>
public
void
DisableAllSystemProxies
()
{
if
(
RunTime
.
IsRunningOnMono
()
)
if
(
RunTime
.
IsRunningOnMono
)
{
throw
new
Exception
(
"Mono Runtime do not support system proxy settings."
);
}
...
...
@@ -474,8 +474,9 @@ namespace Titanium.Web.Proxy
CertificateManager
.
ClearIdleCertificates
(
CertificateCacheTimeOutMinutes
);
if
(!
RunTime
.
IsRunningOnMono
()
)
if
(!
RunTime
.
IsRunningOnMono
)
{
//clear orphaned windows auth states every 2 minutes
WinAuthEndPoint
.
ClearIdleStates
(
2
);
}
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
f02a8bfd
...
...
@@ -322,6 +322,16 @@ namespace Titanium.Web.Proxy
PrepareRequestHeaders
(
args
.
WebSession
.
Request
.
RequestHeaders
,
args
.
WebSession
);
args
.
WebSession
.
Request
.
Host
=
args
.
WebSession
.
Request
.
RequestUri
.
Authority
;
//if win auth is enabled
//we need a cache of request body
//so that we can send it after authentication in WinAuthHandler.cs
if
(
EnableWinAuth
&&
!
RunTime
.
IsRunningOnMono
&&
args
.
WebSession
.
Request
.
HasBody
)
{
await
args
.
GetRequestBody
();
}
//If user requested interception do it
if
(
BeforeRequest
!=
null
)
{
...
...
@@ -461,8 +471,7 @@ namespace Titanium.Web.Proxy
if
(!
args
.
WebSession
.
Request
.
ExpectationFailed
)
{
//If its a post/put/patch request, then read the client html body and send it to server
var
method
=
args
.
WebSession
.
Request
.
Method
.
ToUpper
();
if
(
method
==
"POST"
||
method
==
"PUT"
||
method
==
"PATCH"
)
if
(
args
.
WebSession
.
Request
.
HasBody
)
{
await
SendClientRequestBody
(
args
);
}
...
...
Titanium.Web.Proxy/ResponseHandler.cs
View file @
f02a8bfd
...
...
@@ -38,7 +38,7 @@ namespace Titanium.Web.Proxy
//check for windows authentication
if
(
EnableWinAuth
&&
!
RunTime
.
IsRunningOnMono
()
&&
!
RunTime
.
IsRunningOnMono
&&
args
.
WebSession
.
Response
.
ResponseStatusCode
==
"401"
)
{
var
disposed
=
await
Handle401UnAuthorized
(
args
);
...
...
Titanium.Web.Proxy/WinAuthHandler.cs
View file @
f02a8bfd
...
...
@@ -96,7 +96,8 @@ namespace Titanium.Web.Proxy
//challenge value will start with any of the scheme selected
else
{
scheme
=
authSchemes
.
FirstOrDefault
(
x
=>
authHeader
.
Value
.
StartsWith
(
x
,
StringComparison
.
OrdinalIgnoreCase
));
scheme
=
authSchemes
.
FirstOrDefault
(
x
=>
authHeader
.
Value
.
StartsWith
(
x
,
StringComparison
.
OrdinalIgnoreCase
)
&&
authHeader
.
Value
.
Length
>
x
.
Length
+
1
);
var
serverToken
=
authHeader
.
Value
.
Substring
(
scheme
.
Length
+
1
);
var
clientToken
=
WinAuthHandler
.
GetFinalAuthToken
(
args
.
WebSession
.
Request
.
Host
,
serverToken
,
args
.
Id
);
...
...
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