Permalink
Browse files

add `CanTimeout` check before setting `ReadTimeout`

  • Loading branch information...
andyedinborough committed May 16, 2012
1 parent 4fdd125 commit b916e2ec5f89b2a47ce0522add26a8aec8d33f48
Showing with 7 additions and 3 deletions.
  1. +1 −1 Properties/AssemblyInfo.cs
  2. +6 −2 Utilities.cs
@@ -33,5 +33,5 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.6.1.0")]
-[assembly: AssemblyFileVersion("1.6.1-beta3")]
+[assembly: AssemblyFileVersion("1.6.1-beta4")]
[assembly: InternalsVisibleTo("Tests")]
View
@@ -12,7 +12,9 @@ internal static class Utilities {
private static CultureInfo _enUsCulture = CultureInfo.GetCultureInfo("en-US");
internal static string ReadLine(this Stream stream, ref int maxLength, Encoding encoding) {
- stream.ReadTimeout = 10000;
+ if (stream.CanTimeout)
+ stream.ReadTimeout = 10000;
+
var maxLengthSpecified = maxLength > 0;
byte b;
using (var mem = new MemoryStream()) {
@@ -30,7 +32,9 @@ internal static class Utilities {
}
internal static string ReadToEnd(this Stream stream, int maxLength, Encoding encoding) {
- stream.ReadTimeout = 10000;
+ if (stream.CanTimeout)
+ stream.ReadTimeout = 10000;
+
int read = 1;
byte[] buffer = new byte[8192];
using (var mem = new MemoryStream()) {

0 comments on commit b916e2e

Please sign in to comment.