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
53a57610
Commit
53a57610
authored
Nov 27, 2016
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#153
Demo how to share items accross same session
parent
fc7e798c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
ProxyTestController.cs
.../Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
+11
-0
SessionEventArgs.cs
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
+6
-0
No files found.
Examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
View file @
53a57610
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Net
;
using
System.Net
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Titanium.Web.Proxy.EventArguments
;
using
Titanium.Web.Proxy.EventArguments
;
...
@@ -10,10 +11,14 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -10,10 +11,14 @@ namespace Titanium.Web.Proxy.Examples.Basic
{
{
private
ProxyServer
proxyServer
;
private
ProxyServer
proxyServer
;
//share requestBody outside handlers
private
Dictionary
<
Guid
,
string
>
requestBodyHistory
;
public
ProxyTestController
()
public
ProxyTestController
()
{
{
proxyServer
=
new
ProxyServer
();
proxyServer
=
new
ProxyServer
();
proxyServer
.
TrustRootCertificate
=
true
;
proxyServer
.
TrustRootCertificate
=
true
;
requestBodyHistory
=
new
Dictionary
<
Guid
,
string
>();
}
}
public
void
StartProxy
()
public
void
StartProxy
()
...
@@ -90,6 +95,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -90,6 +95,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
string
bodyString
=
await
e
.
GetRequestBodyAsString
();
string
bodyString
=
await
e
.
GetRequestBodyAsString
();
await
e
.
SetRequestBodyString
(
bodyString
);
await
e
.
SetRequestBodyString
(
bodyString
);
requestBodyHistory
[
e
.
Id
]
=
bodyString
;
}
}
//To cancel a request with a custom HTML content
//To cancel a request with a custom HTML content
...
@@ -114,6 +120,11 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -114,6 +120,11 @@ namespace Titanium.Web.Proxy.Examples.Basic
//Modify response
//Modify response
public
async
Task
OnResponse
(
object
sender
,
SessionEventArgs
e
)
public
async
Task
OnResponse
(
object
sender
,
SessionEventArgs
e
)
{
{
if
(
requestBodyHistory
.
ContainsKey
(
e
.
Id
))
{
//access request body by looking up the shared dictionary using requestId
var
requestBody
=
requestBodyHistory
[
e
.
Id
];
}
//read response headers
//read response headers
var
responseHeaders
=
e
.
WebSession
.
Response
.
ResponseHeaders
;
var
responseHeaders
=
e
.
WebSession
.
Response
.
ResponseHeaders
;
...
...
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
View file @
53a57610
...
@@ -38,6 +38,12 @@ namespace Titanium.Web.Proxy.EventArguments
...
@@ -38,6 +38,12 @@ namespace Titanium.Web.Proxy.EventArguments
/// </summary>
/// </summary>
internal
ProxyClient
ProxyClient
{
get
;
set
;
}
internal
ProxyClient
ProxyClient
{
get
;
set
;
}
/// <summary>
/// Returns a unique Id for this request/response session
/// same as RequestId of WebSession
/// </summary>
public
Guid
Id
=>
WebSession
.
RequestId
;
//Should we send a rerequest
//Should we send a rerequest
public
bool
ReRequest
public
bool
ReRequest
{
{
...
...
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