-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for providing single
sid
cookie;
Allow skipping setting file as Vortex default;
- Loading branch information
Showing
6 changed files
with
57 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Linq; | ||
using System.Net; | ||
using System.Net.Http; | ||
using Microsoft.Extensions.Logging; | ||
using NexusUploader.Nexus.Services; | ||
|
||
namespace NexusUploader.Nexus.Http | ||
{ | ||
public class NexusCookieHandler : HttpClientHandler | ||
{ | ||
private readonly CookieService _cookies; | ||
private readonly ILogger<NexusCookieHandler> _logger; | ||
|
||
public NexusCookieHandler(CookieService cookieService, ILogger<NexusCookieHandler> logger) | ||
{ | ||
_cookies = cookieService; | ||
_logger = logger; | ||
base.CookieContainer = GetCookies(); | ||
} | ||
|
||
private CookieContainer GetCookies() | ||
{ | ||
var c = new CookieContainer(); | ||
try { | ||
foreach (var (name, value) in _cookies.GetCookies().Where(cookie => | ||
!string.IsNullOrWhiteSpace(cookie.Key) && !string.IsNullOrWhiteSpace(cookie.Value))) { | ||
c.Add(new Cookie(name, value) {Domain = "nexusmods.com"}); | ||
} | ||
} catch { | ||
_logger.LogError("Error encountered while loading cookies! [bold] This probably won't work![/]"); | ||
} | ||
return c; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters