mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
Response cookies not stored by default.
This commit is contained in:
parent
d4532c3856
commit
ee87537848
4 changed files with 54 additions and 5 deletions
|
@ -52,8 +52,6 @@ namespace NzbDrone.Common.Http
|
|||
webRequest.AllowAutoRedirect = request.AllowAutoRedirect;
|
||||
webRequest.ContentLength = 0;
|
||||
|
||||
webRequest.CookieContainer = _cookieContainerCache.Get("container", () => new CookieContainer());
|
||||
|
||||
if (!RuntimeInfoBase.IsProduction)
|
||||
{
|
||||
webRequest.AllowAutoRedirect = false;
|
||||
|
@ -66,17 +64,29 @@ namespace NzbDrone.Common.Http
|
|||
AddRequestHeaders(webRequest, request.Headers);
|
||||
}
|
||||
|
||||
var cookieContainer = _cookieContainerCache.Get("container", () => new CookieContainer());
|
||||
|
||||
if (request.Cookies.Count != 0)
|
||||
{
|
||||
foreach (var pair in request.Cookies)
|
||||
{
|
||||
webRequest.CookieContainer.Add(new Cookie(pair.Key, pair.Value, "/", request.Url.Host)
|
||||
cookieContainer.Add(new Cookie(pair.Key, pair.Value, "/", request.Url.Host)
|
||||
{
|
||||
Expires = DateTime.UtcNow.AddHours(1)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (request.StoreResponseCookie)
|
||||
{
|
||||
webRequest.CookieContainer = cookieContainer;
|
||||
}
|
||||
else
|
||||
{
|
||||
webRequest.CookieContainer = new CookieContainer();
|
||||
webRequest.CookieContainer.Add(cookieContainer.GetCookies(request.Url));
|
||||
}
|
||||
|
||||
if (!request.Body.IsNullOrWhiteSpace())
|
||||
{
|
||||
var bytes = request.Headers.GetEncodingFromContentType().GetBytes(request.Body.ToCharArray());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue