1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-10-03 22:57:18 +02:00

Check Content-Type in FileList parser

This commit is contained in:
Bogdan 2024-01-16 21:39:03 +02:00
parent 91fbad72c0
commit 0b0c93081d

View File

@ -19,8 +19,6 @@ public FileListParser(FileListSettings settings)
public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
{
var torrentInfos = new List<ReleaseInfo>();
if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK)
{
throw new IndexerException(indexerResponse,
@ -28,6 +26,13 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
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);
foreach (var result in queryResults)