@@ -274,12 +274,11 @@ private ElasticsearchResponse<T> WebToElasticsearchResponse<T>(byte[] data, obje
274274 this . SetByteResult ( cs as ElasticsearchResponse < byte [ ] > , bytes ) ;
275275 return cs ;
276276 }
277- cs . ResponseRaw = bytes ;
277+ cs . ResponseRaw = _ConnectionSettings . KeepRawResponse ? bytes : null ;
278278 }
279279
280280 var result = this . _ConnectionSettings . Serializer . Deserialize < T > ( cs , s , deserializationState ) ;
281281 cs . Response = result ;
282- cs . ResponseRaw = memoryStream . ToArray ( ) ;
283282 tracer . SetResult ( cs ) ;
284283 return cs ;
285284 }
@@ -384,20 +383,20 @@ private IEnumerable<Task> _AsyncSteps<T>(HttpWebRequest request, TaskCompletionS
384383 }
385384 memoryStream . Position = 0 ;
386385 s = memoryStream ;
387- cs . ResponseRaw = memoryStream . ToArray ( ) ;
386+ var bytes = memoryStream . ToArray ( ) ;
388387 if ( typeof ( T ) == typeof ( string ) )
389388 {
390- this . SetStringResult ( cs as ElasticsearchResponse < string > , cs . ResponseRaw ) ;
389+ this . SetStringResult ( cs as ElasticsearchResponse < string > , bytes ) ;
391390 SetReturnOnAsycActors ( tcs , cs , tracer ) ;
392391 yield break ;
393392 }
394393 if ( typeof ( T ) == typeof ( byte [ ] ) )
395394 {
396- this . SetByteResult ( cs as ElasticsearchResponse < byte [ ] > , cs . ResponseRaw ) ;
395+ this . SetByteResult ( cs as ElasticsearchResponse < byte [ ] > , bytes ) ;
397396 SetReturnOnAsycActors ( tcs , cs , tracer ) ;
398397 yield break ;
399398 }
400-
399+ cs . ResponseRaw = _ConnectionSettings . KeepRawResponse ? bytes : null ;
401400 }
402401 var t = this . _ConnectionSettings . Serializer . DeserializeAsync < T > ( cs , s , deserializationState ) ;
403402 yield return t ;
0 commit comments