@@ -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
{
@@ -405,7 +405,7 @@ private static async Task<string> RawQueryAsync(string query, EndPoint server, I
405
405
return string . Empty ;
406
406
}
407
407
408
- var res = new StringBuilder ( ) ;
408
+ var responseBytes = new List < byte > ( 4096 ) ;
409
409
try
410
410
{
411
411
using ( var s = tcpClient . GetStream ( ) )
@@ -424,12 +424,12 @@ private static async Task<string> RawQueryAsync(string query, EndPoint server, I
424
424
do
425
425
{
426
426
cbRead = await s . ReadAsync ( readBuff , 0 , buffSize , token ) . ConfigureAwait ( false ) ;
427
- res . Append ( options . Encoding . GetString ( readBuff , 0 , cbRead ) ) ;
427
+ responseBytes . AddRange ( readBuff . Take ( cbRead ) ) ;
428
428
if ( cbRead > 0 )
429
429
await Task . Delay ( 100 , token ) . ConfigureAwait ( false ) ;
430
430
} while ( cbRead > 0 ) ;
431
431
432
- return res . ToString ( ) ;
432
+ return options . Encoding . GetString ( responseBytes . ToArray ( ) ) ;
433
433
}
434
434
}
435
435
catch ( Exception )
@@ -440,7 +440,7 @@ private static async Task<string> RawQueryAsync(string query, EndPoint server, I
440
440
if ( options . RethrowExceptions )
441
441
throw ;
442
442
443
- return res . ToString ( ) ;
443
+ return options . Encoding . GetString ( responseBytes . ToArray ( ) ) ;
444
444
}
445
445
finally
446
446
{
0 commit comments