Skip to content

Commit f59b55a

Browse files
Mpdreamzrusscam
authored andcommitted
less strict mimetype checking, can contain charset information (old httpconnection) (#4213)
(cherry picked from commit bfca7ed)
1 parent 6da2b93 commit f59b55a

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,20 @@ private static bool SetSpecialTypes<TResponse>(byte[] bytes, IMemoryStreamFactor
165165
cs = new VoidResponse() as TResponse;
166166
else if (responseType == typeof(DynamicResponse))
167167
{
168-
using (var ms = memoryStreamFactory.Create(bytes))
168+
//if not json store the result under "body"
169+
if (!mimeType.StartsWith(RequestData.MimeType))
169170
{
170-
var body = LowLevelRequestResponseSerializer.Instance.Deserialize<DynamicDictionary>(ms);
171-
cs = new DynamicResponse(body) as TResponse;
171+
var dictionary = new DynamicDictionary();
172+
dictionary["body"] = new DynamicValue(bytes.Utf8String());
173+
cs = new DynamicResponse(dictionary) as TResponse;
174+
}
175+
else
176+
{
177+
using (var ms = memoryStreamFactory.Create(bytes))
178+
{
179+
var body = LowLevelRequestResponseSerializer.Instance.Deserialize<DynamicDictionary>(ms);
180+
cs = new DynamicResponse(body) as TResponse;
181+
}
172182
}
173183
}
174184
return cs != null;

0 commit comments

Comments
 (0)