mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Improve the GoogleDrive Downloader a bit
This commit is contained in:
parent
401c2d232f
commit
0f32321971
22
Wabbajack.Lib/Http/HttpExtensions.cs
Normal file
22
Wabbajack.Lib/Http/HttpExtensions.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
|
|
||||||
|
namespace Wabbajack.Lib.Http
|
||||||
|
{
|
||||||
|
public static class HttpExtensions
|
||||||
|
{
|
||||||
|
public static IEnumerable<(string Key, string Value)> GetSetCookies(this HttpResponseMessage response)
|
||||||
|
{
|
||||||
|
if (!response.Headers.TryGetValues("set-cookie", out var values))
|
||||||
|
return Array.Empty<(string, string)>();
|
||||||
|
|
||||||
|
return values
|
||||||
|
.SelectMany(h => h.Split(";"))
|
||||||
|
.Select(h => h.Split("="))
|
||||||
|
.Where(h => h.Length == 2)
|
||||||
|
.Select(h => (h[0], h[1]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user