M
microdevsolutions
Hello
I've seen examples to read a file from somewhere into a HttpWebRequest
object then write it to a HttpWebResponse object then stream it into a
Stream object, very similar to the following code snipet :-
==============================================
Uri uri = new Uri("http://www.somewhere/pdf/image1.pdf");
HttpWebRequest httpRequest = null;
httpRequest = (HttpWebRequest)WebRequest.Create(uri);
HttpWebResponse httpResponse = null;
Stream responseStream = null;
try
{
httpResponse = (HttpWebResponse)httpRequest.GetResponse();
responseStream = httpResponse.GetResponseStream();
...
==============================================
However if the original file is big (i.e. say 200MB) the first read
(i.e. httpRequest.GetResponse) causes the browser times out (even if
the timeout property is set to something big enough) because the entire
200MB is being read into the HttpWebRequest object. Is there any way
to control how much is read in via the httpRequest.GetResponse(), so
that I can read around 4MB chunks, send this (flush) to the browser,
read another 4MB, send this to the browser, etc.
Other options include asynchronous reads and perhaps an ftp object, but
is it necessary ?
Many thanks
Travis
I've seen examples to read a file from somewhere into a HttpWebRequest
object then write it to a HttpWebResponse object then stream it into a
Stream object, very similar to the following code snipet :-
==============================================
Uri uri = new Uri("http://www.somewhere/pdf/image1.pdf");
HttpWebRequest httpRequest = null;
httpRequest = (HttpWebRequest)WebRequest.Create(uri);
HttpWebResponse httpResponse = null;
Stream responseStream = null;
try
{
httpResponse = (HttpWebResponse)httpRequest.GetResponse();
responseStream = httpResponse.GetResponseStream();
...
==============================================
However if the original file is big (i.e. say 200MB) the first read
(i.e. httpRequest.GetResponse) causes the browser times out (even if
the timeout property is set to something big enough) because the entire
200MB is being read into the HttpWebRequest object. Is there any way
to control how much is read in via the httpRequest.GetResponse(), so
that I can read around 4MB chunks, send this (flush) to the browser,
read another 4MB, send this to the browser, etc.
Other options include asynchronous reads and perhaps an ftp object, but
is it necessary ?
Many thanks
Travis