@@ -102,17 +102,19 @@ public static ResourceFormat GetResourceFormatFromContentType(string? contentTyp
102
102
/// </summary>
103
103
/// <param name="format">Whether the body is xml or json.</param>
104
104
/// <param name="fhirVersion">Optional. The version of FHIR to add to the header.</param>
105
- public static string BuildContentType ( ResourceFormat format , string ? fhirVersion = default ) =>
106
- BuildMediaType ( format , fhirVersion ) . ToString ( ) ;
105
+ /// <param name="excludeCharset">Optional. Whether exclude charset.</param>
106
+ public static string BuildContentType ( ResourceFormat format , string ? fhirVersion = default , bool excludeCharset = false ) =>
107
+ BuildMediaType ( format , fhirVersion , excludeCharset ) . ToString ( ) ;
107
108
108
109
/// <summary>
109
110
/// Creates a <see cref="MediaTypeHeaderValue"/> for use in a Content-Type header,
110
111
/// given the serialization format and the fhir version in use.
111
112
/// </summary>
112
113
/// <param name="format">Whether the body is xml or json.</param>
113
114
/// <param name="fhirVersion">Optional. The version of FHIR to add to the header.</param>
115
+ /// <param name="excludeCharset">Optional. Whether exclude charset.</param>
114
116
/// <exception cref="ArgumentException">Unsupported serialization.</exception>
115
- public static MediaTypeHeaderValue BuildMediaType ( ResourceFormat format , string ? fhirVersion = default )
117
+ public static MediaTypeHeaderValue BuildMediaType ( ResourceFormat format , string ? fhirVersion = default , bool excludeCharset = false )
116
118
{
117
119
var contentType = format switch
118
120
{
@@ -121,10 +123,11 @@ public static MediaTypeHeaderValue BuildMediaType(ResourceFormat format, string?
121
123
_ => throw new ArgumentException ( "Cannot determine content type for data format " + format ) ,
122
124
} ;
123
125
124
- var result = new MediaTypeHeaderValue ( contentType )
126
+ var result = new MediaTypeHeaderValue ( contentType ) ;
127
+ if ( ! excludeCharset )
125
128
{
126
- CharSet = Encoding . UTF8 . WebName
127
- } ;
129
+ result . CharSet = Encoding . UTF8 . WebName ;
130
+ }
128
131
129
132
if ( fhirVersion is not null && SemVersion . TryParse ( fhirVersion , out var version ) )
130
133
{
0 commit comments