From 98995132de817fcec4c02536e6494a32eaf13cb7 Mon Sep 17 00:00:00 2001 From: markrendle Date: Tue, 30 Jun 2015 11:00:37 +0100 Subject: [PATCH] Pre-create Continue bytes in Frame --- src/Microsoft.AspNet.Server.Kestrel/Http/Frame.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/Frame.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/Frame.cs index 3ae0d60b6b..4689db0804 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/Frame.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/Frame.cs @@ -260,7 +260,13 @@ namespace Microsoft.AspNet.Server.Kestrel.Http //_upgradeTask = callback(_callContext); } - byte[] _continueBytes = Encoding.ASCII.GetBytes("HTTP/1.1 100 Continue\r\n\r\n"); + private static readonly ArraySegment _continueBytes = CreateAsciiByteArraySegment("HTTP/1.1 100 Continue\r\n\r\n"); + + private static ArraySegment CreateAsciiByteArraySegment(string text) + { + var bytes = Encoding.ASCII.GetBytes(text); + return new ArraySegment(bytes); + } public void ProduceContinue() { @@ -272,7 +278,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http (expect.FirstOrDefault() ?? "").Equals("100-continue", StringComparison.OrdinalIgnoreCase)) { SocketOutput.Write( - new ArraySegment(_continueBytes, 0, _continueBytes.Length), + _continueBytes, (error, _) => { if (error != null)