[Mono-bugs] [Bug 38976][Min] New - StreamReader.ReadToEnd loops forever
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
Mon, 3 Mar 2003 07:51:47 -0500 (EST)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by kmpm_se@msn.com.
http://bugzilla.ximian.com/show_bug.cgi?id=38976
--- shadow/38976 Mon Mar 3 07:51:47 2003
+++ shadow/38976.tmp.26682 Mon Mar 3 07:51:47 2003
@@ -0,0 +1,57 @@
+Bug#: 38976
+Product: Mono/Class Libraries
+Version: unspecified
+OS:
+OS Details: SuSE 8.1 Pro
+Status: NEW
+Resolution:
+Severity:
+Priority: Minor
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: kmpm_se@msn.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: StreamReader.ReadToEnd loops forever
+
+Description of Problem:
+When using StreamReader.ReadToEnd with Encoding.ASCII it enters and never
+ending loop.
+
+Steps to reproduce the problem:
+1. Fill a Stream object with text ( I used HttpWebResponse.GetResponseStream)
+2. Initialize a StreamReader using the Stream object
+3. Call .ReadToEnd to try to return a String.
+
+<begining of code>
+.
+.
+.
+ HttpWebResponse myRes = (HttpWebResponse)myReq.GetResponse();
+ Stream respStream = myRes.GetResponseStream();
+ int respLength=(int)myRes.ContentLength;
+
+ StreamReader reader =
+ new StreamReader(respStream, Encoding.ASCII,true,respLength);
+ String respHTML = reader.ReadToEnd();
+
+<End of Code>
+
+Actual Results:
+The code hangs at "String respHTML = reader.ReadToEnd();"
+Can break with ^c
+
+Expected Results:
+ReadToEnd should return a String with the contents of the respStream
+
+How often does this happen?
+Every time I run the code.
+
+Additional Information:
+I changed the "while ((len = Read (buffer, 0, size)) != 0)..." in
+StreamReader.cs .ReadToEnd to the line
+"if ((len = Read (buffer, 0, size)) != 0)". Then it worked.
+As long as the code reads from index 0 in "buffer" it always will report a
+length >0 if there is any from the begining.