mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-08 23:00:51 +02:00
update path parsing
This commit is contained in:
parent
0dbfc21442
commit
e0c1d740a3
|
@ -180,18 +180,6 @@ namespace Emby.Server.Implementations.HttpServer
|
||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetHandlerPathIfAny(string listenerUrl)
|
|
||||||
{
|
|
||||||
if (listenerUrl == null) return null;
|
|
||||||
var pos = listenerUrl.IndexOf("://", StringComparison.OrdinalIgnoreCase);
|
|
||||||
if (pos == -1) return null;
|
|
||||||
var startHostUrl = listenerUrl.Substring(pos + "://".Length);
|
|
||||||
var endPos = startHostUrl.IndexOf('/');
|
|
||||||
if (endPos == -1) return null;
|
|
||||||
var endHostUrl = startHostUrl.Substring(endPos + 1);
|
|
||||||
return string.IsNullOrEmpty(endHostUrl) ? null : endHostUrl.TrimEnd('/');
|
|
||||||
}
|
|
||||||
|
|
||||||
private IHttpListener GetListener()
|
private IHttpListener GetListener()
|
||||||
{
|
{
|
||||||
return new WebSocketSharpListener(_logger,
|
return new WebSocketSharpListener(_logger,
|
||||||
|
@ -798,8 +786,6 @@ namespace Emby.Server.Implementations.HttpServer
|
||||||
{
|
{
|
||||||
UrlPrefixes = urlPrefixes;
|
UrlPrefixes = urlPrefixes;
|
||||||
|
|
||||||
WebSocketSharpRequest.HandlerFactoryPath = GetHandlerPathIfAny(UrlPrefixes[0]);
|
|
||||||
|
|
||||||
_listener = GetListener();
|
_listener = GetListener();
|
||||||
|
|
||||||
_listener.WebSocketConnected = OnWebSocketConnected;
|
_listener.WebSocketConnected = OnWebSocketConnected;
|
||||||
|
|
|
@ -27,6 +27,20 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
|
||||||
_memoryStreamProvider = memoryStreamProvider;
|
_memoryStreamProvider = memoryStreamProvider;
|
||||||
this.request = httpContext.Request;
|
this.request = httpContext.Request;
|
||||||
this.response = new WebSocketSharpResponse(logger, httpContext.Response, this);
|
this.response = new WebSocketSharpResponse(logger, httpContext.Response, this);
|
||||||
|
|
||||||
|
//HandlerFactoryPath = GetHandlerPathIfAny(UrlPrefixes[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetHandlerPathIfAny(string listenerUrl)
|
||||||
|
{
|
||||||
|
if (listenerUrl == null) return null;
|
||||||
|
var pos = listenerUrl.IndexOf("://", StringComparison.OrdinalIgnoreCase);
|
||||||
|
if (pos == -1) return null;
|
||||||
|
var startHostUrl = listenerUrl.Substring(pos + "://".Length);
|
||||||
|
var endPos = startHostUrl.IndexOf('/');
|
||||||
|
if (endPos == -1) return null;
|
||||||
|
var endHostUrl = startHostUrl.Substring(endPos + 1);
|
||||||
|
return string.IsNullOrEmpty(endHostUrl) ? null : endHostUrl.TrimEnd('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
public HttpListenerRequest HttpRequest
|
public HttpListenerRequest HttpRequest
|
||||||
|
@ -584,18 +598,6 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetHandlerPathIfAny(string listenerUrl)
|
|
||||||
{
|
|
||||||
if (listenerUrl == null) return null;
|
|
||||||
var pos = listenerUrl.IndexOf("://", StringComparison.OrdinalIgnoreCase);
|
|
||||||
if (pos == -1) return null;
|
|
||||||
var startHostUrl = listenerUrl.Substring(pos + "://".Length);
|
|
||||||
var endPos = startHostUrl.IndexOf('/');
|
|
||||||
if (endPos == -1) return null;
|
|
||||||
var endHostUrl = startHostUrl.Substring(endPos + 1);
|
|
||||||
return String.IsNullOrEmpty(endHostUrl) ? null : endHostUrl.TrimEnd('/');
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string NormalizePathInfo(string pathInfo, string handlerPath)
|
public static string NormalizePathInfo(string pathInfo, string handlerPath)
|
||||||
{
|
{
|
||||||
if (handlerPath != null && pathInfo.TrimStart('/').StartsWith(
|
if (handlerPath != null && pathInfo.TrimStart('/').StartsWith(
|
||||||
|
|
Loading…
Reference in a new issue