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
28f78650
Commit
28f78650
authored
Mar 12, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid slowness in demo (uncomment)
parent
5d22fe00
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
39 deletions
+39
-39
ProxyTestController.cs
.../Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
+39
-39
No files found.
Examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
View file @
28f78650
...
@@ -165,31 +165,31 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -165,31 +165,31 @@ namespace Titanium.Web.Proxy.Examples.Basic
// e.MultipartRequestPartSent += MultipartRequestPartSent;
// e.MultipartRequestPartSent += MultipartRequestPartSent;
//}
//}
if
(
e
.
WebSession
.
Request
.
HasBody
)
//
if (e.WebSession.Request.HasBody)
{
//
{
//Get/Set request body bytes
//
//Get/Set request body bytes
var
bodyBytes
=
await
e
.
GetRequestBody
();
//
var bodyBytes = await e.GetRequestBody();
await
e
.
SetRequestBody
(
bodyBytes
);
//
await e.SetRequestBody(bodyBytes);
//Get/Set request body as string
//
//Get/Set request body as string
string
bodyString
=
await
e
.
GetRequestBodyAsString
();
//
string bodyString = await e.GetRequestBodyAsString();
await
e
.
SetRequestBodyString
(
bodyString
);
//
await e.SetRequestBodyString(bodyString);
//requestBodyHistory[e.Id] = bodyString;
//
//requestBodyHistory[e.Id] = bodyString;
}
//
}
//To cancel a request with a custom HTML content
//To cancel a request with a custom HTML content
//Filter URL
//Filter URL
if
(
e
.
WebSession
.
Request
.
RequestUri
.
AbsoluteUri
.
Contains
(
"yahoo.com"
))
//
if (e.WebSession.Request.RequestUri.AbsoluteUri.Contains("yahoo.com"))
{
//
{
e
.
Ok
(
"<!DOCTYPE html>"
+
//
e.Ok("<!DOCTYPE html>" +
"<html><body><h1>"
+
//
"<html><body><h1>" +
"Website Blocked"
+
//
"Website Blocked" +
"</h1>"
+
//
"</h1>" +
"<p>Blocked by titanium web proxy.</p>"
+
//
"<p>Blocked by titanium web proxy.</p>" +
"</body>"
+
//
"</body>" +
"</html>"
);
//
"</html>");
}
//
}
////Redirect example
////Redirect example
//if (e.WebSession.Request.RequestUri.AbsoluteUri.Contains("wikipedia.org"))
//if (e.WebSession.Request.RequestUri.AbsoluteUri.Contains("wikipedia.org"))
...
@@ -219,27 +219,27 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -219,27 +219,27 @@ namespace Titanium.Web.Proxy.Examples.Basic
// var requestBody = requestBodyHistory[e.Id];
// var requestBody = requestBodyHistory[e.Id];
//}
//}
//read response headers
//
//
read response headers
responseHeaderHistory
[
e
.
Id
]
=
e
.
WebSession
.
Response
.
Headers
;
//
responseHeaderHistory[e.Id] = e.WebSession.Response.Headers;
// print out process id of current session
//
//
print out process id of current session
//Console.WriteLine($"PID: {e.WebSession.ProcessId.Value}");
//
//
Console.WriteLine($"PID: {e.WebSession.ProcessId.Value}");
//if (!e.ProxySession.Request.Host.Equals("medeczane.sgk.gov.tr")) return;
//
//
if (!e.ProxySession.Request.Host.Equals("medeczane.sgk.gov.tr")) return;
if
(
e
.
WebSession
.
Request
.
Method
==
"GET"
||
e
.
WebSession
.
Request
.
Method
==
"POST"
)
//
if (e.WebSession.Request.Method == "GET" || e.WebSession.Request.Method == "POST")
{
//
{
if
(
e
.
WebSession
.
Response
.
StatusCode
==
(
int
)
HttpStatusCode
.
OK
)
//
if (e.WebSession.Response.StatusCode == (int)HttpStatusCode.OK)
{
//
{
if
(
e
.
WebSession
.
Response
.
ContentType
!=
null
&&
e
.
WebSession
.
Response
.
ContentType
.
Trim
().
ToLower
().
Contains
(
"text/html"
))
//
if (e.WebSession.Response.ContentType != null && e.WebSession.Response.ContentType.Trim().ToLower().Contains("text/html"))
{
//
{
var
bodyBytes
=
await
e
.
GetResponseBody
();
//
var bodyBytes = await e.GetResponseBody();
await
e
.
SetResponseBody
(
bodyBytes
);
//
await e.SetResponseBody(bodyBytes);
string
body
=
await
e
.
GetResponseBodyAsString
();
//
string body = await e.GetResponseBodyAsString();
await
e
.
SetResponseBodyString
(
body
);
//
await e.SetResponseBodyString(body);
}
//
}
}
//
}
}
//
}
}
}
/// <summary>
/// <summary>
...
...
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