Skip to content

Commit

Permalink
fix htmlcontent not sending charset parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
CypherPotato committed Jan 24, 2024
1 parent 835612b commit c85fda6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Http/HtmlContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace Sisk.Core.Http;

/// <summary>
/// Provides HTTP content based on HTML file.
/// Provides HTTP content based on HTML contents.
/// </summary>
/// <definition>
/// public class HtmlContent : ByteArrayContent
Expand Down Expand Up @@ -45,9 +45,10 @@ public class HtmlContent : ByteArrayContent
/// <type>
/// Constructor
/// </type>
public HtmlContent(string content, Encoding? encoding) : base(GetContentBytes(content, encoding))
public HtmlContent(string content, Encoding encoding) : base(GetContentBytes(content, encoding))
{
Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("text/html");
Headers.ContentType.CharSet = encoding.HeaderName;
}

/// <summary>
Expand All @@ -63,7 +64,7 @@ public HtmlContent(string content, Encoding? encoding) : base(GetContentBytes(co
public HtmlContent(string content) : this(content, DefaultEncoding) { }

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static byte[] GetContentBytes(string content, Encoding? encoder)
private static byte[] GetContentBytes(string content, Encoding encoder)
{
ArgumentNullException.ThrowIfNull(content, nameof(content));
return (encoder ?? Encoding.UTF8).GetBytes(content);
Expand Down

0 comments on commit c85fda6

Please sign in to comment.