From b54046a6dedf691e33b273d5aa105910efee3c7e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 22 Oct 2017 19:36:22 -0400 Subject: [PATCH] adjust header values --- Emby.Dlna/PlayTo/SsdpHttpClient.cs | 2 +- .../HttpClientManager/HttpClientManager.cs | 13 ++++++------- MediaBrowser.Common/Net/HttpRequestOptions.cs | 2 +- Mono.Nat/Upnp/Messages/UpnpMessage.cs | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Emby.Dlna/PlayTo/SsdpHttpClient.cs b/Emby.Dlna/PlayTo/SsdpHttpClient.cs index 40fe010a2..78b688d92 100644 --- a/Emby.Dlna/PlayTo/SsdpHttpClient.cs +++ b/Emby.Dlna/PlayTo/SsdpHttpClient.cs @@ -147,7 +147,7 @@ namespace Emby.Dlna.PlayTo } options.RequestContentType = "text/xml"; - options.RequestContentEncoding = Encoding.UTF8; + options.AppendCharsetToMimeType = true; options.RequestContent = postData; return _httpClient.Post(options); diff --git a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs index ae53e3a5b..ef95b47c3 100644 --- a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs +++ b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs @@ -397,17 +397,16 @@ namespace Emby.Server.Implementations.HttpClientManager { try { - var bytes = options.RequestContentBytes ?? - Encoding.UTF8.GetBytes(options.RequestContent ?? string.Empty); + // TODO: We can always put this in the options object if needed + var requestEncoding = Encoding.UTF8; + + var bytes = options.RequestContentBytes ?? requestEncoding.GetBytes(options.RequestContent ?? string.Empty); var contentType = options.RequestContentType ?? "application/x-www-form-urlencoded"; - if (options.RequestContentEncoding != null) + if (options.AppendCharsetToMimeType) { - if (options.RequestContentEncoding.Equals(Encoding.UTF8)) - { - contentType = contentType.TrimEnd(';') + "; charset=\"utf-8\""; - } + contentType = contentType.TrimEnd(';') + "; charset=\"utf-8\""; } httpWebRequest.ContentType = contentType; diff --git a/MediaBrowser.Common/Net/HttpRequestOptions.cs b/MediaBrowser.Common/Net/HttpRequestOptions.cs index 0950df021..51859ecdb 100644 --- a/MediaBrowser.Common/Net/HttpRequestOptions.cs +++ b/MediaBrowser.Common/Net/HttpRequestOptions.cs @@ -104,7 +104,7 @@ namespace MediaBrowser.Common.Net public bool PreferIpv4 { get; set; } public bool EnableDefaultUserAgent { get; set; } - public Encoding RequestContentEncoding { get; set; } + public bool AppendCharsetToMimeType { get; set; } private string GetHeaderValue(string name) { diff --git a/Mono.Nat/Upnp/Messages/UpnpMessage.cs b/Mono.Nat/Upnp/Messages/UpnpMessage.cs index 05280172b..b0264fc4a 100644 --- a/Mono.Nat/Upnp/Messages/UpnpMessage.cs +++ b/Mono.Nat/Upnp/Messages/UpnpMessage.cs @@ -59,7 +59,7 @@ namespace Mono.Nat.Upnp req.Url = ss; req.EnableKeepAlive = false; req.RequestContentType = "text/xml"; - req.RequestContentEncoding = Encoding.UTF8; + req.AppendCharsetToMimeType = true; req.RequestHeaders.Add("SOAPACTION", "\"" + device.ServiceType + "#" + upnpMethod + "\""); string bodyString = "