X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem.Web%2FSystem.Web%2FHttpWriter.cs;h=f695bccc12239b5e772567b964426698a0dfb11f;hb=b6969f355f56af8e2b62fa705f799e87f5226502;hp=5882a5a48690a6c7648a3e4c4dc2d5e49eb28f4f;hpb=096265478e6e4145c90250a5bf78c0c179ee50af;p=mono.git diff --git a/mcs/class/System.Web/System.Web/HttpWriter.cs b/mcs/class/System.Web/System.Web/HttpWriter.cs index 5882a5a4869..f695bccc122 100644 --- a/mcs/class/System.Web/System.Web/HttpWriter.cs +++ b/mcs/class/System.Web/System.Web/HttpWriter.cs @@ -81,6 +81,9 @@ namespace System.Web { } } + internal HttpResponse Response { + get { return response; } + } // // Flush data, and closes socket // @@ -119,27 +122,25 @@ namespace System.Web { { if (buffer == null || index < 0 || count < 0 || (buffer.Length - index) < count) throw new ArgumentOutOfRangeException (); - - int length = encoding.GetByteCount (buffer, index, count); +#if TARGET_JVM + output_stream.Write (buffer, index, count); +#else + int length = encoding.GetMaxByteCount (count); byte [] bytebuffer = GetByteBuffer (length); - encoding.GetBytes (buffer, index, count, bytebuffer, 0); - output_stream.Write (bytebuffer, 0, length); + int realLength = encoding.GetBytes (buffer, index, count, bytebuffer, 0); + output_stream.Write (bytebuffer, 0, realLength); +#endif if (response.buffer) return; response.Flush (); } - static byte [] newline = new byte [2] { 13, 10 }; + static char [] newline = new char [2] { '\r', '\n' }; public override void WriteLine () { - output_stream.Write (newline, 0, 2); - - if (response.buffer) - return; - - response.Flush (); + Write (newline, 0, 2); } public void WriteString (string s, int index, int count) @@ -149,24 +150,25 @@ namespace System.Web { if (index < 0 || count < 0 || ((index + count > s.Length))) throw new ArgumentOutOfRangeException (); - - int length; - if (index == 0 && count == s.Length) { - length = encoding.GetByteCount (s); - } else { - char [] chars = s.ToCharArray (index, count); - length = encoding.GetByteCount (chars); - } - +#if TARGET_JVM + output_stream.Write (s, index, count); +#else + int length = encoding.GetMaxByteCount (count); byte [] bytebuffer = GetByteBuffer (length); - encoding.GetBytes (s, index, count, bytebuffer, 0); - output_stream.Write (bytebuffer, 0, length); + int realLength = encoding.GetBytes (s, index, count, bytebuffer, 0); + output_stream.Write (bytebuffer, 0, realLength); +#endif if (response.buffer) return; response.Flush (); } + internal void WriteUTF8Ptr (IntPtr ptr, int length) + { + output_stream.WritePtr (ptr, length); + } + public void WriteBytes (byte [] buffer, int index, int count) { output_stream.Write (buffer, index, count);