JsonHttpPipeline only deserializes JSON responses

The JsonHttpPipeline should only try to deserialize responses that have
a Content-Type of application/json.
This commit is contained in:
Haacked
2013-10-06 21:05:18 -07:00
parent 9a33c68dbc
commit fa1473264c
6 changed files with 60 additions and 4 deletions
+7 -3
View File
@@ -1,4 +1,5 @@
using System.Net.Http;
using System;
using System.Net.Http;
namespace Octokit.Http
{
@@ -43,8 +44,11 @@ namespace Octokit.Http
{
Ensure.ArgumentNotNull(response, "response");
var json = _serializer.Deserialize<T>(response.Body);
response.BodyAsObject = json;
if (response.ContentType != null && response.ContentType.Equals("application/json", StringComparison.Ordinal))
{
var json = _serializer.Deserialize<T>(response.Body);
response.BodyAsObject = json;
}
}
}
}