ContentType "application/vnd.api+json" is not recognized as json (#186)

* Admin API GetRequestsAsync Json/JsonApi request body tests

* Fix code + update unit-tests
This commit is contained in:
Steve Land authored and Stef Heyenrath committed 2018-08-17 19:15:01 +02:00
1 parent b57d118c3d
commit fb6b25a9c5
4 files changed
+168 -69

No files matched your search

+8 -2
View File
@@ -10,6 +10,12 @@ namespace WireMock.Util
{
internal static class BodyParser
{
private static readonly string[] JsonContentTypes =
{
"application/json",
"application/vnd.api+json"
};
private static readonly string[] TextContentTypes =
{
"text/",
@@ -41,7 +47,7 @@ namespace WireMock.Util
{
var data = new BodyData();
if (contentTypeHeaderValue != null && TextContentTypes.Any(t => contentTypeHeaderValue.StartsWith(t, StringComparison.OrdinalIgnoreCase)))
if (contentTypeHeaderValue != null && TextContentTypes.Any(text => contentTypeHeaderValue.StartsWith(text, StringComparison.OrdinalIgnoreCase)))
{
try
{
@@ -55,7 +61,7 @@ namespace WireMock.Util
data.BodyAsBytes = await ReadBytesAsync(stream);
}
}
else if (contentTypeHeaderValue != null && contentTypeHeaderValue.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
else if (contentTypeHeaderValue != null && JsonContentTypes.Any(json => contentTypeHeaderValue.StartsWith(json, StringComparison.OrdinalIgnoreCase)))
{
var stringData = await ReadStringAsync(stream);
data.BodyAsString = stringData.Item1;