I got around this problem by writing my own "ReadLine" for the buffered stream, eliminating the need for the StreamReader. Here it is, if you are interested. Please excuse the use of "goto", but it was the most natural (and efficient) way to write the code:
/// Gets the next line of text from the NTTP server. Reads from the
/// buffered stream one byte at a time, until the characters \r \n
/// have been encountered. Returns the text string, without the
/// line terminators.
private string ReadLine()
{
StringBuilder sb = new StringBuilder();
byte b;
// Read bytes until the \r is encountered, adding it to the string.
p0:
b = (byte)bufStream_.ReadByte();
if (b != '\r')
{
sb.Append((char)b);
goto p0;
}
// At this point, the \r has been seen, so we're looking for the
// \n. If a second \r is encountered, loop back and look for \n
// again. If any other character is found, add it to the string
// and start over.
p1:
b = (byte)bufStream_.ReadByte();
if (b != '\n')
{
sb.Append((char)'\r');
if (b == '\r')
{
goto p1;
}
else
{
sb.Append((char)b);
goto p0;
}
}
return sb.ToString();
}