Skip to content

Commit 22a7274

Browse files
committed
Merge pull request Pathoschild#4 from shbita/master
setting the encoding default to utf-8
2 parents 0120b74 + 3b063ef commit 22a7274

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

Formatters.JsonNet/package.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package>
33
<metadata>
44
<id>Pathoschild.Http.Formatters.JsonNet</id>
5-
<version>1.0.0</version>
5+
<version>1.0.1</version>
66
<authors>Jesse Plamondon-Willard</authors>
77
<description>Provides JSON, JSONP, and BSON implementations of the .NET 4.5 MediaTypeFormatter using Json.NET. These can be used by the .NET 4.5 HttpClient and the Web API for serializing content.</description>
88
<licenseUrl>https://creativecommons.org/licenses/by/3.0/</licenseUrl>
@@ -15,7 +15,7 @@
1515
<dependency id="Microsoft.AspNet.WebApi.Client" version="4.0" />
1616
<dependency id="Newtonsoft.Json" version="4.5" />
1717
</dependencies>
18-
<releaseNotes>Migrated to Microsoft's HTTP NuGet packages.</releaseNotes>
18+
<releaseNotes>Added a default UTF-8 encoding to fix missing charsets in Web API response headers.</releaseNotes>
1919
</metadata>
2020
<files>
2121
<file src="bin\Debug\Pathoschild.Http.Formatters.dll" target="lib\net45" />

Formatters/MediaTypeFormatterBase.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Net.Http;
55
using System.Net.Http.Formatting;
66
using System.Net.Http.Headers;
7+
using System.Text;
78
using System.Threading.Tasks;
89

910
namespace Pathoschild.Http.Formatters
@@ -109,5 +110,15 @@ public MediaTypeFormatterBase AddMediaType(string mediaType, double? quality = n
109110
/// <param name="content">The HTTP content being written.</param>
110111
/// <param name="transportContext">The <see cref="TransportContext"/>.</param>
111112
public abstract void Serialize(Type type, object value, Stream stream, HttpContent content, TransportContext transportContext);
113+
114+
115+
/*********
116+
** Protected methods
117+
*********/
118+
/// <summary>Construct an instance.</summary>
119+
protected MediaTypeFormatterBase()
120+
{
121+
this.SupportedEncodings.Add(new UTF8Encoding());
122+
}
112123
}
113124
}

Formatters/package.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package>
33
<metadata>
44
<id>Pathoschild.Http.Formatters.Core</id>
5-
<version>1.0.0</version>
5+
<version>1.0.1</version>
66
<authors>Jesse Plamondon-Willard</authors>
77
<description>A base implementation of the .NET 4.5 MediaTypeFormatter for serializers with an example PlainTextFormatter. This handles the common plumbing code so you only need to implement the "Serialize" and "Deserialize" methods.</description>
88
<licenseUrl>https://creativecommons.org/licenses/by/3.0/</licenseUrl>
@@ -14,6 +14,6 @@
1414
<dependency id="Microsoft.Net.Http" version="2.0" />
1515
<dependency id="Microsoft.AspNet.WebApi.Client" version="4.0" />
1616
</dependencies>
17-
<releaseNotes>Migrated to Microsoft's HTTP NuGet packages.</releaseNotes>
17+
<releaseNotes>Added a default UTF-8 encoding to fix missing charsets in Web API response headers.</releaseNotes>
1818
</metadata>
1919
</package>

0 commit comments

Comments
 (0)