public static string slurpInputStream(Stream stream)
{
StringBuilder data = new StringBuilder();
try
{
System.Text.Encoding encode =
System.Text.Encoding.GetEncoding("utf-8");
StreamReader readStream = new StreamReader(stream, encode);
const int stride = 4096;
Char[] read = new Char[stride];
int count = readStream.Read(read, 0, stride);
while (count > 0)
{
string str = new string(read, 0, count);
data.Append(str);
count = readStream.Read(read, 0, stride);
}
}
finally
{
stream.Close();
}
return data.ToString();
}