[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick style fix #838

Merged
merged 1 commit into from
Feb 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions Jellyfin.Server/SocketSharp/WebSocketSharpRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ private static string GetHandlerPathIfAny(string listenerUrl)

private static readonly char[] HttpTrimCharacters = new char[] { (char)0x09, (char)0xA, (char)0xB, (char)0xC, (char)0xD, (char)0x20 };

//
// CheckBadChars - throws on invalid chars to be not found in header name/value
//
internal static string CheckBadChars(string name)
{
if (name == null || name.Length == 0)
Expand All @@ -97,11 +95,11 @@ internal static string CheckBadChars(string name)
}

// VALUE check
//Trim spaces from both ends
// Trim spaces from both ends
name = name.Trim(HttpTrimCharacters);

//First, check for correctly formed multi-line value
//Second, check for absenece of CTL characters
// First, check for correctly formed multi-line value
// Second, check for absenece of CTL characters
int crlf = 0;
for (int i = 0; i < name.Length; ++i)
{
Expand Down Expand Up @@ -198,7 +196,10 @@ public string ResponseContentType
public static string GetResponseContentType(IRequest httpReq)
{
var specifiedContentType = GetQueryStringContentType(httpReq);
if (!string.IsNullOrEmpty(specifiedContentType)) return specifiedContentType;
if (!string.IsNullOrEmpty(specifiedContentType))
{
return specifiedContentType;
}

var serverDefaultContentType = "application/json";

Expand Down Expand Up @@ -237,7 +238,7 @@ public static string GetResponseContentType(IRequest httpReq)
return Soap11;
}

//We could also send a '406 Not Acceptable', but this is allowed also
// We could also send a '406 Not Acceptable', but this is allowed also
return serverDefaultContentType;
}

Expand All @@ -252,7 +253,10 @@ public static bool HasAnyOfContentTypes(IRequest request, params string[] conten

foreach (var contentType in contentTypes)
{
if (IsContentType(request, contentType)) return true;
if (IsContentType(request, contentType))
{
return true;
}
}

return false;
Expand All @@ -274,18 +278,20 @@ private static string GetQueryStringContentType(IRequest httpReq)
{
return null;
}

if (pi[0] == '/')
{
pi = pi.Substring(1);
}

format = LeftPart(pi, '/');
if (format.Length > formatMaxLength)
{
return null;
}
}

format = LeftPart(format, '.').ToLowerInvariant();
format = LeftPart(format, '.');
if (format.Contains("json", StringComparison.OrdinalIgnoreCase))
{
return "application/json";
Expand Down Expand Up @@ -349,7 +355,7 @@ private static string GetPathInfo(string fullPath, string mode, string appPath)
return pathInfo;
}

//Wildcard mode relies on this to work out the handlerPath
// Wildcard mode relies on this to work out the handlerPath
pathInfo = ResolvePathInfoFromMappedPath(fullPath, appPath);
if (!string.IsNullOrEmpty(pathInfo))
{
Expand Down