elsa-core/src/modules/Elsa.Http/Extensions/HeadersExtensions.cs
lukhipolito-nexxbiz c4451c4f40
Feat/6732 zip archive activities (#6751)
* Io module and content strategies

* Restructuring the folders and projects

* Create zip activity + shared content resolver

* Fixing build on github.com

* Update src/modules/Elsa.IO/Services/ContentResolver.cs

explicit nullable field

Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>

* QoL improvements

* More QoL improvements + removing some logic duplications

* Update src/modules/Elsa.IO.Compression/Activities/CreateZipArchive.cs

avoiding duplicate extensions

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Assigning file path correctly to the variable

* More QoL changes, new Elsa.IO.Http module, more modular content strategy

* Addresing QoL review comments + Correct extension handling

---------

Co-authored-by: lucas.hipolito <lukhipolito@yahoo.com.br>
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-06-30 16:56:51 +02:00

32 lines
1 KiB
C#

// ReSharper disable once CheckNamespace
using Elsa.Http;
namespace Elsa.Extensions;
/// <summary>
/// Provides extension methods for HTTP headers.
/// </summary>
public static class HeadersExtensions
{
/// <summary>
/// Gets the filename from the Content-Disposition header.
/// </summary>
public static string? GetFilename(this HttpResponseMessage response)
{
var dictionary = response.Headers.ToDictionary(x => x.Key, x => x.Value.ToArray(), StringComparer.OrdinalIgnoreCase);
return dictionary.GetFilename();
}
/// <summary>
/// Gets the filename from the Content-Disposition header.
/// </summary>
public static string? GetFilename(this IDictionary<string, string[]> headers)
{
if (!headers.TryGetValue("Content-Disposition", out var values))
return null;
var contentDispositionString = string.Join("", values);
var contentDisposition = new System.Net.Mime.ContentDisposition(contentDispositionString);
return contentDisposition.FileName;
}
}