Merge branch 'rel/2.0.0-preview2' into dev

This commit is contained in:
Kiran Challa 2017-06-03 19:28:28 -07:00
commit 7de91da37d
3 changed files with 5 additions and 4 deletions

View File

@ -3,6 +3,7 @@
using System;
using System.Binary.Base64;
using System.Buffers;
namespace Microsoft.AspNetCore.Sockets.Internal.Formatters
{
@ -13,11 +14,11 @@ namespace Microsoft.AspNetCore.Sockets.Internal.Formatters
if (inputPayload.Length > 0)
{
// Determine the output size
var decodedLength = Base64Encoder.ComputeDecodedLength(inputPayload);
var decodedLength = Base64Decoder.ComputeDecodedLength(inputPayload);
// Allocate a new buffer to decode to
var decodeBuffer = new byte[decodedLength];
if (!Base64Encoder.TryDecode(inputPayload, decodeBuffer, out _, out var _))
if (Base64.Decoder.Transform(inputPayload, decodeBuffer, out _, out var _) != TransformationStatus.Done)
{
throw new FormatException("Invalid Base64 payload");
}

View File

@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Sockets.Internal.Formatters
{
// TODO: Base64 writer that works with IOutput would be amazing!
var arr = new byte[Base64Encoder.ComputeEncodedLength(payload.Length)];
Base64Encoder.TryEncode(payload, arr, out _, out _);
Base64.Encoder.Transform(payload, arr, out _, out _);
return TryWriteLine(arr, output);
}
else

View File

@ -62,7 +62,7 @@ namespace Microsoft.AspNetCore.Sockets.Internal.Formatters
{
// TODO: Base64 writer that works with IOutput would be amazing!
var arr = new byte[Base64Encoder.ComputeEncodedLength(message.Payload.Length)];
Base64Encoder.TryEncode(message.Payload, arr, out _, out _);
Base64.Encoder.Transform(message.Payload, arr, out _, out _);
return output.TryWrite(arr);
}
else