private static Hashtable getTimings(SessionTimers oTimers, bool bUseV1dot2Format) { Hashtable hashtable = new Hashtable(); hashtable.Add("blocked", -1); hashtable.Add("dns", oTimers.DNSTime); hashtable.Add("connect", oTimers.TCPConnectTime + oTimers.HTTPSHandshakeTime); if (bUseV1dot2Format) { hashtable.Add("ssl", oTimers.HTTPSHandshakeTime); } hashtable.Add("send", Math.Max(0.0, Math.Round((oTimers.ServerGotRequest - oTimers.FiddlerBeginRequest).TotalMilliseconds))); hashtable.Add("wait", Math.Max(0.0, Math.Round((oTimers.ServerBeginResponse - oTimers.ServerGotRequest).TotalMilliseconds))); hashtable.Add("receive", Math.Max(0.0, Math.Round((oTimers.ServerDoneResponse - oTimers.ServerBeginResponse).TotalMilliseconds))); return(hashtable); }
private static Timings GetTimings(SessionTimers timers) { var timings = new Timings { blocked = -1, dns = timers.DNSTime, connect = timers.TCPConnectTime + timers.HTTPSHandshakeTime, ssl = timers.HTTPSHandshakeTime }; TimeSpan span = timers.ServerGotRequest - timers.FiddlerBeginRequest; timings.send = (int)Math.Max(0.0, Math.Round(span.TotalMilliseconds)); TimeSpan span2 = timers.ServerBeginResponse - timers.ServerGotRequest; timings.wait = (int)Math.Max(0.0, Math.Round(span2.TotalMilliseconds)); TimeSpan span3 = timers.ServerDoneResponse - timers.ServerBeginResponse; timings.receive = (int)Math.Max(0.0, Math.Round(span3.TotalMilliseconds)); return(timings); }
private static List <Session> GetSessionsFromStreams(TCPStream tcpsClient, TCPStream tcpsServer) { StringBuilder stringBuilder = null; if (PacketCaptureImport.bVerboseDebug) { stringBuilder = new StringBuilder(); } if (stringBuilder != null) { stringBuilder.AppendFormat("Connection {0}\nREQUEST\n", tcpsClient.sStreamID); } MemoryStream payloadStream = tcpsClient.GetPayloadStream(stringBuilder, 0); if (stringBuilder != null) { stringBuilder.AppendFormat("\nRESPONSE\n", new object[0]); } MemoryStream memoryStream; if (tcpsServer != null) { memoryStream = tcpsServer.GetPayloadStream(stringBuilder, 0); } else { memoryStream = new MemoryStream(); } payloadStream.Position = 0L; memoryStream.Position = 0L; List <Session> list = new List <Session>(); int num = 0; bool flag; do { string text = null; SessionTimers sessionTimers = new SessionTimers(); sessionTimers.ClientConnected = tcpsClient.dtConnectStart; if (tcpsServer != null) { sessionTimers.ServerConnected = tcpsServer.dtConnectStart; } sessionTimers.ClientBeginRequest = tcpsClient.GetTimestampAtByte((int)payloadStream.Position); HTTPRequestHeaders hTTPRequestHeaders; byte[] array; flag = Parser.TakeRequest(payloadStream, out hTTPRequestHeaders, out array); sessionTimers.ClientDoneRequest = tcpsClient.GetTimestampAtByte((int)payloadStream.Position - 1); if (flag) { num++; HTTPResponseHeaders hTTPResponseHeaders = null; byte[] emptyByteArray = Utilities.emptyByteArray; bool flag2 = false; if (tcpsServer != null) { sessionTimers.ServerBeginResponse = tcpsServer.GetTimestampAtByte((int)memoryStream.Position); flag2 = Parser.TakeResponse(memoryStream, hTTPRequestHeaders.HTTPMethod, out hTTPResponseHeaders, out emptyByteArray); } if (flag2) { while (flag2 && hTTPResponseHeaders.HTTPResponseCode > 99 && hTTPResponseHeaders.HTTPResponseCode < 200) { text = text + "Eating a HTTP/" + hTTPResponseHeaders.HTTPResponseCode.ToString() + " message from the stream."; flag2 = Parser.TakeResponse(memoryStream, hTTPRequestHeaders.HTTPMethod, out hTTPResponseHeaders, out emptyByteArray); } sessionTimers.ServerDoneResponse = tcpsServer.GetTimestampAtByte((int)memoryStream.Position - 1); } else { hTTPResponseHeaders = Parser.ParseResponse("HTTP/1.1 0 FIDDLER GENERATED - RESPONSE DATA WAS MISSING\r\n\r\n"); } Session session = new Session(hTTPRequestHeaders, array); session.oResponse.headers = hTTPResponseHeaders; session.responseBodyBytes = emptyByteArray; session.oFlags["X-EgressPort"] = (session.oFlags["X-ClientPort"] = tcpsClient.tcpEndpoints.iSrcPort.ToString()); session.oFlags["X-ClientIP"] = tcpsClient.tcpEndpoints.addrSrc.ToString(); session.oFlags["X-HostIP"] = tcpsClient.tcpEndpoints.addrDst.ToString(); session.oFlags["X-HostPort"] = tcpsClient.tcpEndpoints.iDstPort.ToString(); if (!string.IsNullOrEmpty(text)) { session.oFlags["x-fiddler-streaming"] = text; } session.Timers = sessionTimers; if (num > 1) { session.UNSTABLE_SetBitFlag((SessionFlags)24, true); } string sProcessInfo = tcpsClient.sProcessInfo; if (!string.IsNullOrEmpty(sProcessInfo)) { session.oFlags["X-ProcessInfo"] = sProcessInfo; } if (stringBuilder != null) { session.oFlags["X-ConnectionDebugInfo"] = stringBuilder.ToString(); } list.Add(session); } }while (flag); return(list); }