[
  {
    "Id": "421689",
    "ThreadId": "206614",
    "Html": "<p>I'm trying to port <a href=\"http://www.fiddler2.com\">Fiddler</a>&nbsp;to DotNetZip from the Xceed library.&nbsp; However, I'm having a problem with the AddEntry(string, OpenDelegate, CloseDelegate) method. Specifically, sometimes my close delegate is getting called twice (but Open is called only once), and that leads to an exception.&nbsp; Any idea why this might happen?</p>\r\n<p>thanks for any tips!</p>\r\n<p>** LogString: Open response: raw/0032_s.txt<br>** LogString: Close response: raw/0032_s.txt<br>** LogString: Open response: raw/0033_s.txt<br>** LogString: Close response: raw/0033_s.txt<br>** LogString: Open response: raw/0034_s.txt<br>** LogString: Close response: raw/0034_s.txt<br>** LogString: Open response: raw/0035_s.txt<br>** LogString: Close response: raw/0035_s.txt<br><strong>** LogString: Close response: raw/0035_s.txt</strong><br>** LogString: WriteSessionArchive skipped writing raw/0035_s.txt to C:\\Users\\eri<br>claw\\Desktop\\11-36-47.saz because Cannot access a closed Stream.;<br>&nbsp;&nbsp; at System.IO.MemoryStream.set_Position(Int64 value)<br>&nbsp;&nbsp; at Ionic.Zip.ZipEntry.PrepSourceStream()<br>&nbsp;&nbsp; at Ionic.Zip.ZipEntry.SetInputAndFigureFileLength(Stream&amp; input)<br>&nbsp;&nbsp; at Ionic.Zip.ZipEntry._WriteEntryData(Stream s)<br>&nbsp;&nbsp; at Ionic.Zip.ZipEntry._EmitOne(Stream outstream)<br>&nbsp;&nbsp; at Ionic.Zip.ZipEntry.Write(Stream s)...</p>\r\n<p>My code is pretty simple:</p>\r\n<p>oZip.AddEntry(sResponseFilename,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new OpenDelegate(delegate(string sn)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FiddlerApplication.Log.LogString(&quot;Open response: &quot; + sn);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MemoryStream strmResponse = new MemoryStream();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!delegatesCopyOfSession.WriteResponseToStream(strmResponse, false))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fiddl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p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FiddlerApplication.Log.LogString(&quot;Close response: &quot; + sn);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (null != strmResponse) strmResponse.Close();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; })<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );&nbsp;</p>",
    "PostedDate": "2010-03-21T11:41:55.87-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "422672",
    "ThreadId": "206614",
    "Html": "<p>Hmmm, that's a surprise!</p>\r\n<p>It's possible that the compression algorithm actually causes an increase in data size.&nbsp; That can happen for a small file, where the compression dictionary is larger than the data to be compressed.&nbsp; There's logic in DotNetZip that compares the size of the compressed stream with the size of the uncompressed stream, and if the former is larger, then DotNetZip will re-read the stream and store it uncompressed.&nbsp;</p>\r\n<p>I just looked at the code and saw the problem.&nbsp; When a stream provided by an open delegate results in an expansion, and the re-read happens, DotNetZip fails to re-open the stream. (Fails to call the OpenDelegate again).&nbsp;</p>\r\n<p>Looks like a one-line fix.&nbsp; I'll make a build ready for you to test in a few minutes.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2010-03-23T10:46:03.773-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "422673",
    "ThreadId": "206614",
    "Html": "This discussion has been copied to a work item. Click <a href=\"http://dotnetzip.codeplex.com/WorkItem/View.aspx?WorkItemId=10489\">here</a> to go to the work item and continue the discussion.",
    "PostedDate": "2010-03-23T10:47:24.357-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "422677",
    "ThreadId": "206614",
    "Html": "<p>ok, a patched version of the DLL is available on that workitem.&nbsp; (<a href=\"http://dotnetzip.codeplex.com/WorkItem/View.aspx?WorkItemId=10489\">http://dotnetzip.codeplex.com/WorkItem/View.aspx?WorkItemId=10489</a>&nbsp;)</p>\r\n<p>Try it out and let me know.</p>\r\n<p>ps; I love Fiddler.&nbsp; Excellent tool.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2010-03-23T10:52:25.487-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "422820",
    "ThreadId": "206614",
    "Html": "<p>Thanks a bunch!&nbsp; Turns out that the WriteDelegate version worked super-well for my needs, but I'll give your new bits a shot!</p>",
    "PostedDate": "2010-03-23T16:44:28.817-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "423147",
    "ThreadId": "206614",
    "Html": "<p>Great, I'll be interested in what you find.</p>\r\n<p>ps: I used fiddler today to work on a rewriting filter/proxy - IIRF - also on codeplex.&nbsp; I needed to&nbsp;diagnose some problems with&nbsp;the proxy behavior. Fiddler is indispensable.</p>",
    "PostedDate": "2010-03-24T10:30:43.11-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]