public SessionData(Session oS) { MemoryStream oFS = new MemoryStream(); oS.WriteRequestToStream(false, true, oFS); this.arrRequest = oFS.ToArray(); oFS = new MemoryStream(); oS.WriteResponseToStream(oFS, false); this.arrResponse = oFS.ToArray(); oFS = new MemoryStream(); oS.WriteMetadataToStream(oFS); this.arrMetadata = oFS.ToArray(); oFS = new MemoryStream(); oS.WriteWebSocketMessagesToStream(oFS); this.arrWebSocketMessages = oFS.ToArray(); }
// This is a refactored helper function which writes a single session to an open SAZ file. internal static void WriteSessionToSAZ(Session oSession, DiskFile odfZip, int iFileNumber, string sFileNumberFormatter, StringBuilder sbHTML, bool bDisplayErrorMessages) { string sBaseFilename = @"raw\" + iFileNumber.ToString(sFileNumberFormatter); string sRequestFilename = sBaseFilename + "_c.txt"; string sResponseFilename = sBaseFilename + "_s.txt"; string sMetadataFilename = sBaseFilename + "_m.xml"; // Write the Request to the Archive try { ZippedFile o = new ZippedFile(odfZip, sRequestFilename); Stream oS = o.CreateWrite(FileShare.None); oSession.WriteRequestToStream(false, true, oS); oS.Close(); } catch (Exception eX) { if (bDisplayErrorMessages) { FiddlerApplication.Log.LogString("Archive Failure: Unable to add " + sRequestFilename + "\n\n" + eX.Message); } } // Write the Response to the Archive try { ZippedFile o = new ZippedFile(odfZip, sResponseFilename); Stream oS = o.CreateWrite(FileShare.None); oSession.WriteResponseToStream(oS, false); oS.Close(); } catch (Exception eX) { if (bDisplayErrorMessages) { FiddlerApplication.Log.LogString("Archive Failure: Unable to add " + sResponseFilename + "\n\n" + eX.Message); } } // Write the MetaData to the Archive try { ZippedFile o = new ZippedFile(odfZip, sMetadataFilename); Stream oS = o.CreateWrite(FileShare.None); oSession.WriteMetadataToStream(oS); oS.Close(); } catch (Exception eX) { if (bDisplayErrorMessages) { FiddlerApplication.Log.LogString("Archive Failure: Unable to add " + sMetadataFilename + "\n\n" + eX.Message); } } #region AddIndexHTMLEntry if (null != sbHTML) { sbHTML.Append("<tr>"); sbHTML.Append("<TD><a href='" + sRequestFilename + "'>C</a> "); sbHTML.Append("<a href='" + sResponseFilename + "'>S</a> "); sbHTML.Append("<a href='" + sMetadataFilename + "'>M</a></TD>"); sbHTML.Append("</tr>"); } #endregion AddIndexHTMLEntry }