Skip to content

Commit 2569071

Browse files
committed
[Modify] Replace it
1 parent 2216119 commit 2569071

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

websocket-sharp/HttpBase.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
using System.Collections.Generic;
3131
using System.Collections.Specialized;
3232
using System.IO;
33+
using System.Linq;
3334
using System.Text;
3435
using System.Threading;
3536
using WebSocketSharp.Net;
@@ -283,16 +284,9 @@ public byte[] ToByteArray ()
283284
{
284285
var headerData = Encoding.UTF8.GetBytes (MessageHeader);
285286

286-
if (_messageBodyData == null)
287-
return headerData;
288-
289-
var buff = new MemoryStream ();
290-
291-
buff.Write (headerData, 0, headerData.Length);
292-
buff.WriteBytes (_messageBodyData, 1024);
293-
buff.Close ();
294-
295-
return buff.ToArray ();
287+
return _messageBodyData != null
288+
? headerData.Concat (_messageBodyData).ToArray ()
289+
: headerData;
296290
}
297291

298292
public override string ToString ()

0 commit comments

Comments
 (0)