Skip to content

Commit 48e54ca

Browse files
committed
Merge branch '6.x' of github.com:elastic/elasticsearch-net into 6.x
2 parents 2e47cb2 + a47a9cb commit 48e54ca

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

src/Elasticsearch.Net/Transport/Pipeline/ResponseBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private static bool SetSpecialTypes<TResponse>(byte[] bytes, out TResponse cs)
146146

147147
if (responseType == typeof(StringResponse))
148148
cs = new StringResponse(bytes.Utf8String()) as TResponse;
149-
else if (responseType == typeof(byte[]))
149+
else if (responseType == typeof(BytesResponse))
150150
cs = new BytesResponse(bytes) as TResponse;
151151
else if (responseType == typeof(VoidResponse))
152152
cs = StaticVoid as TResponse;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Net.Http;
5+
using System.Reactive.Linq;
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
using Elasticsearch.Net;
9+
using FluentAssertions;
10+
using Nest;
11+
using Tests.Framework;
12+
using Tests.Framework.ManagedElasticsearch.Clusters;
13+
using Tests.Framework.MockData;
14+
using Xunit;
15+
16+
namespace Tests.Reproduce
17+
{
18+
public class BytesResponseTests : IClusterFixture<ReadOnlyCluster>
19+
{
20+
private readonly ReadOnlyCluster _cluster;
21+
22+
public BytesResponseTests(ReadOnlyCluster cluster) => _cluster = cluster;
23+
24+
[I] public void NonNullBytesResponse()
25+
{
26+
var client = _cluster.Client;
27+
28+
var bytesResponse = client.LowLevel.Search<BytesResponse>("project", "project", PostData.Serializable(new { }));
29+
30+
bytesResponse.Body.Should().NotBeNull();
31+
bytesResponse.Body.Should().BeEquivalentTo(bytesResponse.ResponseBodyInBytes);
32+
}
33+
34+
[I] public void NonNullBytesLowLevelResponse()
35+
{
36+
var settings = new ConnectionConfiguration(new Uri($"http://localhost:{_cluster.DesiredPort}"));
37+
var lowLevelClient = new ElasticLowLevelClient(settings);
38+
39+
var bytesResponse = lowLevelClient.Search<BytesResponse>("project", "project", PostData.Serializable(new { }));
40+
41+
bytesResponse.Body.Should().NotBeNull();
42+
bytesResponse.Body.Should().BeEquivalentTo(bytesResponse.ResponseBodyInBytes);
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)