diff options
| author | Bond-009 <bond.009@outlook.com> | 2019-02-16 17:05:44 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-16 17:05:44 +0100 |
| commit | 4811e76860c9ad71c14dc8548e70ef001458bf80 (patch) | |
| tree | 997310af3cace45c32d502ebf7841c41efcef078 /Jellyfin.Server/SocketSharp/WebSocketSharpRequest.cs | |
| parent | 5835c4b21d5ab2666478f29c240d2e56316e1f67 (diff) | |
| parent | 25c2267a89af5c2e82774c638cdad0defcc894b5 (diff) | |
Merge branch 'master' into perf
Diffstat (limited to 'Jellyfin.Server/SocketSharp/WebSocketSharpRequest.cs')
| -rw-r--r-- | Jellyfin.Server/SocketSharp/WebSocketSharpRequest.cs | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/Jellyfin.Server/SocketSharp/WebSocketSharpRequest.cs b/Jellyfin.Server/SocketSharp/WebSocketSharpRequest.cs index c2b71e9ef..6458707d9 100644 --- a/Jellyfin.Server/SocketSharp/WebSocketSharpRequest.cs +++ b/Jellyfin.Server/SocketSharp/WebSocketSharpRequest.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Text; using Emby.Server.Implementations.HttpServer; @@ -24,7 +25,7 @@ namespace Jellyfin.Server.SocketSharp this.request = httpContext.Request; this.response = new WebSocketSharpResponse(logger, httpContext.Response, this); - //HandlerFactoryPath = GetHandlerPathIfAny(UrlPrefixes[0]); + // HandlerFactoryPath = GetHandlerPathIfAny(UrlPrefixes[0]); } public HttpListenerRequest HttpRequest => request; @@ -45,9 +46,11 @@ namespace Jellyfin.Server.SocketSharp public string UserHostAddress => request.UserHostAddress; - public string XForwardedFor => string.IsNullOrEmpty(request.Headers["X-Forwarded-For"]) ? null : request.Headers["X-Forwarded-For"]; + public string XForwardedFor + => string.IsNullOrEmpty(request.Headers["X-Forwarded-For"]) ? null : request.Headers["X-Forwarded-For"]; - public int? XForwardedPort => string.IsNullOrEmpty(request.Headers["X-Forwarded-Port"]) ? (int?)null : int.Parse(request.Headers["X-Forwarded-Port"]); + public int? XForwardedPort + => string.IsNullOrEmpty(request.Headers["X-Forwarded-Port"]) ? (int?)null : int.Parse(request.Headers["X-Forwarded-Port"], CultureInfo.InvariantCulture); public string XForwardedProtocol => string.IsNullOrEmpty(request.Headers["X-Forwarded-Proto"]) ? null : request.Headers["X-Forwarded-Proto"]; @@ -83,6 +86,7 @@ namespace Jellyfin.Server.SocketSharp switch (crlf) { case 0: + { if (c == '\r') { crlf = 1; @@ -97,29 +101,39 @@ namespace Jellyfin.Server.SocketSharp { throw new ArgumentException("net_WebHeaderInvalidControlChars"); } + break; + } case 1: + { if (c == '\n') { crlf = 2; break; } + throw new ArgumentException("net_WebHeaderInvalidCRLFChars"); + } case 2: + { if (c == ' ' || c == '\t') { crlf = 0; break; } + throw new ArgumentException("net_WebHeaderInvalidCRLFChars"); + } } } + if (crlf != 0) { throw new ArgumentException("net_WebHeaderInvalidCRLFChars"); } + return name; } @@ -132,6 +146,7 @@ namespace Jellyfin.Server.SocketSharp return true; } } + return false; } @@ -337,6 +352,7 @@ namespace Jellyfin.Server.SocketSharp this.pathInfo = System.Net.WebUtility.UrlDecode(pathInfo); this.pathInfo = NormalizePathInfo(pathInfo, mode); } + return this.pathInfo; } } @@ -438,7 +454,7 @@ namespace Jellyfin.Server.SocketSharp public string ContentType => request.ContentType; - public Encoding contentEncoding; + private Encoding contentEncoding; public Encoding ContentEncoding { get => contentEncoding ?? request.ContentEncoding; @@ -496,6 +512,7 @@ namespace Jellyfin.Server.SocketSharp i++; } } + return httpFiles; } } |
