Check Content-Type in FileList parser
This commit is contained in:
parent
c6bb6ad878
commit
2dbf5b5a71
|
@ -33,7 +33,7 @@ namespace NzbDrone.Core.Test.IndexerTests.FileListTests
|
||||||
|
|
||||||
Mocker.GetMock<IHttpClient>()
|
Mocker.GetMock<IHttpClient>()
|
||||||
.Setup(o => o.ExecuteAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.Get)))
|
.Setup(o => o.ExecuteAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.Get)))
|
||||||
.Returns<HttpRequest>(r => Task.FromResult(new HttpResponse(r, new HttpHeader(), recentFeed)));
|
.Returns<HttpRequest>(r => Task.FromResult(new HttpResponse(r, new HttpHeader { { "Content-Type", "application/json" } }, recentFeed)));
|
||||||
|
|
||||||
var releases = await Subject.FetchRecent();
|
var releases = await Subject.FetchRecent();
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,6 @@ namespace NzbDrone.Core.Indexers.FileList
|
||||||
|
|
||||||
public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
||||||
{
|
{
|
||||||
var torrentInfos = new List<ReleaseInfo>();
|
|
||||||
|
|
||||||
if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK)
|
if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
throw new IndexerException(indexerResponse,
|
throw new IndexerException(indexerResponse,
|
||||||
|
@ -27,6 +25,13 @@ namespace NzbDrone.Core.Indexers.FileList
|
||||||
indexerResponse.HttpResponse.StatusCode);
|
indexerResponse.HttpResponse.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!indexerResponse.HttpResponse.Headers.ContentType.Contains(HttpAccept.Json.Value))
|
||||||
|
{
|
||||||
|
throw new IndexerException(indexerResponse, "Unexpected response header '{0}' from indexer request, expected '{1}'", indexerResponse.HttpResponse.Headers.ContentType, HttpAccept.Json.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
var torrentInfos = new List<ReleaseInfo>();
|
||||||
|
|
||||||
var queryResults = JsonConvert.DeserializeObject<List<FileListTorrent>>(indexerResponse.Content);
|
var queryResults = JsonConvert.DeserializeObject<List<FileListTorrent>>(indexerResponse.Content);
|
||||||
|
|
||||||
foreach (var result in queryResults)
|
foreach (var result in queryResults)
|
||||||
|
|
Loading…
Reference in New Issue