[Modify] Polish it

This commit is contained in:
sta 2015-11-19 16:11:49 +09:00
parent 974f6dc1d7
commit ea831f0dd8

View File

@ -152,17 +152,14 @@ namespace WebSocketSharp
internal static byte[] Append (this ushort code, string reason) internal static byte[] Append (this ushort code, string reason)
{ {
using (var buff = new MemoryStream ()) { var ret = code.InternalToByteArray (ByteOrder.Big);
var bytes = code.InternalToByteArray (ByteOrder.Big); if (reason != null && reason.Length > 0) {
buff.Write (bytes, 0, 2); var buff = new List<byte> (ret);
if (reason != null && reason.Length > 0) { buff.AddRange (Encoding.UTF8.GetBytes (reason));
bytes = Encoding.UTF8.GetBytes (reason); ret = buff.ToArray ();
buff.Write (bytes, 0, bytes.Length);
}
buff.Close ();
return buff.ToArray ();
} }
return ret;
} }
internal static string CheckIfAvailable ( internal static string CheckIfAvailable (