mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00

* Move service config service back into shared .NET Framework Library * Move Content files into shared folder. Make autoface load different assembilies depending on what framework is using it. * Change my mind on what the shared module should be called. Common Module is too bland. * DotNet4.SocksProxy is not yet publically .NET Standard. Revert to previous SocksWebProxy package. * Check in unstaged change to test dependency injection setup.
63 lines
1.9 KiB
C#
63 lines
1.9 KiB
C#
using Newtonsoft.Json.Linq;
|
|
using NLog;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Web;
|
|
|
|
namespace Jackett
|
|
{
|
|
public static class CookieContainerExtensions
|
|
{
|
|
public static void FillFromJson(this CookieContainer cookies, Uri uri, JToken json, Logger logger)
|
|
{
|
|
if (json["cookies"] != null)
|
|
{
|
|
var cookieArray = (JArray)json["cookies"];
|
|
foreach (string cookie in cookieArray)
|
|
{
|
|
var w = cookie.Split('=');
|
|
if (w.Length == 1)
|
|
{
|
|
cookies.Add(uri, new Cookie { Name = cookie.Trim() });
|
|
}
|
|
else
|
|
{
|
|
cookies.Add(uri, new Cookie(w[0].Trim(), w[1].Trim()));
|
|
}
|
|
}
|
|
}
|
|
|
|
if (json["cookie_header"] != null)
|
|
{
|
|
var cfh = (string)json["cookie_header"];
|
|
var cookieHeaders = ((string)json["cookie_header"]).Split(';');
|
|
foreach (var c in cookieHeaders)
|
|
{
|
|
try
|
|
{
|
|
cookies.SetCookies(uri, c);
|
|
}
|
|
catch (CookieException ex)
|
|
{
|
|
logger.Info("(Non-critical) Problem loading cookie {0}, {1}, {2}", uri, c, ex.Message);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void DumpToJson(this CookieContainer cookies, string uri, JToken json)
|
|
{
|
|
DumpToJson(cookies, new Uri(uri), json);
|
|
}
|
|
|
|
public static void DumpToJson(this CookieContainer cookies, Uri uri, JToken json)
|
|
{
|
|
json["cookie_header"] = cookies.GetCookieHeader(uri);
|
|
}
|
|
}
|
|
}
|