}
}
+ internal HttpResponse Response {
+ get { return response; }
+ }
//
// Flush data, and closes socket
//
{
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)
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);