// Deny client with http error message private async Task <bool> RejectClient(ConnectionStream stream, string errorMessage) { byte[] errorData = Encoding.UTF8.GetBytes(HttpErrorTemplate .Replace("{Content}", errorMessage) .Replace("{ContentType}", "text/plain") .Replace("{ContentLength}", errorMessage.Length.ToString())); await stream.WriteAsync(errorData, errorData.Length); stream.Dispose(); return(false); }
public void Dispose() { stream.Dispose(); }