Unverified Commit 8818a9e2 authored by justcoding121's avatar justcoding121 Committed by GitHub

update example

parent ca08a33d
...@@ -121,10 +121,6 @@ Sample request and response event handlers ...@@ -121,10 +121,6 @@ Sample request and response event handlers
```csharp ```csharp
//To access requestBody from OnResponse handler
private HashSet<SessionEventArgs> requestHistory
= new HashSet<SessionEventArgs>();
private async Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e) private async Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e)
{ {
string hostname = e.WebSession.Request.RequestUri.Host; string hostname = e.WebSession.Request.RequestUri.Host;
...@@ -157,9 +153,8 @@ public async Task OnRequest(object sender, SessionEventArgs e) ...@@ -157,9 +153,8 @@ public async Task OnRequest(object sender, SessionEventArgs e)
await e.SetRequestBodyString(bodyString); await e.SetRequestBodyString(bodyString);
//store request //store request
//so that you can find it from response handler using request Id //so that you can find it from response handler
//You can also use e.UserData to set any user data and access it from response e.UserData = e.WebSession.Request;
requestHistory.Add(e);
} }
//To cancel a request with a custom HTML content //To cancel a request with a custom HTML content
...@@ -203,11 +198,9 @@ public async Task OnResponse(object sender, SessionEventArgs e) ...@@ -203,11 +198,9 @@ public async Task OnResponse(object sender, SessionEventArgs e)
} }
} }
//access request by looking up HashSet //access request from UserData property where we stored it in RequestHandler
if(requestHistory.ContainsKey(e)) var request = (Request)e.UserData;
{
var request = requestHistory[e];
}
} }
/// Allows overriding default certificate validation logic /// Allows overriding default certificate validation logic
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment