This commit is contained in:
Chris R 2016-09-02 15:33:10 -07:00
parent f05007e0f2
commit 6522926c22
2 changed files with 6 additions and 14 deletions

View File

@ -30,7 +30,6 @@ namespace System.Net.WebSockets
/// <param name="stream">The connected Stream.</param>
/// <param name="isServer">true if this is the server-side of the connection; false if this is the client-side of the connection.</param>
/// <param name="subprotocol">The agreed upon subprotocol for the connection.</param>
/// <param name="state">The current state of the websocket connection.</param>
/// <param name="keepAliveIntervalSeconds">The interval to use for keep-alive pings.</param>
/// <param name="receiveBufferSize">The buffer size to use for received data.</param>
/// <returns>The created <see cref="ManagedWebSocket"/> instance.</returns>
@ -616,12 +615,7 @@ namespace System.Net.WebSockets
// Make sure we have the first two bytes, which includes the start of the payload length.
if (_receiveBufferCount < 2)
{
await EnsureBufferContainsAsync(2, cancellationToken, throwOnPrematureClosure: false).ConfigureAwait(false);
if (_receiveBufferCount < 2)
{
// The connection closed; nothing more to read.
return new WebSocketReceiveResult(0, WebSocketMessageType.Text, true);
}
await EnsureBufferContainsAsync(2, cancellationToken, throwOnPrematureClosure: true).ConfigureAwait(false);
}
// Then make sure we have the full header based on the payload length.
@ -877,7 +871,7 @@ namespace System.Net.WebSockets
}
/// <summary>Parses a message header from the buffer. This assumes the header is in the buffer.</summary>
/// <param name="header">The read header.</param>
/// <param name="resultHeader">The read header.</param>
/// <returns>true if a header was read; false if the header was invalid.</returns>
private bool TryParseMessageHeaderFromReceiveBuffer(out MessageHeader resultHeader)
{
@ -1035,7 +1029,7 @@ namespace System.Net.WebSockets
/// <summary>Sends a close message to the server.</summary>
/// <param name="closeStatus">The close status to send.</param>
/// <param name="statusDescription">The close status description to send.</param>
/// <param name="closeStatusDescription">The close status description to send.</param>
/// <param name="cancellationToken">The CancellationToken to use to cancel the websocket.</param>
private async Task SendCloseFrameAsync(WebSocketCloseStatus closeStatus, string closeStatusDescription, CancellationToken cancellationToken)
{
@ -1151,9 +1145,9 @@ namespace System.Net.WebSockets
/// <param name="toMask">The buffer to which the mask should be applied.</param>
/// <param name="toMaskOffset">The offset into <paramref name="toMask"/> at which the mask should start to be applied.</param>
/// <param name="mask">The four-byte mask, stored as an Int32.</param>
/// <param name="maskOffsetIndex">The index into the mas</param>
/// <param name="maskIndex">The index into the mask.</param>
/// <param name="count">The number of bytes to mask.</param>
/// <returns></returns>
/// <returns>The next index into the mask to be used for future applications of the mask.</returns>
private static unsafe int ApplyMask(byte[] toMask, int toMaskOffset, int mask, int maskIndex, long count)
{
Debug.Assert(toMaskOffset <= toMask.Length - count, $"Unexpected inputs: {toMaskOffset}, {toMask.Length}, {count}");

View File

@ -10,9 +10,7 @@
"warningsAsErrors": true,
"keyFile": "../../tools/Key.snk",
"nowarn": [
"CS1591",
"CS1572",
"CS1573"
"CS1591"
],
"xmlDoc": true
},