void reqReader_HTTPRequestCaptured(object sender, HTTPReaderEventArgs e) { TCPStreamMonitorStack tsStack = GetStackForMonitor((NetworkStreamMonitor)sender); if (tsStack == null) { InvokeExceptionThrown(new InvalidOperationException("HTTP monitor captured a HTTP response from a stack which was already destroyed.")); return; } HTTPConversation hcConversation = dictConversations[tsStack]; hcConversation.AddRequest((HTTPRequest)e.HTTPMessage); if (dictResponses[tsStack].Count > 0) { HTTPRequest htqr = GetNextRequest(hcConversation); if (htqr != null) { htqr.Response = dictResponses[tsStack].Dequeue(); } } InvokeExternalAsync(HTTPSessionInformationChanged, new HTTPMonitorEventArgs(hcConversation)); }
void respReader_HTTPResponseCaptured(object sender, HTTPReaderEventArgs e) { TCPStreamMonitorStack tsStack = GetStackForMonitor((NetworkStreamMonitor)sender); if (tsStack == null) { InvokeExceptionThrown(new InvalidOperationException(this.Name + "captured a HTTP response from a stack which was already destroyed.")); return; } HTTPConversation hcConversation = dictConversations[tsStack]; HTTPRequest htqr = GetNextRequest(hcConversation); if (htqr == null) { //Request missing for response dictResponses[tsStack].Enqueue((HTTPResponse)e.HTTPMessage); } else { htqr.Response = (HTTPResponse)e.HTTPMessage; } InvokeExternalAsync(HTTPSessionInformationChanged, new HTTPMonitorEventArgs(hcConversation)); }
HTTPRequest GetNextRequest(HTTPConversation httpConversation) { foreach (HTTPRequest htrq in httpConversation.Requests) { if (htrq.Response == null) { return(htrq); } } return(null); }
/// <summary> /// Creates a new instance of this class /// </summary> /// <param name="siItem">The information associated with the event</param> public HTTPMonitorEventArgs(HTTPConversation siItem) { this.siItem = siItem; }