1
0
mirror of https://github.com/chylex/Minecraft-Phantom-Panel.git synced 2026-02-25 11:08:17 +01:00
Files
Minecraft-Phantom-Panel/Utils/Phantom.Utils/Net/HttpHeadersExtensions.cs

22 lines
528 B
C#

using System.Net.Http.Headers;
using Phantom.Utils.IO;
namespace Phantom.Utils.Net;
public static class HttpHeadersExtensions {
private const string ContentLength = "Content-Length";
extension(HttpResponseHeaders headers) {
public FileSize? ContentLength {
get {
if (!headers.TryGetValues(ContentLength, out var values)) {
return null;
}
string? value = values.FirstOrDefault();
return value != null && ulong.TryParse(value, out ulong result) ? new FileSize(result) : null;
}
}
}
}