Commit 461f788a authored by Honfika's avatar Honfika

long url requests fixed

parent 5fe25998
...@@ -17,7 +17,9 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -17,7 +17,9 @@ namespace Titanium.Web.Proxy.Helpers
private readonly char[] charBuffer; private readonly char[] charBuffer;
private static readonly byte[] newLine = ProxyConstants.NewLine; private static readonly byte[] newLine = ProxyConstants.NewLine;
private static readonly Encoding encoding = Encoding.ASCII;
private static readonly Encoder encoder = Encoding.ASCII.GetEncoder(); private static readonly Encoder encoder = Encoding.ASCII.GetEncoder();
internal HttpWriter(Stream stream, int bufferSize) : base(stream) internal HttpWriter(Stream stream, int bufferSize) : base(stream)
...@@ -36,10 +38,10 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -36,10 +38,10 @@ namespace Titanium.Web.Proxy.Helpers
public async Task WriteAsync(string value) public async Task WriteAsync(string value)
{ {
int charCount = value.Length; int charCount = value.Length;
value.CopyTo(0, charBuffer, 0, charCount);
if (charCount < BufferSize) if (charCount < BufferSize)
{ {
value.CopyTo(0, charBuffer, 0, charCount);
var buffer = BufferPool.GetBuffer(BufferSize); var buffer = BufferPool.GetBuffer(BufferSize);
try try
{ {
...@@ -53,9 +55,8 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -53,9 +55,8 @@ namespace Titanium.Web.Proxy.Helpers
} }
else else
{ {
var buffer = new byte[charCount + 1]; var buffer = encoding.GetBytes(value);
int idx = encoder.GetBytes(charBuffer, 0, charCount, buffer, 0, true); await WriteAsync(buffer);
await WriteAsync(buffer, 0, idx);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment