Fixed: Updated error message if services respond with html

Co-Authored-By: taloth <taloth@users.noreply.github.com>
This commit is contained in:
Qstick
2018-11-18 22:27:16 -05:00
parent 6da9868716
commit 2f6b0c77ea
4 changed files with 33 additions and 3 deletions
+10
View File
@@ -267,6 +267,7 @@ namespace NzbDrone.Common.Http
public HttpResponse<T> Get<T>(HttpRequest request) where T : new()
{
var response = Get(request);
CheckResponseContentType(response);
return new HttpResponse<T>(response);
}
@@ -285,7 +286,16 @@ namespace NzbDrone.Common.Http
public HttpResponse<T> Post<T>(HttpRequest request) where T : new()
{
var response = Post(request);
CheckResponseContentType(response);
return new HttpResponse<T>(response);
}
private void CheckResponseContentType(HttpResponse response)
{
if (response.Headers.ContentType != null && response.Headers.ContentType.Contains("text/html"))
{
throw new UnexpectedHtmlContentException(response);
}
}
}
}