Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

Commit a88c68c

Browse files
committed
Merge pull request #29 from titanium007/release
Breaking Change on Release
2 parents 0cc53a6 + 75d6ba7 commit a88c68c

20 files changed

+797
-480
lines changed

.build/default.ps1

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ if(!$Configuration) { $Configuration = "Release" }
2323
if(!$Version) { $Version = $env:APPVEYOR_BUILD_VERSION }
2424
if(!$Version) { $Version = "1.0.$BuildNumber" }
2525

26+
if(!$Branch) { $Branch = $env:APPVEYOR_REPO_BRANCH }
27+
if(!$Branch) { $Branch = "local" }
28+
if($Branch -eq "release" ) { $Version = "$Version-beta" }
29+
2630
Import-Module "$Here\Common" -DisableNameChecking
2731

2832
$NuGet = Join-Path $SolutionRoot ".nuget\nuget.exe"

README.md

+9-8
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ Sample request and response event handlers
5858
//Test On Request, intercept requests
5959
public void OnRequest(object sender, SessionEventArgs e)
6060
{
61-
Console.WriteLine(e.RequestURL);
62-
61+
Console.WriteLine(e.ProxySession.Request.RequestUrl);
62+
6363
//read request headers
64-
var requestHeaders = e.RequestHeaders;
64+
var requestHeaders = e.ProxySession.Request.RequestHeaders;
6565

66-
if ((e.RequestMethod.ToUpper() == "POST" || e.RequestMethod.ToUpper() == "PUT") && e.RequestContentLength > 0)
66+
if ((e.RequestMethod.ToUpper() == "POST" || e.RequestMethod.ToUpper() == "PUT"))
6767
{
6868
//Get/Set request body bytes
6969
byte[] bodyBytes = e.GetRequestBody();
@@ -78,18 +78,19 @@ Sample request and response event handlers
7878
//To cancel a request with a custom HTML content
7979
//Filter URL
8080
81-
if (e.RequestURL.Contains("google.com"))
81+
if (e.ProxySession.Request.RequestUrl.Contains("google.com"))
8282
{
8383
e.Ok("<!DOCTYPE html><html><body><h1>Website Blocked</h1><p>Blocked by titanium web proxy.</p></body></html>");
8484
}
8585
}
8686

8787
public void OnResponse(object sender, SessionEventArgs e)
8888
{
89-
//read response headers
90-
var responseHeaders = e.ResponseHeaders;
89+
////read response headers
90+
var responseHeaders = e.ProxySession.Response.ResponseHeaders;
91+
9192

92-
if (e.ResponseStatusCode == HttpStatusCode.OK)
93+
if (e.ResponseStatusCode == "200")
9394
{
9495
if (e.ResponseContentType.Trim().ToLower().Contains("text/html"))
9596
{

Titanium.Web.Proxy.Test/App.config

+13
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,17 @@
44
<startup>
55
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
66
</startup>
7+
<runtime>
8+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
9+
<dependentAssembly>
10+
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
11+
<bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" />
12+
</dependentAssembly>
13+
<dependentAssembly>
14+
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
15+
<bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" />
16+
</dependentAssembly>
17+
</assemblyBinding>
18+
</runtime>
19+
720
</configuration>

Titanium.Web.Proxy.Test/ProxyTestController.cs

+14-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Text.RegularExpressions;
23
using Titanium.Web.Proxy.EventArguments;
34

45
namespace Titanium.Web.Proxy.Test
@@ -43,10 +44,10 @@ public void Stop()
4344
//Read browser URL send back to proxy by the injection script in OnResponse event
4445
public void OnRequest(object sender, SessionEventArgs e)
4546
{
46-
Console.WriteLine(e.RequestUrl);
47+
Console.WriteLine(e.ProxySession.Request.Url);
4748

4849
////read request headers
49-
//var requestHeaders = e.RequestHeaders;
50+
//var requestHeaders = e.ProxySession.Request.RequestHeaders;
5051

5152
//if ((e.RequestMethod.ToUpper() == "POST" || e.RequestMethod.ToUpper() == "PUT"))
5253
//{
@@ -63,7 +64,7 @@ public void OnRequest(object sender, SessionEventArgs e)
6364
////To cancel a request with a custom HTML content
6465
////Filter URL
6566

66-
//if (e.RequestURL.Contains("google.com"))
67+
//if (e.ProxySession.Request.RequestUrl.Contains("google.com"))
6768
//{
6869
// e.Ok("<!DOCTYPE html><html><body><h1>Website Blocked</h1><p>Blocked by titanium web proxy.</p></body></html>");
6970
//}
@@ -73,27 +74,19 @@ public void OnRequest(object sender, SessionEventArgs e)
7374
//Insert script to read the Browser URL and send it back to proxy
7475
public void OnResponse(object sender, SessionEventArgs e)
7576
{
77+
7678
////read response headers
77-
//var responseHeaders = e.ResponseHeaders;
78-
79-
80-
//if (e.ResponseStatusCode == HttpStatusCode.OK)
79+
// var responseHeaders = e.ProxySession.Response.ResponseHeaders;
80+
81+
//if (!e.ProxySession.Request.Hostname.Equals("medeczane.sgk.gov.tr")) return;
82+
//if (e.RequestMethod == "GET" || e.RequestMethod == "POST")
8183
//{
82-
// if (e.ResponseContentType.Trim().ToLower().Contains("text/html"))
84+
// if (e.ProxySession.Response.ResponseStatusCode == "200")
8385
// {
84-
// //Get/Set response body bytes
85-
// byte[] responseBodyBytes = e.GetResponseBody();
86-
// e.SetResponseBody(responseBodyBytes);
87-
88-
// //Get response body as string
89-
// string responseBody = e.GetResponseBodyAsString();
90-
91-
// //Modify e.ServerResponse
92-
// Regex rex = new Regex("</body>", RegexOptions.RightToLeft | RegexOptions.IgnoreCase | RegexOptions.Multiline);
93-
// string modified = rex.Replace(responseBody, "<script type =\"text/javascript\">alert('Response was modified by this script!');</script></body>", 1);
94-
95-
// //Set modifed response Html Body
96-
// e.SetResponseBodyString(modified);
86+
// if (e.ProxySession.Response.ContentType.Trim().ToLower().Contains("text/html"))
87+
// {
88+
// string body = e.GetResponseBodyAsString();
89+
// }
9790
// }
9891
//}
9992
}

0 commit comments

Comments
 (0)