Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 5f0e936

Browse files
committed
Update HttpUtils.HttpClient.cs
1 parent e50d0c6 commit 5f0e936

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/ServiceStack.Text/HttpUtils.HttpClient.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,10 @@ public static HttpRequestMessage WithHeader(this HttpRequestMessage httpReq, str
10581058
{
10591059
if (httpReq.Content == null)
10601060
throw new NotSupportedException("Can't set ContentType before Content is populated");
1061-
httpReq.Content.Headers.ContentType = new MediaTypeHeaderValue(value);
1061+
httpReq.Content.Headers.ContentType = new MediaTypeHeaderValue(value.LeftPart(';'));
1062+
var charset = value.RightPart(';');
1063+
if (charset != null && charset.IndexOf("charset", StringComparison.OrdinalIgnoreCase) >= 0)
1064+
httpReq.Content.Headers.ContentType.CharSet = charset.RightPart('=');
10621065
}
10631066
else if (name.Equals(HttpHeaders.Referer, StringComparison.OrdinalIgnoreCase))
10641067
{

0 commit comments

Comments
 (0)