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
39d25785
Commit
39d25785
authored
Apr 17, 2016
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
issue #61 , #62 , #59
Fix issues
parent
c16e1c20
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
103 additions
and
63 deletions
+103
-63
App.config
Titanium.Web.Proxy.Test/App.config
+7
-8
ProxyTestController.cs
Titanium.Web.Proxy.Test/ProxyTestController.cs
+20
-9
Titanium.Web.Proxy.Test.csproj
Titanium.Web.Proxy.Test/Titanium.Web.Proxy.Test.csproj
+13
-8
SessionEventArgs.cs
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
+3
-1
TcpExtensions.cs
Titanium.Web.Proxy/Extensions/TcpExtensions.cs
+1
-1
HttpWebClient.cs
Titanium.Web.Proxy/Network/HttpWebClient.cs
+17
-6
TcpConnectionManager.cs
Titanium.Web.Proxy/Network/TcpConnectionManager.cs
+1
-0
ResponseHandler.cs
Titanium.Web.Proxy/ResponseHandler.cs
+10
-4
RedirectResponse.cs
Titanium.Web.Proxy/Responses/RedirectResponse.cs
+0
-6
Titanium.Web.Proxy.csproj
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
+26
-18
packages-Net45.config
Titanium.Web.Proxy/packages-Net45.config
+4
-0
packages.config
Titanium.Web.Proxy/packages.config
+1
-2
No files found.
Titanium.Web.Proxy.Test/App.config
View file @
39d25785
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
configuration
>
<
startup
>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.
0,Profile=Client"
/>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.
5"
/>
</
startup
>
<
runtime
>
<
assemblyBinding
xmlns
=
"urn:schemas-microsoft-com:asm.v1"
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"System.Runtime"
publicKeyToken
=
"b03f5f7f11d50a3a"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-2.6.10.0"
newVersion
=
"2.6.10.0"
/>
<
assemblyIdentity
name
=
"System.Runtime"
publicKeyToken
=
"b03f5f7f11d50a3a"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-2.6.10.0"
newVersion
=
"2.6.10.0"
/>
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"System.Threading.Tasks"
publicKeyToken
=
"b03f5f7f11d50a3a"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-2.6.10.0"
newVersion
=
"2.6.10.0"
/>
<
assemblyIdentity
name
=
"System.Threading.Tasks"
publicKeyToken
=
"b03f5f7f11d50a3a"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-2.6.10.0"
newVersion
=
"2.6.10.0"
/>
</
dependentAssembly
>
</
assemblyBinding
>
</
runtime
>
...
...
Titanium.Web.Proxy.Test/ProxyTestController.cs
View file @
39d25785
...
...
@@ -46,12 +46,9 @@ namespace Titanium.Web.Proxy.Test
Console
.
WriteLine
(
"Listening on '{0}' endpoint at Ip {1} and port: {2} "
,
endPoint
.
GetType
().
Name
,
endPoint
.
IpAddress
,
endPoint
.
Port
);
//You can also add/remove end points after proxy has been started
ProxyServer
.
RemoveEndPoint
(
transparentEndPoint
);
//Only explicit proxies can be set as system proxy!
ProxyServer
.
SetAsSystemHttpProxy
(
explicitEndPoint
);
ProxyServer
.
SetAsSystemHttpsProxy
(
explicitEndPoint
);
//
ProxyServer.SetAsSystemHttpProxy(explicitEndPoint);
//
ProxyServer.SetAsSystemHttpsProxy(explicitEndPoint);
}
public
void
Stop
()
...
...
@@ -85,10 +82,20 @@ namespace Titanium.Web.Proxy.Test
//To cancel a request with a custom HTML content
//Filter URL
if
(
e
.
ProxySession
.
Request
.
RequestUri
.
AbsoluteUri
.
Contains
(
"google.com"
))
{
e
.
Ok
(
"<!DOCTYPE html><html><body><h1>Website Blocked</h1><p>Blocked by titanium web proxy.</p></body></html>"
);
e
.
Ok
(
"<!DOCTYPE html>"
+
"<html><body><h1>"
+
"Website Blocked"
+
"</h1>"
+
"<p>Blocked by titanium web proxy.</p>"
+
"</body>"
+
"</html>"
);
}
//Redirect example
if
(
e
.
ProxySession
.
Request
.
RequestUri
.
AbsoluteUri
.
Contains
(
"wikipedia.org"
))
{
e
.
Redirect
(
"https://www.paypal.com"
);
}
}
...
...
@@ -107,7 +114,11 @@ namespace Titanium.Web.Proxy.Test
{
if
(
e
.
ProxySession
.
Response
.
ContentType
.
Trim
().
ToLower
().
Contains
(
"text/html"
))
{
byte
[]
bodyBytes
=
e
.
GetResponseBody
();
e
.
SetResponseBody
(
bodyBytes
);
string
body
=
e
.
GetResponseBodyAsString
();
e
.
SetResponseBodyString
(
body
);
}
}
}
...
...
Titanium.Web.Proxy.Test/Titanium.Web.Proxy.Test.csproj
View file @
39d25785
...
...
@@ -11,25 +11,28 @@
<RootNamespace>
Titanium.Web.Proxy.Test
</RootNamespace>
<AssemblyName>
Titanium.Web.Proxy.Test
</AssemblyName>
<FileAlignment>
512
</FileAlignment>
<TargetFrameworkProfile
/>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "
>
<DebugSymbols>
true
</DebugSymbols>
<DebugType>
full
</DebugType>
<Optimize>
false
</Optimize>
<OutputPath>
bin\Debug\
</OutputPath>
<DefineConstants>
DEBUG;TRACE
</DefineConstants>
<DefineConstants>
TRACE;DEBUG;NET40
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
<TargetFrameworkVersion>
v4.0
</TargetFrameworkVersion>
<Prefer32Bit>
false
</Prefer32Bit>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "
>
<DebugType>
pdbonly
</DebugType>
<Optimize>
true
</Optimize>
<OutputPath>
bin\Release\
</OutputPath>
<DefineConstants>
TRACE
</DefineConstants>
<DefineConstants>
TRACE
;NET40
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
<TargetFrameworkVersion>
v4.0
</TargetFrameworkVersion>
<Prefer32Bit>
false
</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject
/>
...
...
@@ -37,22 +40,24 @@
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)' == 'Debug-Net45|AnyCPU'"
>
<DebugSymbols>
true
</DebugSymbols>
<OutputPath>
bin\Debug-Net45\
</OutputPath>
<DefineConstants>
DEBUG;TRACE
</DefineConstants>
<DefineConstants>
TRACE;DEBUG;NET45
</DefineConstants>
<DebugType>
full
</DebugType>
<PlatformTarget>
AnyCPU
</PlatformTarget>
<ErrorReport>
prompt
</ErrorReport>
<CodeAnalysisRuleSet>
MinimumRecommendedRules.ruleset
</CodeAnalysisRuleSet>
<TargetFrameworkVersion>
v4.5
</TargetFrameworkVersion>
<Prefer32Bit>
true
</Prefer32Bit>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)' == 'Release-Net45|AnyCPU'"
>
<OutputPath>
bin\Release-Net45\
</OutputPath>
<DefineConstants>
TRACE
</DefineConstants>
<DefineConstants>
TRACE
;NET45
</DefineConstants>
<Optimize>
true
</Optimize>
<DebugType>
pdbonly
</DebugType>
<PlatformTarget>
AnyCPU
</PlatformTarget>
<ErrorReport>
prompt
</ErrorReport>
<CodeAnalysisRuleSet>
MinimumRecommendedRules.ruleset
</CodeAnalysisRuleSet>
<TargetFrameworkVersion>
v4.5
</TargetFrameworkVersion>
<Prefer32Bit>
true
</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"System"
/>
...
...
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
View file @
39d25785
...
...
@@ -393,6 +393,7 @@ namespace Titanium.Web.Proxy.EventArguments
var
response
=
new
RedirectResponse
();
response
.
HttpVersion
=
ProxySession
.
Request
.
HttpVersion
;
response
.
ResponseHeaders
.
Add
(
new
Models
.
HttpHeader
(
"Location"
,
url
));
response
.
ResponseBody
=
Encoding
.
ASCII
.
GetBytes
(
string
.
Empty
);
Respond
(
response
);
...
...
@@ -404,13 +405,14 @@ namespace Titanium.Web.Proxy.EventArguments
public
void
Respond
(
Response
response
)
{
ProxySession
.
Request
.
RequestLocked
=
true
;
ProxySession
.
Response
.
ResponseLocked
=
true
;
response
.
ResponseLocked
=
true
;
response
.
ResponseBodyRead
=
true
;
ProxySession
.
Response
=
response
;
ProxyServer
.
HandleHttpSessionResponse
(
this
);
}
}
}
\ No newline at end of file
Titanium.Web.Proxy/
Network
/TcpExtensions.cs
→
Titanium.Web.Proxy/
Extensions
/TcpExtensions.cs
View file @
39d25785
...
...
@@ -7,7 +7,7 @@ using System.Text;
using
System.Threading.Tasks
;
namespace
Titanium.Web.Proxy.
Network
namespace
Titanium.Web.Proxy.
Extensions
{
internal
static
class
TcpExtensions
...
...
Titanium.Web.Proxy/Network/HttpWebClient.cs
View file @
39d25785
...
...
@@ -100,7 +100,9 @@ namespace Titanium.Web.Proxy.Network
public
string
Url
{
get
{
return
RequestUri
.
OriginalString
;
}
}
internal
Encoding
Encoding
{
get
{
return
this
.
GetEncoding
();
}
}
/// <summary>
/// Terminates the underlying Tcp Connection to client after current request
/// </summary>
internal
bool
CancelRequest
{
get
;
set
;
}
internal
byte
[]
RequestBody
{
get
;
set
;
}
...
...
@@ -248,7 +250,7 @@ namespace Titanium.Web.Proxy.Network
internal
string
ResponseBodyString
{
get
;
set
;
}
internal
bool
ResponseBodyRead
{
get
;
set
;
}
internal
bool
ResponseLocked
{
get
;
set
;
}
public
bool
Is100Continue
{
get
;
internal
set
;
}
public
Response
()
{
...
...
@@ -272,6 +274,7 @@ namespace Titanium.Web.Proxy.Network
public
Response
Response
{
get
;
set
;
}
internal
TcpConnection
ProxyClient
{
get
;
set
;
}
public
void
SetConnection
(
TcpConnection
Connection
)
{
Connection
.
LastAccess
=
DateTime
.
Now
;
...
...
@@ -322,11 +325,19 @@ namespace Titanium.Web.Proxy.Network
var
s
=
ProxyClient
.
ServerStreamReader
.
ReadLine
();
}
this
.
Response
.
HttpVersion
=
httpResult
[
0
];
this
.
Response
.
ResponseStatusCode
=
httpResult
[
1
];
string
status
=
httpResult
[
2
]
;
this
.
Response
.
HttpVersion
=
httpResult
[
0
]
.
Trim
()
;
this
.
Response
.
ResponseStatusCode
=
httpResult
[
1
]
.
Trim
()
;
this
.
Response
.
ResponseStatusDescription
=
httpResult
[
2
].
Trim
()
;
this
.
Response
.
ResponseStatusDescription
=
status
;
if
(
this
.
Response
.
ResponseStatusCode
.
Equals
(
"100"
)
&&
this
.
Response
.
ResponseStatusDescription
.
ToLower
().
Equals
(
"continue"
))
{
this
.
Response
.
Is100Continue
=
true
;
this
.
Response
.
ResponseStatusCode
=
null
;
ProxyClient
.
ServerStreamReader
.
ReadLine
();
ReceiveResponse
();
return
;
}
List
<
string
>
responseLines
=
ProxyClient
.
ServerStreamReader
.
ReadAllLines
();
...
...
Titanium.Web.Proxy/Network/TcpConnectionManager.cs
View file @
39d25785
...
...
@@ -10,6 +10,7 @@ using System.Net.Security;
using
Titanium.Web.Proxy.Helpers
;
using
System.Threading
;
using
System.Security.Authentication
;
using
Titanium.Web.Proxy.Extensions
;
namespace
Titanium.Web.Proxy.Network
{
...
...
Titanium.Web.Proxy/ResponseHandler.cs
View file @
39d25785
...
...
@@ -36,6 +36,16 @@ namespace Titanium.Web.Proxy
args
.
ProxySession
.
Response
.
ResponseLocked
=
true
;
if
(
args
.
ProxySession
.
Response
.
Is100Continue
)
{
WriteResponseStatus
(
args
.
ProxySession
.
Response
.
HttpVersion
,
"100"
,
"Continue"
,
args
.
Client
.
ClientStreamWriter
);
args
.
Client
.
ClientStreamWriter
.
WriteLine
();
}
WriteResponseStatus
(
args
.
ProxySession
.
Response
.
HttpVersion
,
args
.
ProxySession
.
Response
.
ResponseStatusCode
,
args
.
ProxySession
.
Response
.
ResponseStatusDescription
,
args
.
Client
.
ClientStreamWriter
);
if
(
args
.
ProxySession
.
Response
.
ResponseBodyRead
)
{
var
isChunked
=
args
.
ProxySession
.
Response
.
IsChunked
;
...
...
@@ -46,16 +56,12 @@ namespace Titanium.Web.Proxy
args
.
ProxySession
.
Response
.
ResponseBody
=
GetCompressedResponseBody
(
contentEncoding
,
args
.
ProxySession
.
Response
.
ResponseBody
);
}
WriteResponseStatus
(
args
.
ProxySession
.
Response
.
HttpVersion
,
args
.
ProxySession
.
Response
.
ResponseStatusCode
,
args
.
ProxySession
.
Response
.
ResponseStatusDescription
,
args
.
Client
.
ClientStreamWriter
);
WriteResponseHeaders
(
args
.
Client
.
ClientStreamWriter
,
args
.
ProxySession
.
Response
.
ResponseHeaders
,
args
.
ProxySession
.
Response
.
ResponseBody
.
Length
,
isChunked
);
WriteResponseBody
(
args
.
Client
.
ClientStream
,
args
.
ProxySession
.
Response
.
ResponseBody
,
isChunked
);
}
else
{
WriteResponseStatus
(
args
.
ProxySession
.
Response
.
HttpVersion
,
args
.
ProxySession
.
Response
.
ResponseStatusCode
,
args
.
ProxySession
.
Response
.
ResponseStatusDescription
,
args
.
Client
.
ClientStreamWriter
);
WriteResponseHeaders
(
args
.
Client
.
ClientStreamWriter
,
args
.
ProxySession
.
Response
.
ResponseHeaders
);
if
(
args
.
ProxySession
.
Response
.
IsChunked
||
args
.
ProxySession
.
Response
.
ContentLength
>
0
)
...
...
Titanium.Web.Proxy/Responses/RedirectResponse.cs
View file @
39d25785
...
...
@@ -10,12 +10,6 @@ namespace Titanium.Web.Proxy.Responses
{
ResponseStatusCode
=
"302"
;
ResponseStatusDescription
=
"Found"
;
ResponseHeaders
.
Add
(
new
HttpHeader
(
"Timestamp"
,
DateTime
.
Now
.
ToString
()));
ResponseHeaders
.
Add
(
new
HttpHeader
(
"content-length"
,
DateTime
.
Now
.
ToString
()));
ResponseHeaders
.
Add
(
new
HttpHeader
(
"Cache-Control"
,
"no-cache, no-store, must-revalidate"
));
ResponseHeaders
.
Add
(
new
HttpHeader
(
"Pragma"
,
"no-cache"
));
ResponseHeaders
.
Add
(
new
HttpHeader
(
"Expires"
,
"0"
));
}
}
}
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
View file @
39d25785
...
...
@@ -46,11 +46,7 @@
<TargetFrameworkVersion>
v4.5
</TargetFrameworkVersion>
<DefineConstants>
NET45
</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"Ionic.Zip, Version=1.9.7.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL"
>
<SpecificVersion>
False
</SpecificVersion>
<HintPath>
..\packages\DotNetZip.1.9.7\lib\net20\Ionic.Zip.dll
</HintPath>
</Reference>
<ItemGroup
Condition=
"'$(Configuration)' == 'Debug' Or '$(Configuration)' == 'Release'"
>
<Reference
Include=
"Microsoft.Threading.Tasks"
>
<HintPath>
..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll
</HintPath>
</Reference>
...
...
@@ -60,19 +56,25 @@
<Reference
Include=
"Microsoft.Threading.Tasks.Extensions.Desktop"
>
<HintPath>
..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll
</HintPath>
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.configuration"
/>
<Reference
Include=
"System.Core"
/>
<Reference
Include=
"System.IO"
>
<HintPath>
..\packages\Microsoft.Bcl.1.1.10\lib\net40\System.IO.dll
</HintPath>
</Reference>
<Reference
Include=
"System.Net"
/>
<Reference
Include=
"System.Runtime"
>
<HintPath>
..\packages\Microsoft.Bcl.1.1.10\lib\net40\System.Runtime.dll
</HintPath>
</Reference>
<Reference
Include=
"System.Threading.Tasks"
>
<HintPath>
..\packages\Microsoft.Bcl.1.1.10\lib\net40\System.Threading.Tasks.dll
</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference
Include=
"Ionic.Zip, Version=1.9.8.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL"
>
<HintPath>
..\packages\DotNetZip.1.9.8\lib\net20\Ionic.Zip.dll
</HintPath>
<Private>
True
</Private>
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Net"
/>
<Reference
Include=
"System.configuration"
/>
<Reference
Include=
"System.Core"
/>
<Reference
Include=
"System.Xml.Linq"
/>
<Reference
Include=
"System.Data.DataSetExtensions"
/>
<Reference
Include=
"Microsoft.CSharp"
/>
...
...
@@ -99,7 +101,7 @@
<Compile
Include=
"Helpers\Firefox.cs"
/>
<Compile
Include=
"Helpers\SystemProxy.cs"
/>
<Compile
Include=
"Models\EndPoint.cs"
/>
<Compile
Include=
"
Network
\TcpExtensions.cs"
/>
<Compile
Include=
"
Extensions
\TcpExtensions.cs"
/>
<Compile
Include=
"Network\TcpConnectionManager.cs"
/>
<Compile
Include=
"Models\HttpHeader.cs"
/>
<Compile
Include=
"Network\HttpWebClient.cs"
/>
...
...
@@ -107,7 +109,6 @@
<Compile
Include=
"RequestHandler.cs"
/>
<Compile
Include=
"ResponseHandler.cs"
/>
<Compile
Include=
"Helpers\CustomBinaryReader.cs"
/>
<Compile
Include=
"Helpers\Compression.cs"
/>
<Compile
Include=
"ProxyServer.cs"
/>
<Compile
Include=
"EventArguments\SessionEventArgs.cs"
/>
<Compile
Include=
"Helpers\Tcp.cs"
/>
...
...
@@ -118,7 +119,14 @@
<ItemGroup
/>
<ItemGroup>
<None
Include=
"app.config"
/>
<None
Include=
"packages.config"
/>
</ItemGroup>
<ItemGroup
Condition=
"'$(Configuration)' == 'Debug' Or '$(Configuration)' == 'Release'"
>
<None
Include=
"packages.config"
>
<SubType>
Designer
</SubType>
</None>
</ItemGroup>
<ItemGroup
Condition=
"'$(Configuration)' == 'Debug-Net45' Or '$(Configuration)' == 'Release-Net45'"
>
<None
Include=
"packages-Net45.config"
/>
</ItemGroup>
<ItemGroup>
<None
Include=
"makecert.exe"
>
...
...
Titanium.Web.Proxy/packages-Net45.config
0 → 100644
View file @
39d25785
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"DotNetZip"
version
=
"1.9.8"
targetFramework
=
"net45"
/>
</
packages
>
\ No newline at end of file
Titanium.Web.Proxy/packages.config
View file @
39d25785
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"DotNetZip"
version
=
"1.9.7"
targetFramework
=
"net40"
/>
<
package
id
=
"DotNetZip"
version
=
"1.9.7"
targetFramework
=
"net45"
/>
<
package
id
=
"DotNetZip"
version
=
"1.9.8"
targetFramework
=
"net40"
/>
<
package
id
=
"Microsoft.Bcl"
version
=
"1.1.10"
targetFramework
=
"net40"
/>
<
package
id
=
"Microsoft.Bcl.Async"
version
=
"1.0.168"
targetFramework
=
"net40"
/>
<
package
id
=
"Microsoft.Bcl.Build"
version
=
"1.0.14"
targetFramework
=
"net40"
/>
...
...
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