refactoring for portal integration
[mono.git] / mcs / class / Mainsoft.Web / Mainsoft.Web.Hosting / OutputStreamWrapper.cs
index 823c5eb61f47d803d912168db58a88f440aae019..878f771ecd3b34d744d5cd91ba57c49ce4a4b0cf 100644 (file)
@@ -41,7 +41,7 @@ namespace Mainsoft.Web.Hosting
        /// <summary>\r
        /// \r
        /// </summary>\r
-       internal sealed class OutputStreamWrapper : java.io.Writer\r
+       public sealed class OutputStreamWrapper : java.io.Writer\r
        {\r
                enum OutputMode\r
                {\r
@@ -53,9 +53,9 @@ namespace Mainsoft.Web.Hosting
                readonly OutputStream _outputStream;\r
                readonly OutputMode _outputMode;\r
 \r
-               private byte [] _bytebuffer = new byte [1024];\r
-               private char [] _charBuffer = new char [1024];\r
-               sbyte [] _oneByte = new sbyte [1];\r
+               private byte [] _bytebuffer;\r
+               private char [] _charBuffer;\r
+               //sbyte [] _oneByte = new sbyte [1];\r
 \r
                Encoding _encoding = null;\r
 \r
@@ -144,12 +144,15 @@ namespace Mainsoft.Web.Hosting
                private char [] GetCharBuffer (int length)\r
                {\r
                        // We will reuse the buffer if its size is < 32K\r
-                       if (_charBuffer.Length >= length)\r
+                       if (_charBuffer != null && _charBuffer.Length >= length)\r
                                return _charBuffer;\r
 \r
                        if (length > 32 * 1024)\r
                                return new char [length];\r
 \r
+                       if (length < 1024)\r
+                               length = 1024;\r
+\r
                        _charBuffer = new char [length];\r
                        return _charBuffer;\r
                }\r
@@ -157,12 +160,15 @@ namespace Mainsoft.Web.Hosting
                private byte [] GetByteBuffer (int length)\r
                {\r
                        // We will reuse the buffer if its size is < 32K\r
-                       if (_bytebuffer.Length >= length)\r
+                       if (_bytebuffer != null && _bytebuffer.Length >= length)\r
                                return _bytebuffer;\r
 \r
                        if (length > 32 * 1024)\r
                                return new byte [length];\r
 \r
+                       if (length < 1024)\r
+                               length = 1024;\r
+\r
                        _bytebuffer = new byte [length];\r
                        return _bytebuffer;\r
                }\r