Commit 5cfd771b authored by justcoding121's avatar justcoding121 Committed by GitHub

update example without RequestId

parent 61b9715a
...@@ -122,8 +122,8 @@ Sample request and response event handlers ...@@ -122,8 +122,8 @@ Sample request and response event handlers
```csharp ```csharp
//To access requestBody from OnResponse handler //To access requestBody from OnResponse handler
private IDictionary<Guid, string> requestBodyHistory private HashSet<SessionEventArgs> requestHistory
= new ConcurrentDictionary<Guid, string>(); = new HashSet<SessionEventArgs>();
private async Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e) private async Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e)
{ {
...@@ -156,9 +156,10 @@ public async Task OnRequest(object sender, SessionEventArgs e) ...@@ -156,9 +156,10 @@ public async Task OnRequest(object sender, SessionEventArgs e)
string bodyString = await e.GetRequestBodyAsString(); string bodyString = await e.GetRequestBodyAsString();
await e.SetRequestBodyString(bodyString); await e.SetRequestBodyString(bodyString);
//store request Body/request headers etc with request Id as key //store request
//so that you can find it from response handler using request Id //so that you can find it from response handler using request Id
requestBodyHistory[e.Id] = bodyString; //You can also use e.UserData to set any user data and access it from response
requestHistory.Add(e);
} }
//To cancel a request with a custom HTML content //To cancel a request with a custom HTML content
...@@ -202,10 +203,10 @@ public async Task OnResponse(object sender, SessionEventArgs e) ...@@ -202,10 +203,10 @@ public async Task OnResponse(object sender, SessionEventArgs e)
} }
} }
//access request body/request headers etc by looking up using requestId //access request by looking up HashSet
if(requestBodyHistory.ContainsKey(e.Id)) if(requestHistory.ContainsKey(e))
{ {
var requestBody = requestBodyHistory[e.Id]; var request = requestHistory[e];
} }
} }
......
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