diff --git a/src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListFixture.cs index 995332eca..91128bd1a 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListFixture.cs @@ -33,7 +33,7 @@ namespace NzbDrone.Core.Test.IndexerTests.FileListTests Mocker.GetMock() .Setup(o => o.ExecuteAsync(It.Is(v => v.Method == HttpMethod.Get))) - .Returns(r => Task.FromResult(new HttpResponse(r, new HttpHeader(), recentFeed))); + .Returns(r => Task.FromResult(new HttpResponse(r, new HttpHeader { { "Content-Type", "application/json" } }, recentFeed))); var releases = await Subject.FetchRecent(); diff --git a/src/NzbDrone.Core/Indexers/FileList/FileListParser.cs b/src/NzbDrone.Core/Indexers/FileList/FileListParser.cs index ee43829a7..2d0a16a8f 100644 --- a/src/NzbDrone.Core/Indexers/FileList/FileListParser.cs +++ b/src/NzbDrone.Core/Indexers/FileList/FileListParser.cs @@ -18,8 +18,6 @@ namespace NzbDrone.Core.Indexers.FileList public IList ParseResponse(IndexerResponse indexerResponse) { - var torrentInfos = new List(); - if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK) { throw new IndexerException(indexerResponse, @@ -27,6 +25,13 @@ namespace NzbDrone.Core.Indexers.FileList 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(); + var queryResults = JsonConvert.DeserializeObject>(indexerResponse.Content); foreach (var result in queryResults)