aboutsummaryrefslogtreecommitdiff
path: root/ServiceStack
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-12-04 17:02:21 -0500
committerGitHub <noreply@github.com>2016-12-04 17:02:21 -0500
commit06a8b8af88bad549f3722c6dd13b38df24a57583 (patch)
tree4a99e9bd84d093af9b87c5277346136396a670c9 /ServiceStack
parentf04b7339964ccc574a756207a7af33e21505b3c6 (diff)
parent8c8f2aaba5e4bf573efe2730b5450a8c07abe1b3 (diff)
Merge pull request #2329 from MediaBrowser/dev
Dev
Diffstat (limited to 'ServiceStack')
-rw-r--r--ServiceStack/Host/RestPath.cs13
-rw-r--r--ServiceStack/Host/ServiceController.cs2
-rw-r--r--ServiceStack/HttpHandlerFactory.cs9
3 files changed, 17 insertions, 7 deletions
diff --git a/ServiceStack/Host/RestPath.cs b/ServiceStack/Host/RestPath.cs
index 7222578a9..5bbd03a21 100644
--- a/ServiceStack/Host/RestPath.cs
+++ b/ServiceStack/Host/RestPath.cs
@@ -109,7 +109,7 @@ namespace ServiceStack.Host
this.Notes = notes;
this.restPath = path;
- this.allowsAllVerbs = verbs == null || verbs == WildCard;
+ this.allowsAllVerbs = verbs == null || string.Equals(verbs, WildCard, StringComparison.OrdinalIgnoreCase);
if (!this.allowsAllVerbs)
{
this.allowedVerbs = verbs.ToUpper();
@@ -123,7 +123,7 @@ namespace ServiceStack.Host
{
if (string.IsNullOrEmpty(component)) continue;
- if (component.Contains(VariablePrefix)
+ if (StringContains(component, VariablePrefix)
&& component.IndexOf(ComponentSeperator) != -1)
{
hasSeparators.Add(true);
@@ -240,12 +240,17 @@ namespace ServiceStack.Host
score += Math.Max((10 - VariableArgsCount), 1) * 100;
//Exact verb match is better than ANY
- var exactVerb = httpMethod == AllowedVerbs;
+ var exactVerb = string.Equals(httpMethod, AllowedVerbs, StringComparison.OrdinalIgnoreCase);
score += exactVerb ? 10 : 1;
return score;
}
+ private bool StringContains(string str1, string str2)
+ {
+ return str1.IndexOf(str2, StringComparison.OrdinalIgnoreCase) != -1;
+ }
+
/// <summary>
/// For performance withPathInfoParts should already be a lower case string
/// to minimize redundant matching operations.
@@ -259,7 +264,7 @@ namespace ServiceStack.Host
wildcardMatchCount = 0;
if (withPathInfoParts.Length != this.PathComponentsCount && !this.IsWildCardPath) return false;
- if (!this.allowsAllVerbs && !this.allowedVerbs.Contains(httpMethod.ToUpper())) return false;
+ if (!this.allowsAllVerbs && !StringContains(this.allowedVerbs, httpMethod)) return false;
if (!ExplodeComponents(ref withPathInfoParts)) return false;
if (this.TotalComponentsCount != withPathInfoParts.Length && !this.IsWildCardPath) return false;
diff --git a/ServiceStack/Host/ServiceController.cs b/ServiceStack/Host/ServiceController.cs
index 7eb1253b3..378c21d5d 100644
--- a/ServiceStack/Host/ServiceController.cs
+++ b/ServiceStack/Host/ServiceController.cs
@@ -83,7 +83,7 @@ namespace ServiceStack.Host
}
}
- public readonly Dictionary<string, List<RestPath>> RestPathMap = new Dictionary<string, List<RestPath>>();
+ public readonly Dictionary<string, List<RestPath>> RestPathMap = new Dictionary<string, List<RestPath>>(StringComparer.OrdinalIgnoreCase);
public void RegisterRestPaths(Type requestType)
{
diff --git a/ServiceStack/HttpHandlerFactory.cs b/ServiceStack/HttpHandlerFactory.cs
index d48bfeb5f..5f4892d51 100644
--- a/ServiceStack/HttpHandlerFactory.cs
+++ b/ServiceStack/HttpHandlerFactory.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Services;
using ServiceStack.Host;
@@ -9,12 +10,16 @@ namespace ServiceStack
public class HttpHandlerFactory
{
// Entry point for HttpListener
- public static RestHandler GetHandler(IHttpRequest httpReq)
+ public static RestHandler GetHandler(IHttpRequest httpReq, ILogger logger)
{
var pathInfo = httpReq.PathInfo;
var pathParts = pathInfo.TrimStart('/').Split('/');
- if (pathParts.Length == 0) return null;
+ if (pathParts.Length == 0)
+ {
+ logger.Error("Path parts empty for PathInfo: {0}, Url: {1}", pathInfo, httpReq.RawUrl);
+ return null;
+ }
string contentType;
var restPath = RestHandler.FindMatchingRestPath(httpReq.HttpMethod, pathInfo, out contentType);