Skip to content

Commit c85fda6

Browse files
committed
fix htmlcontent not sending charset parameter
1 parent 835612b commit c85fda6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Http/HtmlContent.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
namespace Sisk.Core.Http;
1414

1515
/// <summary>
16-
/// Provides HTTP content based on HTML file.
16+
/// Provides HTTP content based on HTML contents.
1717
/// </summary>
1818
/// <definition>
1919
/// public class HtmlContent : ByteArrayContent
@@ -45,9 +45,10 @@ public class HtmlContent : ByteArrayContent
4545
/// <type>
4646
/// Constructor
4747
/// </type>
48-
public HtmlContent(string content, Encoding? encoding) : base(GetContentBytes(content, encoding))
48+
public HtmlContent(string content, Encoding encoding) : base(GetContentBytes(content, encoding))
4949
{
5050
Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("text/html");
51+
Headers.ContentType.CharSet = encoding.HeaderName;
5152
}
5253

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

6566
[MethodImpl(MethodImplOptions.AggressiveInlining)]
66-
private static byte[] GetContentBytes(string content, Encoding? encoder)
67+
private static byte[] GetContentBytes(string content, Encoding encoder)
6768
{
6869
ArgumentNullException.ThrowIfNull(content, nameof(content));
6970
return (encoder ?? Encoding.UTF8).GetBytes(content);

0 commit comments

Comments
 (0)