diff --git a/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs b/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs
index 792615a0f..957371df6 100644
--- a/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs
+++ b/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs
@@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Primitives;
using Microsoft.Net.Http.Headers;
+using HeaderNames = MediaBrowser.Common.Net.MoreHeaderNames;
using IHttpFile = MediaBrowser.Model.Services.IHttpFile;
using IHttpRequest = MediaBrowser.Model.Services.IHttpRequest;
using IResponse = MediaBrowser.Model.Services.IResponse;
@@ -38,16 +39,9 @@ namespace Emby.Server.Implementations.SocketSharp
public string RawUrl => request.GetEncodedPathAndQuery();
public string AbsoluteUri => request.GetDisplayUrl().TrimEnd('/');
+ // Header[name] returns "" when undefined
- public string XForwardedFor
- => StringValues.IsNullOrEmpty(request.Headers["X-Forwarded-For"]) ? null : request.Headers["X-Forwarded-For"].ToString();
-
- public int? XForwardedPort
- => StringValues.IsNullOrEmpty(request.Headers["X-Forwarded-Port"]) ? (int?)null : int.Parse(request.Headers["X-Forwarded-Port"], CultureInfo.InvariantCulture);
-
- public string XForwardedProtocol => StringValues.IsNullOrEmpty(request.Headers["X-Forwarded-Proto"]) ? null : request.Headers["X-Forwarded-Proto"].ToString();
-
- public string XRealIp => StringValues.IsNullOrEmpty(request.Headers["X-Real-IP"]) ? null : request.Headers["X-Real-IP"].ToString();
+ private string GetHeader(string name) => request.Headers[name].ToString();
private string remoteIp;
public string RemoteIp
@@ -59,13 +53,13 @@ namespace Emby.Server.Implementations.SocketSharp
return remoteIp;
}
- var temp = CheckBadChars(XForwardedFor.AsSpan());
+ var temp = CheckBadChars(GetHeader(HeaderNames.XForwardedFor).AsSpan());
if (temp.Length != 0)
{
return remoteIp = temp.ToString();
}
- temp = CheckBadChars(XRealIp.AsSpan());
+ temp = CheckBadChars(GetHeader(HeaderNames.XRealIP).AsSpan());
if (temp.Length != 0)
{
return remoteIp = NormalizeIp(temp).ToString();
diff --git a/MediaBrowser.Model/Services/IHttpRequest.cs b/MediaBrowser.Model/Services/IHttpRequest.cs
index 50c6076f3..daf91488f 100644
--- a/MediaBrowser.Model/Services/IHttpRequest.cs
+++ b/MediaBrowser.Model/Services/IHttpRequest.cs
@@ -7,26 +7,6 @@ namespace MediaBrowser.Model.Services
///
string HttpMethod { get; }
- ///
- /// The IP Address of the X-Forwarded-For header, null if null or empty
- ///
- string XForwardedFor { get; }
-
- ///
- /// The Port number of the X-Forwarded-Port header, null if null or empty
- ///
- int? XForwardedPort { get; }
-
- ///
- /// The http or https scheme of the X-Forwarded-Proto header, null if null or empty
- ///
- string XForwardedProtocol { get; }
-
- ///
- /// The value of the X-Real-IP header, null if null or empty
- ///
- string XRealIp { get; }
-
///
/// The value of the Accept HTTP Request Header
///