[Mono-list] Stream Issue with WebResponse
Gonzalo Paniagua Javier
gonzalo@ximian.com
01 Apr 2003 17:13:29 +0200
El mar, 01 de 04 de 2003 a las 02:02, Sean Newton escribió:
> I'm rather new to Mono and not exactly a linux guru so my issue may not be a bug but instead user error. Basically, trying to build a test harness for getting performance metrics of web requests. Wrote the code on windows, hoping Mono would be a viable alternative for end users that wanted to use Linux. Initially structured with a multi-threaded, asynchronous design, all worked well under windows but seemed to hang on linux/mono, eventually reporting an exception.
>
> Since then, I've simplified the code greatly to isolate the error:
>
> using System;
> using System.IO;
> using System.Text;
> using System.Net;
>
> class Harness {
>
> static void Main(string[] args) {
>
> string url = "http://www.microsoft.com";
> Console.WriteLine("Creating WebRequest...");
> WebRequest request = WebRequest.Create(url);
> Console.WriteLine("Retrieving WebResponse...");
> WebResponse response = request.GetResponse();
> StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.ASCII);
> string line = null;
> Console.WriteLine("Retrieving Stream...");
> while( (line = sr.ReadLine()) != null) {
> Console.WriteLine(line);
> }
> Console.WriteLine("I never reach this point");
> sr.Close();
> }
> }
This works with CVS version. There have been some fixes after the last
mono release that makes this actually work.
-Gonzalo