✨ Pool support wildcard in accept types
This commit is contained in:
@@ -228,13 +228,33 @@ public abstract class TusService
|
|||||||
);
|
);
|
||||||
rejected = true;
|
rejected = true;
|
||||||
}
|
}
|
||||||
else if (!policy.AcceptTypes.Contains(contentType))
|
else
|
||||||
{
|
{
|
||||||
eventContext.FailRequest(
|
var foundMatch = false;
|
||||||
HttpStatusCode.Forbidden,
|
foreach (var acceptType in policy.AcceptTypes)
|
||||||
$"Content type {contentType} is not allowed by the pool's policy"
|
{
|
||||||
);
|
if (acceptType.EndsWith("/*", StringComparison.OrdinalIgnoreCase))
|
||||||
rejected = true;
|
{
|
||||||
|
var type = acceptType[..^2];
|
||||||
|
if (!contentType.StartsWith($"{type}/", StringComparison.OrdinalIgnoreCase)) continue;
|
||||||
|
foundMatch = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (acceptType.Equals(contentType, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
foundMatch = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!foundMatch)
|
||||||
|
{
|
||||||
|
eventContext.FailRequest(
|
||||||
|
HttpStatusCode.Forbidden,
|
||||||
|
$"Content type {contentType} is not allowed by the pool's policy"
|
||||||
|
);
|
||||||
|
rejected = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user