mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
Fixed: BitMeTv cookie will now also be used for the fetching the torrent file.
This commit is contained in:
parent
a6d2283be8
commit
ccfd66260d
4 changed files with 80 additions and 6 deletions
|
@ -3,6 +3,7 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Net;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Cache;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
||||
|
@ -23,10 +24,14 @@ namespace NzbDrone.Common.Http
|
|||
{
|
||||
private readonly Logger _logger;
|
||||
|
||||
public HttpClient(Logger logger)
|
||||
private readonly ICached<CookieContainer> _cookieContainerCache;
|
||||
|
||||
public HttpClient(ICacheManager cacheManager, Logger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
ServicePointManager.DefaultConnectionLimit = 12;
|
||||
|
||||
_cookieContainerCache = cacheManager.GetCache<CookieContainer>(typeof(HttpClient));
|
||||
}
|
||||
|
||||
public HttpResponse Execute(HttpRequest request)
|
||||
|
@ -47,6 +52,8 @@ namespace NzbDrone.Common.Http
|
|||
webRequest.AllowAutoRedirect = request.AllowAutoRedirect;
|
||||
webRequest.ContentLength = 0;
|
||||
|
||||
webRequest.CookieContainer = _cookieContainerCache.Get("container", () => new CookieContainer());
|
||||
|
||||
if (!RuntimeInfoBase.IsProduction)
|
||||
{
|
||||
webRequest.AllowAutoRedirect = false;
|
||||
|
@ -61,10 +68,12 @@ namespace NzbDrone.Common.Http
|
|||
|
||||
if (request.Cookies.Count != 0)
|
||||
{
|
||||
webRequest.CookieContainer = new CookieContainer();
|
||||
foreach (var pair in request.Cookies)
|
||||
{
|
||||
webRequest.CookieContainer.Add(new Cookie(pair.Key, pair.Value, "/", request.Url.Host));
|
||||
webRequest.CookieContainer.Add(new Cookie(pair.Key, pair.Value, "/", request.Url.Host)
|
||||
{
|
||||
Expires = DateTime.UtcNow.AddHours(1)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue