@@ -298,7 +298,7 @@ private static string RawQuery(string query, EndPoint server, IQueryOptions opti
298
298
return string . Empty ;
299
299
}
300
300
301
- var res = new StringBuilder ( ) ;
301
+ var responseBytes = new List < byte > ( 4096 ) ;
302
302
try
303
303
{
304
304
using ( var s = tcpClient . GetStream ( ) )
@@ -317,12 +317,12 @@ private static string RawQuery(string query, EndPoint server, IQueryOptions opti
317
317
do
318
318
{
319
319
cbRead = s . Read ( readBuff , 0 , readBuff . Length ) ;
320
- res . Append ( options . Encoding . GetString ( readBuff , 0 , cbRead ) ) ;
320
+ responseBytes . AddRange ( readBuff . Take ( cbRead ) ) ;
321
321
if ( cbRead > 0 )
322
322
Thread . Sleep ( 100 ) ;
323
323
} while ( cbRead > 0 ) ;
324
324
325
- return res . ToString ( ) ;
325
+ return options . Encoding . GetString ( responseBytes . ToArray ( ) ) ;
326
326
}
327
327
}
328
328
catch
@@ -333,7 +333,7 @@ private static string RawQuery(string query, EndPoint server, IQueryOptions opti
333
333
if ( options . RethrowExceptions )
334
334
throw ;
335
335
336
- return res . ToString ( ) ;
336
+ return options . Encoding . GetString ( responseBytes . ToArray ( ) ) ;
337
337
}
338
338
finally
339
339
{
@@ -406,7 +406,7 @@ private static async Task<string> RawQueryAsync(string query, EndPoint server, I
406
406
return string . Empty ;
407
407
}
408
408
409
- var res = new StringBuilder ( ) ;
409
+ var responseBytes = new List < byte > ( 4096 ) ;
410
410
try
411
411
{
412
412
using ( var s = tcpClient . GetStream ( ) )
@@ -425,12 +425,12 @@ private static async Task<string> RawQueryAsync(string query, EndPoint server, I
425
425
do
426
426
{
427
427
cbRead = await s . ReadAsync ( readBuff , 0 , buffSize , token ) . ConfigureAwait ( false ) ;
428
- res . Append ( options . Encoding . GetString ( readBuff , 0 , cbRead ) ) ;
428
+ responseBytes . AddRange ( readBuff . Take ( cbRead ) ) ;
429
429
if ( cbRead > 0 )
430
430
await Task . Delay ( 100 , token ) . ConfigureAwait ( false ) ;
431
431
} while ( cbRead > 0 ) ;
432
432
433
- return res . ToString ( ) ;
433
+ return options . Encoding . GetString ( responseBytes . ToArray ( ) ) ;
434
434
}
435
435
}
436
436
catch ( Exception )
@@ -441,7 +441,7 @@ private static async Task<string> RawQueryAsync(string query, EndPoint server, I
441
441
if ( options . RethrowExceptions )
442
442
throw ;
443
443
444
- return res . ToString ( ) ;
444
+ return options . Encoding . GetString ( responseBytes . ToArray ( ) ) ;
445
445
}
446
446
finally
447
447
{
0 commit comments