Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think this is very close to what @Zachary suggests. And it (seems to) work(s); actually I think using <code>using</code> as @Zachary does is even "nicer".<br> My main point being I cannot see the blocking behaviour of <code>GetResponse()</code> you (seem to) describe.</p> <p>In addition the following code only roughly shows how everything works; <em>it will not read the stream to the end</em> for example (unless by coincidence :)). But it should work if you copy-n-paste it into an empty "Console Application"-project in Visual Studio.</p> <p>You can try using some "shorter" URL for a test. The example here starts downloading an ISO of the debian distribution (a bit more than 600 MByte). <em>Sorry debian, I did not mean to steal your bandwidth.</em> -> Btw: is there something sensible one can use to test such a scenario?</p> <p>The Code is strongly inspired by <a href="https://stackoverflow.com/questions/775574/c-how-to-read-a-continuous-stream-of-xml-over-http">C# - How to read a continuous stream of XML over HTTP</a>.</p> <pre><code>namespace StreamReadWebRequest { using System; using System.Collections.Generic; using System.Text; using System.Net; using System.IO; class Program { static void Main(string[] args) { HttpWebRequest req; HttpWebResponse res = null; try { req = (HttpWebRequest)WebRequest.Create( "http://cdimage.debian.org/debian-cd/5.0.4/i386/iso-cd/debian-504-i386-CD-1.iso"); res = (HttpWebResponse)req.GetResponse(); Stream stream = res.GetResponseStream(); byte[] data = new byte[4096]; int read; while ((read = stream.Read(data, 0, data.Length)) &gt; 0) { Process(data, read); } } finally { if (res != null) res.Close(); } Console.In.Read(); } private static void Process(byte[] data, int read) { Console.Out.Write(ASCIIEncoding.ASCII.GetString(data)); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload