Replacing NotNullAttribute with thrown exceptions
This commit is contained in:
parent
f4a25b1408
commit
58974a9def
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
"type": "git",
|
||||
"url": "git://github.com/aspnet/httpabstractions"
|
||||
},
|
||||
"compilationOptions": {
|
||||
"warningsAsErrors": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.Framework.WebEncoders.Core": "1.0.0-*"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http.Features.Authentication;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Authentication
|
||||
{
|
||||
|
|
@ -13,10 +13,15 @@ namespace Microsoft.AspNet.Http.Authentication
|
|||
{
|
||||
public abstract IEnumerable<AuthenticationDescription> GetAuthenticationSchemes();
|
||||
|
||||
public abstract Task AuthenticateAsync([NotNull] AuthenticateContext context);
|
||||
public abstract Task AuthenticateAsync(AuthenticateContext context);
|
||||
|
||||
public virtual async Task<ClaimsPrincipal> AuthenticateAsync([NotNull] string authenticationScheme)
|
||||
public virtual async Task<ClaimsPrincipal> AuthenticateAsync(string authenticationScheme)
|
||||
{
|
||||
if (authenticationScheme == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(authenticationScheme));
|
||||
}
|
||||
|
||||
var context = new AuthenticateContext(authenticationScheme);
|
||||
await AuthenticateAsync(context);
|
||||
return context.Principal;
|
||||
|
|
@ -32,42 +37,77 @@ namespace Microsoft.AspNet.Http.Authentication
|
|||
return ChallengeAsync(authenticationScheme: string.Empty, properties: properties);
|
||||
}
|
||||
|
||||
public virtual Task ChallengeAsync([NotNull] string authenticationScheme)
|
||||
public virtual Task ChallengeAsync(string authenticationScheme)
|
||||
{
|
||||
if (authenticationScheme == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(authenticationScheme));
|
||||
}
|
||||
|
||||
return ChallengeAsync(authenticationScheme: authenticationScheme, properties: null);
|
||||
}
|
||||
|
||||
// Leave it up to authentication handler to do the right thing for the challenge
|
||||
public virtual Task ChallengeAsync([NotNull] string authenticationScheme, AuthenticationProperties properties)
|
||||
public virtual Task ChallengeAsync(string authenticationScheme, AuthenticationProperties properties)
|
||||
{
|
||||
if (authenticationScheme == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(authenticationScheme));
|
||||
}
|
||||
|
||||
return ChallengeAsync(authenticationScheme, properties, ChallengeBehavior.Automatic);
|
||||
}
|
||||
|
||||
public virtual Task SignInAsync([NotNull] string authenticationScheme, [NotNull] ClaimsPrincipal principal)
|
||||
public virtual Task SignInAsync(string authenticationScheme, ClaimsPrincipal principal)
|
||||
{
|
||||
if (authenticationScheme == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(authenticationScheme));
|
||||
}
|
||||
|
||||
if (principal == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(principal));
|
||||
}
|
||||
|
||||
return SignInAsync(authenticationScheme, principal, properties: null);
|
||||
}
|
||||
|
||||
public virtual Task ForbidAsync([NotNull] string authenticationScheme)
|
||||
public virtual Task ForbidAsync(string authenticationScheme)
|
||||
{
|
||||
if (authenticationScheme == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(authenticationScheme));
|
||||
}
|
||||
|
||||
return ForbidAsync(authenticationScheme, properties: null);
|
||||
}
|
||||
|
||||
// Deny access (typically a 403)
|
||||
public virtual Task ForbidAsync([NotNull] string authenticationScheme, AuthenticationProperties properties)
|
||||
public virtual Task ForbidAsync(string authenticationScheme, AuthenticationProperties properties)
|
||||
{
|
||||
if (authenticationScheme == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(authenticationScheme));
|
||||
}
|
||||
|
||||
return ChallengeAsync(authenticationScheme, properties, ChallengeBehavior.Forbidden);
|
||||
}
|
||||
|
||||
public abstract Task ChallengeAsync([NotNull] string authenticationScheme, AuthenticationProperties properties, ChallengeBehavior behavior);
|
||||
public abstract Task ChallengeAsync(string authenticationScheme, AuthenticationProperties properties, ChallengeBehavior behavior);
|
||||
|
||||
public abstract Task SignInAsync([NotNull] string authenticationScheme, [NotNull] ClaimsPrincipal principal, AuthenticationProperties properties);
|
||||
public abstract Task SignInAsync(string authenticationScheme, ClaimsPrincipal principal, AuthenticationProperties properties);
|
||||
|
||||
public virtual Task SignOutAsync([NotNull] string authenticationScheme)
|
||||
public virtual Task SignOutAsync(string authenticationScheme)
|
||||
{
|
||||
if (authenticationScheme == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(authenticationScheme));
|
||||
}
|
||||
|
||||
return SignOutAsync(authenticationScheme, properties: null);
|
||||
}
|
||||
|
||||
public abstract Task SignOutAsync([NotNull] string authenticationScheme, AuthenticationProperties properties);
|
||||
public abstract Task SignOutAsync(string authenticationScheme, AuthenticationProperties properties);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Http
|
||||
{
|
||||
|
|
@ -21,8 +20,18 @@ namespace Microsoft.AspNet.Http
|
|||
/// <param name="text"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static Task WriteAsync([NotNull] this HttpResponse response, [NotNull] string text, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public static Task WriteAsync(this HttpResponse response, string text, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
if (response == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(response));
|
||||
}
|
||||
|
||||
if (text == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(text));
|
||||
}
|
||||
|
||||
return response.WriteAsync(text, Encoding.UTF8, cancellationToken);
|
||||
}
|
||||
|
||||
|
|
@ -34,8 +43,23 @@ namespace Microsoft.AspNet.Http
|
|||
/// <param name="encoding"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static Task WriteAsync([NotNull] this HttpResponse response, [NotNull] string text, [NotNull] Encoding encoding, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public static Task WriteAsync(this HttpResponse response, string text, Encoding encoding, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
if (response == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(response));
|
||||
}
|
||||
|
||||
if (text == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(text));
|
||||
}
|
||||
|
||||
if (encoding == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(encoding));
|
||||
}
|
||||
|
||||
byte[] data = encoding.GetBytes(text);
|
||||
return response.Body.WriteAsync(data, 0, data.Length, cancellationToken);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Builder.Extensions;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Builder
|
||||
{
|
||||
|
|
@ -18,8 +17,18 @@ namespace Microsoft.AspNet.Builder
|
|||
/// <param name="pathMatch">The path to match</param>
|
||||
/// <param name="configuration">The branch to take for positive path matches</param>
|
||||
/// <returns></returns>
|
||||
public static IApplicationBuilder Map([NotNull] this IApplicationBuilder app, PathString pathMatch, [NotNull] Action<IApplicationBuilder> configuration)
|
||||
public static IApplicationBuilder Map(this IApplicationBuilder app, PathString pathMatch, Action<IApplicationBuilder> configuration)
|
||||
{
|
||||
if (app == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(app));
|
||||
}
|
||||
|
||||
if (configuration == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(configuration));
|
||||
}
|
||||
|
||||
if (pathMatch.HasValue && pathMatch.Value.EndsWith("/", StringComparison.Ordinal))
|
||||
{
|
||||
throw new ArgumentException("The path must not end with a '/'", nameof(pathMatch));
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Builder.Extensions
|
||||
{
|
||||
|
|
@ -12,14 +12,29 @@ namespace Microsoft.AspNet.Builder.Extensions
|
|||
private readonly RequestDelegate _next;
|
||||
private readonly MapOptions _options;
|
||||
|
||||
public MapMiddleware([NotNull] RequestDelegate next, [NotNull] MapOptions options)
|
||||
public MapMiddleware(RequestDelegate next, MapOptions options)
|
||||
{
|
||||
if (next == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(next));
|
||||
}
|
||||
|
||||
if (options == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
_next = next;
|
||||
_options = options;
|
||||
}
|
||||
|
||||
public async Task Invoke([NotNull] HttpContext context)
|
||||
public async Task Invoke(HttpContext context)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(context));
|
||||
}
|
||||
|
||||
PathString path = context.Request.Path;
|
||||
PathString remainingPath;
|
||||
if (path.StartsWithSegments(_options.PathMatch, out remainingPath))
|
||||
|
|
|
|||
|
|
@ -2,10 +2,9 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Builder.Extensions;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
|
||||
namespace Microsoft.AspNet.Builder
|
||||
{
|
||||
|
|
@ -23,8 +22,23 @@ namespace Microsoft.AspNet.Builder
|
|||
/// <param name="predicate">Invoked with the request environment to determine if the branch should be taken</param>
|
||||
/// <param name="configuration">Configures a branch to take</param>
|
||||
/// <returns></returns>
|
||||
public static IApplicationBuilder MapWhen([NotNull] this IApplicationBuilder app, [NotNull] Predicate predicate, [NotNull] Action<IApplicationBuilder> configuration)
|
||||
public static IApplicationBuilder MapWhen(this IApplicationBuilder app, Predicate predicate, Action<IApplicationBuilder> configuration)
|
||||
{
|
||||
if (app == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(app));
|
||||
}
|
||||
|
||||
if (predicate == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(predicate));
|
||||
}
|
||||
|
||||
if (configuration == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(configuration));
|
||||
}
|
||||
|
||||
// create branch
|
||||
var branchBuilder = app.New();
|
||||
configuration(branchBuilder);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Builder.Extensions
|
||||
{
|
||||
|
|
@ -12,14 +12,29 @@ namespace Microsoft.AspNet.Builder.Extensions
|
|||
private readonly RequestDelegate _next;
|
||||
private readonly MapWhenOptions _options;
|
||||
|
||||
public MapWhenMiddleware([NotNull] RequestDelegate next, [NotNull] MapWhenOptions options)
|
||||
public MapWhenMiddleware(RequestDelegate next, MapWhenOptions options)
|
||||
{
|
||||
if (next == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(next));
|
||||
}
|
||||
|
||||
if (options == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
_next = next;
|
||||
_options = options;
|
||||
}
|
||||
|
||||
public async Task Invoke([NotNull] HttpContext context)
|
||||
public async Task Invoke(HttpContext context)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(context));
|
||||
}
|
||||
|
||||
if (_options.Predicate(context))
|
||||
{
|
||||
await _options.Branch(context);
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Builder.Extensions
|
||||
{
|
||||
|
|
@ -13,14 +11,26 @@ namespace Microsoft.AspNet.Builder.Extensions
|
|||
/// </summary>
|
||||
public class MapWhenOptions
|
||||
{
|
||||
private Func<HttpContext, bool> _predicate;
|
||||
|
||||
/// <summary>
|
||||
/// The user callback that determines if the branch should be taken
|
||||
/// </summary>
|
||||
public Func<HttpContext, bool> Predicate
|
||||
{
|
||||
get;
|
||||
[param: NotNull]
|
||||
set;
|
||||
get
|
||||
{
|
||||
return _predicate;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
_predicate = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -2,16 +2,23 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Builder
|
||||
{
|
||||
public static class RunExtensions
|
||||
{
|
||||
public static void Run([NotNull] this IApplicationBuilder app, [NotNull] RequestDelegate handler)
|
||||
public static void Run(this IApplicationBuilder app, RequestDelegate handler)
|
||||
{
|
||||
if (app == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(app));
|
||||
}
|
||||
|
||||
if (handler == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(handler));
|
||||
}
|
||||
|
||||
app.Use(_ => handler);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Http
|
||||
{
|
||||
|
|
@ -91,8 +90,13 @@ namespace Microsoft.AspNet.Http
|
|||
/// </summary>
|
||||
/// <param name="uri">The Uri object</param>
|
||||
/// <returns>The resulting FragmentString</returns>
|
||||
public static FragmentString FromUriComponent([NotNull] Uri uri)
|
||||
public static FragmentString FromUriComponent(Uri uri)
|
||||
{
|
||||
if (uri == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(uri));
|
||||
}
|
||||
|
||||
string fragmentValue = uri.GetComponents(UriComponents.Fragment, UriFormat.UriEscaped);
|
||||
if (!string.IsNullOrEmpty(fragmentValue))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Http
|
||||
{
|
||||
|
|
@ -135,8 +134,13 @@ namespace Microsoft.AspNet.Http
|
|||
/// </summary>
|
||||
/// <param name="uri"></param>
|
||||
/// <returns></returns>
|
||||
public static HostString FromUriComponent([NotNull] Uri uri)
|
||||
public static HostString FromUriComponent(Uri uri)
|
||||
{
|
||||
if (uri == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(uri));
|
||||
}
|
||||
|
||||
return new HostString(uri.GetComponents(
|
||||
UriComponents.NormalizedHost | // Always convert punycode to Unicode.
|
||||
UriComponents.HostAndPort, UriFormat.Unescaped));
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Http
|
||||
{
|
||||
|
|
@ -33,15 +32,15 @@ namespace Microsoft.AspNet.Http
|
|||
|
||||
public abstract bool HasStarted { get; }
|
||||
|
||||
public abstract void OnStarting([NotNull] Func<object, Task> callback, object state);
|
||||
public abstract void OnStarting(Func<object, Task> callback, object state);
|
||||
|
||||
public virtual void OnStarting([NotNull] Func<Task> callback) => OnStarting(_callbackDelegate, callback);
|
||||
public virtual void OnStarting(Func<Task> callback) => OnStarting(_callbackDelegate, callback);
|
||||
|
||||
public abstract void OnCompleted([NotNull] Func<object, Task> callback, object state);
|
||||
public abstract void OnCompleted(Func<object, Task> callback, object state);
|
||||
|
||||
public virtual void RegisterForDispose([NotNull] IDisposable disposable) => OnCompleted(_disposeDelegate, disposable);
|
||||
public virtual void RegisterForDispose(IDisposable disposable) => OnCompleted(_disposeDelegate, disposable);
|
||||
|
||||
public virtual void OnCompleted([NotNull] Func<Task> callback) => OnCompleted(_callbackDelegate, callback);
|
||||
public virtual void OnCompleted(Func<Task> callback) => OnCompleted(_callbackDelegate, callback);
|
||||
|
||||
public virtual void Redirect(string location) => Redirect(location, permanent: false);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.WebEncoders;
|
||||
|
||||
namespace Microsoft.AspNet.Http
|
||||
|
|
@ -88,8 +87,13 @@ namespace Microsoft.AspNet.Http
|
|||
/// </summary>
|
||||
/// <param name="uri">The Uri object</param>
|
||||
/// <returns>The resulting PathString</returns>
|
||||
public static PathString FromUriComponent([NotNull] Uri uri)
|
||||
public static PathString FromUriComponent(Uri uri)
|
||||
{
|
||||
if (uri == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(uri));
|
||||
}
|
||||
|
||||
// REVIEW: what is the exactly correct thing to do?
|
||||
return new PathString("/" + uri.GetComponents(UriComponents.Path, UriFormat.Unescaped));
|
||||
}
|
||||
|
|
@ -128,8 +132,8 @@ namespace Microsoft.AspNet.Http
|
|||
/// <returns>The combined PathString value</returns>
|
||||
public PathString Add(PathString other)
|
||||
{
|
||||
if (HasValue &&
|
||||
other.HasValue &&
|
||||
if (HasValue &&
|
||||
other.HasValue &&
|
||||
Value[Value.Length - 1] == '/')
|
||||
{
|
||||
// If the path string has a trailing slash and the other string has a leading slash, we need
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.Primitives;
|
||||
using Microsoft.Framework.WebEncoders;
|
||||
|
||||
|
|
@ -97,8 +96,13 @@ namespace Microsoft.AspNet.Http
|
|||
/// </summary>
|
||||
/// <param name="uri">The Uri object</param>
|
||||
/// <returns>The resulting QueryString</returns>
|
||||
public static QueryString FromUriComponent([NotNull] Uri uri)
|
||||
public static QueryString FromUriComponent(Uri uri)
|
||||
{
|
||||
if (uri == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(uri));
|
||||
}
|
||||
|
||||
string queryValue = uri.GetComponents(UriComponents.Query, UriFormat.UriEscaped);
|
||||
if (!string.IsNullOrEmpty(queryValue))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,10 +5,12 @@
|
|||
"type": "git",
|
||||
"url": "git://github.com/aspnet/httpabstractions"
|
||||
},
|
||||
"compilationOptions": {
|
||||
"warningsAsErrors": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Http.Features": "1.0.0-*",
|
||||
"Microsoft.Framework.ActivatorUtilities.Sources": { "type": "build", "version": "1.0.0-*" },
|
||||
"Microsoft.Framework.NotNullAttribute.Sources": { "type": "build", "version": "1.0.0-*" },
|
||||
"Microsoft.Framework.WebEncoders.Core": "1.0.0-*"
|
||||
},
|
||||
"frameworks": {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Http
|
||||
{
|
||||
|
|
@ -21,8 +21,13 @@ namespace Microsoft.AspNet.Http
|
|||
/// </summary>
|
||||
/// <param name="formFile">The <see cref="IFormFile"/>.</param>
|
||||
/// <param name="filename">The name of the file to create.</param>
|
||||
public static void SaveAs([NotNull] this IFormFile formFile, string filename)
|
||||
public static void SaveAs(this IFormFile formFile, string filename)
|
||||
{
|
||||
if (formFile == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(formFile));
|
||||
}
|
||||
|
||||
using (var fileStream = new FileStream(filename, FileMode.Create))
|
||||
{
|
||||
var inputStream = formFile.OpenReadStream();
|
||||
|
|
@ -35,10 +40,15 @@ namespace Microsoft.AspNet.Http
|
|||
/// </summary>
|
||||
/// <param name="formFile">The <see cref="IFormFile"/>.</param>
|
||||
/// <param name="filename">The name of the file to create.</param>
|
||||
public async static Task SaveAsAsync([NotNull] this IFormFile formFile,
|
||||
public async static Task SaveAsAsync(this IFormFile formFile,
|
||||
string filename,
|
||||
CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
if (formFile == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(formFile));
|
||||
}
|
||||
|
||||
using (var fileStream = new FileStream(filename, FileMode.Create))
|
||||
{
|
||||
var inputStream = formFile.OpenReadStream();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNet.Http.Headers;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.Primitives;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
|
||||
|
|
@ -26,13 +25,33 @@ namespace Microsoft.AspNet.Http
|
|||
|
||||
// These are all shared helpers used by both RequestHeaders and ResponseHeaders
|
||||
|
||||
internal static DateTimeOffset? GetDate([NotNull] this IHeaderDictionary headers, [NotNull] string name)
|
||||
internal static DateTimeOffset? GetDate(this IHeaderDictionary headers, string name)
|
||||
{
|
||||
if (headers == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(headers));
|
||||
}
|
||||
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
return headers.Get<DateTimeOffset?>(name);
|
||||
}
|
||||
|
||||
internal static void Set([NotNull] this IHeaderDictionary headers, [NotNull] string name, object value)
|
||||
internal static void Set(this IHeaderDictionary headers, string name, object value)
|
||||
{
|
||||
if (headers == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(headers));
|
||||
}
|
||||
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
headers.Remove(name);
|
||||
|
|
@ -43,8 +62,18 @@ namespace Microsoft.AspNet.Http
|
|||
}
|
||||
}
|
||||
|
||||
internal static void SetList<T>([NotNull] this IHeaderDictionary headers, [NotNull] string name, IList<T> values)
|
||||
internal static void SetList<T>(this IHeaderDictionary headers, string name, IList<T> values)
|
||||
{
|
||||
if (headers == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(headers));
|
||||
}
|
||||
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
if (values == null || values.Count == 0)
|
||||
{
|
||||
headers.Remove(name);
|
||||
|
|
@ -55,8 +84,18 @@ namespace Microsoft.AspNet.Http
|
|||
}
|
||||
}
|
||||
|
||||
internal static void SetDate([NotNull] this IHeaderDictionary headers, [NotNull] string name, DateTimeOffset? value)
|
||||
internal static void SetDate(this IHeaderDictionary headers, string name, DateTimeOffset? value)
|
||||
{
|
||||
if (headers == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(headers));
|
||||
}
|
||||
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
if (value.HasValue)
|
||||
{
|
||||
headers[name] = HeaderUtilities.FormatDate(value.Value);
|
||||
|
|
@ -89,8 +128,13 @@ namespace Microsoft.AspNet.Http
|
|||
{ typeof(SetCookieHeaderValue), new Func<IList<string>, IList<SetCookieHeaderValue>>(value => { IList<SetCookieHeaderValue> result; return SetCookieHeaderValue.TryParseList(value, out result) ? result : null; }) },
|
||||
};
|
||||
|
||||
internal static T Get<T>([NotNull] this IHeaderDictionary headers, string name)
|
||||
internal static T Get<T>(this IHeaderDictionary headers, string name)
|
||||
{
|
||||
if (headers == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(headers));
|
||||
}
|
||||
|
||||
object temp;
|
||||
if (KnownParsers.TryGetValue(typeof(T), out temp))
|
||||
{
|
||||
|
|
@ -107,8 +151,13 @@ namespace Microsoft.AspNet.Http
|
|||
return GetViaReflection<T>(value);
|
||||
}
|
||||
|
||||
internal static IList<T> GetList<T>([NotNull] this IHeaderDictionary headers, string name)
|
||||
internal static IList<T> GetList<T>(this IHeaderDictionary headers, string name)
|
||||
{
|
||||
if (headers == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(headers));
|
||||
}
|
||||
|
||||
object temp;
|
||||
if (KnownListParsers.TryGetValue(typeof(T), out temp))
|
||||
{
|
||||
|
|
@ -169,11 +218,11 @@ namespace Microsoft.AspNet.Http
|
|||
if (string.Equals("TryParseList", methodInfo.Name, StringComparison.Ordinal)
|
||||
&& methodInfo.ReturnParameter.ParameterType.Equals(typeof(Boolean)))
|
||||
{
|
||||
var methodParams = methodInfo.GetParameters();
|
||||
return methodParams.Length == 2
|
||||
&& methodParams[0].ParameterType.Equals(typeof(IList<string>))
|
||||
&& methodParams[1].IsOut
|
||||
&& methodParams[1].ParameterType.Equals(typeof(IList<T>).MakeByRefType());
|
||||
var methodParams = methodInfo.GetParameters();
|
||||
return methodParams.Length == 2
|
||||
&& methodParams[0].ParameterType.Equals(typeof(IList<string>))
|
||||
&& methodParams[1].IsOut
|
||||
&& methodParams[1].ParameterType.Equals(typeof(IList<T>).MakeByRefType());
|
||||
}
|
||||
return false;
|
||||
}).FirstOrDefault();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Framework.Primitives;
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.Primitives;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Internal
|
||||
|
|
@ -35,14 +33,24 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
}
|
||||
}
|
||||
|
||||
public static StringValues GetHeaderUnmodified([NotNull] IDictionary<string, StringValues> headers, string key)
|
||||
public static StringValues GetHeaderUnmodified(IDictionary<string, StringValues> headers, string key)
|
||||
{
|
||||
if (headers == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(headers));
|
||||
}
|
||||
|
||||
StringValues values;
|
||||
return headers.TryGetValue(key, out values) ? values : StringValues.Empty;
|
||||
}
|
||||
|
||||
public static void SetHeaderJoined([NotNull] IDictionary<string, StringValues> headers, [NotNull] string key, StringValues value)
|
||||
public static void SetHeaderJoined(IDictionary<string, StringValues> headers, string key, StringValues value)
|
||||
{
|
||||
if (headers == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(headers));
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(key))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
|
|
@ -89,8 +97,13 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
return value;
|
||||
}
|
||||
|
||||
public static void SetHeaderUnmodified([NotNull] IDictionary<string, StringValues> headers, [NotNull] string key, StringValues? values)
|
||||
public static void SetHeaderUnmodified(IDictionary<string, StringValues> headers, string key, StringValues? values)
|
||||
{
|
||||
if (headers == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(headers));
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(key))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
|
|
@ -105,8 +118,18 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
}
|
||||
}
|
||||
|
||||
public static void AppendHeaderJoined([NotNull] IDictionary<string, StringValues> headers, [NotNull] string key, params string[] values)
|
||||
public static void AppendHeaderJoined(IDictionary<string, StringValues> headers, string key, params string[] values)
|
||||
{
|
||||
if (headers == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(headers));
|
||||
}
|
||||
|
||||
if (key == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
|
||||
if (values == null || values.Length == 0)
|
||||
{
|
||||
return;
|
||||
|
|
@ -123,8 +146,18 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
}
|
||||
}
|
||||
|
||||
public static void AppendHeaderUnmodified([NotNull] IDictionary<string, StringValues> headers, [NotNull] string key, StringValues values)
|
||||
public static void AppendHeaderUnmodified(IDictionary<string, StringValues> headers, string key, StringValues values)
|
||||
{
|
||||
if (headers == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(headers));
|
||||
}
|
||||
|
||||
if (key == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
|
||||
if (values.Count == 0)
|
||||
{
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Internal
|
||||
{
|
||||
|
|
@ -80,8 +79,13 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
return !left.Equals(right);
|
||||
}
|
||||
|
||||
public bool StartsWith([NotNull] string text, StringComparison comparisonType)
|
||||
public bool StartsWith(string text, StringComparison comparisonType)
|
||||
{
|
||||
if (text == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(text));
|
||||
}
|
||||
|
||||
int textLength = text.Length;
|
||||
if (!HasValue || _count < textLength)
|
||||
{
|
||||
|
|
@ -91,8 +95,13 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
return string.Compare(_buffer, _offset, text, 0, textLength, comparisonType) == 0;
|
||||
}
|
||||
|
||||
public bool EndsWith([NotNull] string text, StringComparison comparisonType)
|
||||
public bool EndsWith(string text, StringComparison comparisonType)
|
||||
{
|
||||
if (text == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(text));
|
||||
}
|
||||
|
||||
int textLength = text.Length;
|
||||
if (!HasValue || _count < textLength)
|
||||
{
|
||||
|
|
@ -102,8 +111,13 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
return string.Compare(_buffer, _offset + _count - textLength, text, 0, textLength, comparisonType) == 0;
|
||||
}
|
||||
|
||||
public bool Equals([NotNull] string text, StringComparison comparisonType)
|
||||
public bool Equals(string text, StringComparison comparisonType)
|
||||
{
|
||||
if (text == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(text));
|
||||
}
|
||||
|
||||
int textLength = text.Length;
|
||||
if (!HasValue || _count != textLength)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,15 +4,19 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Headers
|
||||
{
|
||||
public class RequestHeaders
|
||||
{
|
||||
public RequestHeaders([NotNull] IHeaderDictionary headers)
|
||||
public RequestHeaders(IHeaderDictionary headers)
|
||||
{
|
||||
if (headers == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(headers));
|
||||
}
|
||||
|
||||
Headers = headers;
|
||||
}
|
||||
|
||||
|
|
@ -268,23 +272,53 @@ namespace Microsoft.AspNet.Http.Headers
|
|||
return Headers.GetList<T>(name);
|
||||
}
|
||||
|
||||
public void Set([NotNull] string name, object value)
|
||||
public void Set(string name, object value)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
Headers.Set(name, value);
|
||||
}
|
||||
|
||||
public void SetList<T>([NotNull] string name, IList<T> values)
|
||||
public void SetList<T>(string name, IList<T> values)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
Headers.SetList<T>(name, values);
|
||||
}
|
||||
|
||||
public void Append([NotNull] string name, [NotNull] object value)
|
||||
public void Append(string name, object value)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
Headers.Append(name, value.ToString());
|
||||
}
|
||||
|
||||
public void AppendList<T>([NotNull] string name, [NotNull] IList<T> values)
|
||||
public void AppendList<T>(string name, IList<T> values)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
if (values == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(values));
|
||||
}
|
||||
|
||||
Headers.Append(name, values.Select(value => value.ToString()).ToArray());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,15 +5,19 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Http.Extensions;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Headers
|
||||
{
|
||||
public class ResponseHeaders
|
||||
{
|
||||
public ResponseHeaders([NotNull] IHeaderDictionary headers)
|
||||
public ResponseHeaders(IHeaderDictionary headers)
|
||||
{
|
||||
if (headers == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(headers));
|
||||
}
|
||||
|
||||
Headers = headers;
|
||||
}
|
||||
|
||||
|
|
@ -165,23 +169,53 @@ namespace Microsoft.AspNet.Http.Headers
|
|||
return Headers.GetList<T>(name);
|
||||
}
|
||||
|
||||
public void Set([NotNull] string name, object value)
|
||||
public void Set(string name, object value)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
Headers.Set(name, value);
|
||||
}
|
||||
|
||||
public void SetList<T>([NotNull] string name, IList<T> values)
|
||||
public void SetList<T>(string name, IList<T> values)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
Headers.SetList<T>(name, values);
|
||||
}
|
||||
|
||||
public void Append([NotNull] string name, [NotNull] object value)
|
||||
public void Append(string name, object value)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
Headers.Append(name, value.ToString());
|
||||
}
|
||||
|
||||
public void AppendList<T>([NotNull] string name, [NotNull] IList<T> values)
|
||||
public void AppendList<T>(string name, IList<T> values)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
if (values == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(values));
|
||||
}
|
||||
|
||||
Headers.Append(name, values.Select(value => value.ToString()).ToArray());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http.Extensions;
|
||||
using Microsoft.AspNet.Http.Features;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Http
|
||||
{
|
||||
|
|
@ -20,8 +19,13 @@ namespace Microsoft.AspNet.Http
|
|||
/// </summary>
|
||||
/// <param name="response"></param>
|
||||
/// <returns>True if sendfile feature exists in the response.</returns>
|
||||
public static bool SupportsSendFile([NotNull] this HttpResponse response)
|
||||
public static bool SupportsSendFile(this HttpResponse response)
|
||||
{
|
||||
if (response == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(response));
|
||||
}
|
||||
|
||||
return response.HttpContext.Features.Get<IHttpSendFileFeature>() != null;
|
||||
}
|
||||
|
||||
|
|
@ -31,8 +35,18 @@ namespace Microsoft.AspNet.Http
|
|||
/// <param name="response"></param>
|
||||
/// <param name="fileName"></param>
|
||||
/// <returns></returns>
|
||||
public static Task SendFileAsync([NotNull] this HttpResponse response, [NotNull] string fileName)
|
||||
public static Task SendFileAsync(this HttpResponse response, string fileName)
|
||||
{
|
||||
if (response == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(response));
|
||||
}
|
||||
|
||||
if (fileName == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(fileName));
|
||||
}
|
||||
|
||||
return response.SendFileAsync(fileName, 0, null, CancellationToken.None);
|
||||
}
|
||||
|
||||
|
|
@ -45,8 +59,18 @@ namespace Microsoft.AspNet.Http
|
|||
/// <param name="count">The number of types to send, or null to send the remainder of the file.</param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static Task SendFileAsync([NotNull] this HttpResponse response, [NotNull] string fileName, long offset, long? count, CancellationToken cancellationToken)
|
||||
public static Task SendFileAsync(this HttpResponse response, string fileName, long offset, long? count, CancellationToken cancellationToken)
|
||||
{
|
||||
if (response == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(response));
|
||||
}
|
||||
|
||||
if (fileName == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(fileName));
|
||||
}
|
||||
|
||||
var sendFile = response.HttpContext.Features.Get<IHttpSendFileFeature>();
|
||||
if (sendFile == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,9 +5,11 @@
|
|||
"type": "git",
|
||||
"url": "git://github.com/aspnet/httpabstractions"
|
||||
},
|
||||
"dependencies": {
|
||||
"compilationOptions": {
|
||||
"warningsAsErrors": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Http.Abstractions": "1.0.0-*",
|
||||
"Microsoft.Framework.NotNullAttribute.Sources": { "type": "build", "version": "1.0.0-*" },
|
||||
"Microsoft.Framework.WebEncoders.Core": "1.0.0-*",
|
||||
"Microsoft.Net.Http.Headers": "1.0.0-*"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,16 +1,21 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Features.Authentication
|
||||
{
|
||||
public class AuthenticateContext
|
||||
{
|
||||
public AuthenticateContext([NotNull] string authenticationScheme)
|
||||
public AuthenticateContext(string authenticationScheme)
|
||||
{
|
||||
if (authenticationScheme == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(authenticationScheme));
|
||||
}
|
||||
|
||||
AuthenticationScheme = authenticationScheme;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,18 +3,23 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Features.Authentication
|
||||
{
|
||||
public class ChallengeContext
|
||||
{
|
||||
public ChallengeContext([NotNull] string authenticationScheme) : this(authenticationScheme, properties: null, behavior: ChallengeBehavior.Automatic)
|
||||
public ChallengeContext(string authenticationScheme)
|
||||
: this(authenticationScheme, properties: null, behavior: ChallengeBehavior.Automatic)
|
||||
{
|
||||
}
|
||||
|
||||
public ChallengeContext([NotNull] string authenticationScheme, IDictionary<string, string> properties, ChallengeBehavior behavior)
|
||||
public ChallengeContext(string authenticationScheme, IDictionary<string, string> properties, ChallengeBehavior behavior)
|
||||
{
|
||||
if (authenticationScheme == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(authenticationScheme));
|
||||
}
|
||||
|
||||
AuthenticationScheme = authenticationScheme;
|
||||
Properties = properties ?? new Dictionary<string, string>(StringComparer.Ordinal);
|
||||
Behavior = behavior;
|
||||
|
|
|
|||
|
|
@ -4,14 +4,23 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Features.Authentication
|
||||
{
|
||||
public class SignInContext
|
||||
{
|
||||
public SignInContext([NotNull] string authenticationScheme, [NotNull] ClaimsPrincipal principal, IDictionary<string, string> properties)
|
||||
public SignInContext(string authenticationScheme, ClaimsPrincipal principal, IDictionary<string, string> properties)
|
||||
{
|
||||
if (authenticationScheme == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(authenticationScheme));
|
||||
}
|
||||
|
||||
if (principal == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(principal));
|
||||
}
|
||||
|
||||
AuthenticationScheme = authenticationScheme;
|
||||
Principal = principal;
|
||||
Properties = properties ?? new Dictionary<string, string>(StringComparer.Ordinal);
|
||||
|
|
|
|||
|
|
@ -3,14 +3,18 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Features.Authentication
|
||||
{
|
||||
public class SignOutContext
|
||||
{
|
||||
public SignOutContext([NotNull] string authenticationScheme, IDictionary<string, string> properties)
|
||||
public SignOutContext(string authenticationScheme, IDictionary<string, string> properties)
|
||||
{
|
||||
if (authenticationScheme == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(authenticationScheme));
|
||||
}
|
||||
|
||||
AuthenticationScheme = authenticationScheme;
|
||||
Properties = properties ?? new Dictionary<string, string>(StringComparer.Ordinal);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,13 +5,12 @@ using System;
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Features
|
||||
{
|
||||
public class FeatureCollection : IFeatureCollection
|
||||
{
|
||||
private static KeyComparer FeatureKeyComparer = new FeatureCollection.KeyComparer();
|
||||
private static KeyComparer FeatureKeyComparer = new KeyComparer();
|
||||
private readonly IFeatureCollection _defaults;
|
||||
private IDictionary<Type, object> _features;
|
||||
private volatile int _containerRevision;
|
||||
|
|
@ -32,15 +31,25 @@ namespace Microsoft.AspNet.Http.Features
|
|||
|
||||
public bool IsReadOnly { get { return false; } }
|
||||
|
||||
public object this[[NotNull] Type key]
|
||||
public object this[Type key]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (key == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
|
||||
object result;
|
||||
return _features != null && _features.TryGetValue(key, out result) ? result : _defaults?[key];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (key == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
if (_features != null && _features.Remove(key))
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Features
|
||||
{
|
||||
|
|
@ -24,6 +23,6 @@ namespace Microsoft.AspNet.Http.Features
|
|||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns>The requested feature, or null if it is not present.</returns>
|
||||
object this[[NotNull] Type key] { get; set; }
|
||||
object this[Type key] { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,11 +5,10 @@
|
|||
"type": "git",
|
||||
"url": "git://github.com/aspnet/httpabstractions"
|
||||
},
|
||||
"compilationOptions": {
|
||||
"warningsAsErrors": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.Framework.NotNullAttribute.Sources": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
},
|
||||
"Microsoft.Framework.Primitives": "1.0.0-*"
|
||||
},
|
||||
"frameworks": {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ using System.Threading.Tasks;
|
|||
using Microsoft.AspNet.Http.Features;
|
||||
using Microsoft.AspNet.Http.Features.Authentication;
|
||||
using Microsoft.AspNet.Http.Features.Authentication.Internal;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Authentication.Internal
|
||||
{
|
||||
|
|
@ -47,8 +46,13 @@ namespace Microsoft.AspNet.Http.Authentication.Internal
|
|||
return describeContext.Results.Select(description => new AuthenticationDescription(description));
|
||||
}
|
||||
|
||||
public override async Task AuthenticateAsync([NotNull] AuthenticateContext context)
|
||||
public override async Task AuthenticateAsync(AuthenticateContext context)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(context));
|
||||
}
|
||||
|
||||
var handler = HttpAuthenticationFeature.Handler;
|
||||
|
||||
if (handler != null)
|
||||
|
|
@ -62,8 +66,13 @@ namespace Microsoft.AspNet.Http.Authentication.Internal
|
|||
}
|
||||
}
|
||||
|
||||
public override async Task ChallengeAsync([NotNull] string authenticationScheme, AuthenticationProperties properties, ChallengeBehavior behavior)
|
||||
public override async Task ChallengeAsync(string authenticationScheme, AuthenticationProperties properties, ChallengeBehavior behavior)
|
||||
{
|
||||
if (authenticationScheme == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(authenticationScheme));
|
||||
}
|
||||
|
||||
var handler = HttpAuthenticationFeature.Handler;
|
||||
|
||||
var challengeContext = new ChallengeContext(authenticationScheme, properties?.Items, behavior);
|
||||
|
|
@ -78,8 +87,18 @@ namespace Microsoft.AspNet.Http.Authentication.Internal
|
|||
}
|
||||
}
|
||||
|
||||
public override async Task SignInAsync([NotNull] string authenticationScheme, [NotNull] ClaimsPrincipal principal, AuthenticationProperties properties)
|
||||
public override async Task SignInAsync(string authenticationScheme, ClaimsPrincipal principal, AuthenticationProperties properties)
|
||||
{
|
||||
if (authenticationScheme == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(authenticationScheme));
|
||||
}
|
||||
|
||||
if (principal == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(principal));
|
||||
}
|
||||
|
||||
var handler = HttpAuthenticationFeature.Handler;
|
||||
|
||||
var signInContext = new SignInContext(authenticationScheme, principal, properties?.Items);
|
||||
|
|
@ -94,8 +113,13 @@ namespace Microsoft.AspNet.Http.Authentication.Internal
|
|||
}
|
||||
}
|
||||
|
||||
public override async Task SignOutAsync([NotNull] string authenticationScheme, AuthenticationProperties properties)
|
||||
public override async Task SignOutAsync(string authenticationScheme, AuthenticationProperties properties)
|
||||
{
|
||||
if (authenticationScheme == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(authenticationScheme));
|
||||
}
|
||||
|
||||
var handler = HttpAuthenticationFeature.Handler;
|
||||
|
||||
var signOutContext = new SignOutContext(authenticationScheme, properties?.Items);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.AspNet.WebUtilities;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Internal
|
||||
{
|
||||
|
|
@ -39,8 +38,13 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
}
|
||||
}
|
||||
|
||||
public static HttpRequest EnableRewind([NotNull] this HttpRequest request, int bufferThreshold = DefaultBufferThreshold)
|
||||
public static HttpRequest EnableRewind(this HttpRequest request, int bufferThreshold = DefaultBufferThreshold)
|
||||
{
|
||||
if (request == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(request));
|
||||
}
|
||||
|
||||
var body = request.Body;
|
||||
if (!body.CanSeek)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -95,11 +95,21 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
|
||||
public override void OnStarting(Func<object, Task> callback, object state)
|
||||
{
|
||||
if (callback == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(callback));
|
||||
}
|
||||
|
||||
HttpResponseFeature.OnStarting(callback, state);
|
||||
}
|
||||
|
||||
public override void OnCompleted(Func<object, Task> callback, object state)
|
||||
{
|
||||
if (callback == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(callback));
|
||||
}
|
||||
|
||||
HttpResponseFeature.OnCompleted(callback, state);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http.Internal;
|
||||
using Microsoft.AspNet.WebUtilities;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.Primitives;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
|
||||
|
|
@ -19,13 +18,23 @@ namespace Microsoft.AspNet.Http.Features.Internal
|
|||
{
|
||||
private readonly HttpRequest _request;
|
||||
|
||||
public FormFeature([NotNull] IFormCollection form)
|
||||
public FormFeature(IFormCollection form)
|
||||
{
|
||||
if (form == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(form));
|
||||
}
|
||||
|
||||
Form = form;
|
||||
}
|
||||
|
||||
public FormFeature([NotNull] HttpRequest request)
|
||||
public FormFeature(HttpRequest request)
|
||||
{
|
||||
if (request == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(request));
|
||||
}
|
||||
|
||||
_request = request;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Http.Internal;
|
||||
using Microsoft.AspNet.WebUtilities;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.Primitives;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Features.Internal
|
||||
|
|
@ -18,18 +17,32 @@ namespace Microsoft.AspNet.Http.Features.Internal
|
|||
private string _original;
|
||||
private IReadableStringCollection _parsedValues;
|
||||
|
||||
public QueryFeature([NotNull] IDictionary<string, StringValues> query)
|
||||
public QueryFeature(IDictionary<string, StringValues> query)
|
||||
: this(new ReadableStringCollection(query))
|
||||
{
|
||||
if (query == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(query));
|
||||
}
|
||||
}
|
||||
|
||||
public QueryFeature([NotNull] IReadableStringCollection query)
|
||||
public QueryFeature(IReadableStringCollection query)
|
||||
{
|
||||
if (query == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(query));
|
||||
}
|
||||
|
||||
_parsedValues = query;
|
||||
}
|
||||
|
||||
public QueryFeature([NotNull] IFeatureCollection features)
|
||||
public QueryFeature(IFeatureCollection features)
|
||||
{
|
||||
if (features == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(features));
|
||||
}
|
||||
|
||||
_features = features;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Http.Internal;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.Primitives;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
|
||||
|
|
@ -19,18 +18,28 @@ namespace Microsoft.AspNet.Http.Features.Internal
|
|||
private StringValues _original;
|
||||
private IReadableStringCollection _parsedValues;
|
||||
|
||||
public RequestCookiesFeature([NotNull] IDictionary<string, StringValues> cookies)
|
||||
public RequestCookiesFeature(IDictionary<string, StringValues> cookies)
|
||||
: this(new ReadableStringCollection(cookies))
|
||||
{
|
||||
}
|
||||
|
||||
public RequestCookiesFeature([NotNull] IReadableStringCollection cookies)
|
||||
public RequestCookiesFeature(IReadableStringCollection cookies)
|
||||
{
|
||||
if (cookies == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(cookies));
|
||||
}
|
||||
|
||||
_parsedValues = cookies;
|
||||
}
|
||||
|
||||
public RequestCookiesFeature([NotNull] IFeatureCollection features)
|
||||
public RequestCookiesFeature(IFeatureCollection features)
|
||||
{
|
||||
if (features == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(features));
|
||||
}
|
||||
|
||||
_features = features;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.Primitives;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Internal
|
||||
|
|
@ -12,17 +12,27 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
/// </summary>
|
||||
public class FormCollection : ReadableStringCollection, IFormCollection
|
||||
{
|
||||
public FormCollection([NotNull] IDictionary<string, StringValues> store)
|
||||
public FormCollection(IDictionary<string, StringValues> store)
|
||||
: this(store, new FormFileCollection())
|
||||
{
|
||||
}
|
||||
|
||||
public FormCollection([NotNull] IDictionary<string, StringValues> store, [NotNull] IFormFileCollection files)
|
||||
public FormCollection(IDictionary<string, StringValues> store, IFormFileCollection files)
|
||||
: base(store)
|
||||
{
|
||||
if (store == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(store));
|
||||
}
|
||||
|
||||
if (files == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(files));
|
||||
}
|
||||
|
||||
Files = files;
|
||||
}
|
||||
|
||||
public IFormFileCollection Files { get; private set; }
|
||||
public IFormFileCollection Files { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.Primitives;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Internal
|
||||
|
|
@ -22,8 +21,13 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
/// Initializes a new instance of the <see cref="T:Microsoft.Owin.HeaderDictionary" /> class.
|
||||
/// </summary>
|
||||
/// <param name="store">The underlying data store.</param>
|
||||
public HeaderDictionary([NotNull] IDictionary<string, StringValues> store)
|
||||
public HeaderDictionary(IDictionary<string, StringValues> store)
|
||||
{
|
||||
if (store == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(store));
|
||||
}
|
||||
|
||||
Store = store;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.Primitives;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
|
||||
|
|
@ -444,8 +443,13 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
|
||||
#endregion
|
||||
|
||||
public bool StartsWith([NotNull] string text, StringComparison comparisonType)
|
||||
public bool StartsWith(string text, StringComparison comparisonType)
|
||||
{
|
||||
if (text == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(text));
|
||||
}
|
||||
|
||||
int textLength = text.Length;
|
||||
if (!HasValue || _count < textLength)
|
||||
{
|
||||
|
|
@ -455,8 +459,13 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
return string.Compare(_buffer, _offset, text, 0, textLength, comparisonType) == 0;
|
||||
}
|
||||
|
||||
public bool EndsWith([NotNull] string text, StringComparison comparisonType)
|
||||
public bool EndsWith(string text, StringComparison comparisonType)
|
||||
{
|
||||
if (text == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(text));
|
||||
}
|
||||
|
||||
int textLength = text.Length;
|
||||
if (!HasValue || _count < textLength)
|
||||
{
|
||||
|
|
@ -466,8 +475,13 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
return string.Compare(_buffer, _offset + _count - textLength, text, 0, textLength, comparisonType) == 0;
|
||||
}
|
||||
|
||||
public bool Equals([NotNull] string text, StringComparison comparisonType)
|
||||
public bool Equals(string text, StringComparison comparisonType)
|
||||
{
|
||||
if (text == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(text));
|
||||
}
|
||||
|
||||
int textLength = text.Length;
|
||||
if (!HasValue || _count != textLength)
|
||||
{
|
||||
|
|
@ -518,14 +532,29 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
}
|
||||
}
|
||||
|
||||
public static StringValues GetHeaderUnmodified([NotNull] IDictionary<string, StringValues> headers, string key)
|
||||
public static StringValues GetHeaderUnmodified(IDictionary<string, StringValues> headers, string key)
|
||||
{
|
||||
if (headers == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(headers));
|
||||
}
|
||||
|
||||
StringValues values;
|
||||
return headers.TryGetValue(key, out values) ? values : StringValues.Empty;
|
||||
}
|
||||
|
||||
public static void SetHeader([NotNull] IDictionary<string, StringValues> headers, [NotNull] string key, StringValues value)
|
||||
public static void SetHeader(IDictionary<string, StringValues> headers, string key, StringValues value)
|
||||
{
|
||||
if (headers == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(headers));
|
||||
}
|
||||
|
||||
if (key == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(key))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
|
|
@ -554,8 +583,13 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
return value;
|
||||
}
|
||||
|
||||
public static long? GetContentLength([NotNull] IHeaderDictionary headers)
|
||||
public static long? GetContentLength(IHeaderDictionary headers)
|
||||
{
|
||||
if (headers == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(headers));
|
||||
}
|
||||
|
||||
const NumberStyles styles = NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite;
|
||||
long value;
|
||||
var rawValue = headers[HeaderNames.ContentLength];
|
||||
|
|
@ -569,8 +603,13 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
return null;
|
||||
}
|
||||
|
||||
public static void SetContentLength([NotNull] IHeaderDictionary headers, long? value)
|
||||
public static void SetContentLength(IHeaderDictionary headers, long? value)
|
||||
{
|
||||
if (headers == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(headers));
|
||||
}
|
||||
|
||||
if (value.HasValue)
|
||||
{
|
||||
headers[HeaderNames.ContentLength] = value.Value.ToString(CultureInfo.InvariantCulture);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.Primitives;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Internal
|
||||
|
|
@ -19,8 +19,13 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
/// Create a new wrapper
|
||||
/// </summary>
|
||||
/// <param name="store"></param>
|
||||
public ReadableStringCollection([NotNull] IDictionary<string, StringValues> store)
|
||||
public ReadableStringCollection(IDictionary<string, StringValues> store)
|
||||
{
|
||||
if (store == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(store));
|
||||
}
|
||||
|
||||
Store = store;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Internal
|
||||
{
|
||||
|
|
@ -21,8 +20,13 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
|
||||
private bool _disposed;
|
||||
|
||||
public ReferenceReadStream([NotNull] Stream inner, long offset, long length)
|
||||
public ReferenceReadStream(Stream inner, long offset, long length)
|
||||
{
|
||||
if (inner == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(inner));
|
||||
}
|
||||
|
||||
_inner = inner;
|
||||
_innerOffset = offset;
|
||||
_length = length;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.Primitives;
|
||||
using Microsoft.Framework.WebEncoders;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
|
|
@ -19,8 +18,13 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
/// Create a new wrapper
|
||||
/// </summary>
|
||||
/// <param name="headers"></param>
|
||||
public ResponseCookies([NotNull] IHeaderDictionary headers)
|
||||
public ResponseCookies(IHeaderDictionary headers)
|
||||
{
|
||||
if (headers == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(headers));
|
||||
}
|
||||
|
||||
Headers = headers;
|
||||
}
|
||||
|
||||
|
|
@ -49,8 +53,13 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="options"></param>
|
||||
public void Append(string key, string value, [NotNull] CookieOptions options)
|
||||
public void Append(string key, string value, CookieOptions options)
|
||||
{
|
||||
if (options == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
var setCookieHeaderValue = new SetCookieHeaderValue(
|
||||
UrlEncoder.Default.UrlEncode(key),
|
||||
UrlEncoder.Default.UrlEncode(value))
|
||||
|
|
@ -91,8 +100,13 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="options"></param>
|
||||
public void Delete(string key, [NotNull] CookieOptions options)
|
||||
public void Delete(string key, CookieOptions options)
|
||||
{
|
||||
if (options == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
var encodedKeyPlusEquals = UrlEncoder.Default.UrlEncode(key) + "=";
|
||||
bool domainHasValue = !string.IsNullOrEmpty(options.Domain);
|
||||
bool pathHasValue = !string.IsNullOrEmpty(options.Path);
|
||||
|
|
|
|||
|
|
@ -5,10 +5,12 @@
|
|||
"type": "git",
|
||||
"url": "git://github.com/aspnet/httpabstractions"
|
||||
},
|
||||
"compilationOptions": {
|
||||
"warningsAsErrors": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Http.Abstractions": "1.0.0-*",
|
||||
"Microsoft.AspNet.WebUtilities": "1.0.0-*",
|
||||
"Microsoft.Framework.NotNullAttribute.Sources": { "type": "build", "version": "1.0.0-*" },
|
||||
"Microsoft.Net.Http.Headers": "1.0.0-*"
|
||||
},
|
||||
"frameworks": {
|
||||
|
|
|
|||
|
|
@ -5,9 +5,11 @@
|
|||
"type": "git",
|
||||
"url": "git://github.com/aspnet/httpabstractions"
|
||||
},
|
||||
"compilationOptions": {
|
||||
"warningsAsErrors": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Http": "1.0.0-*",
|
||||
"Microsoft.Framework.NotNullAttribute.Sources": { "type": "build", "version": "1.0.0-*" }
|
||||
"Microsoft.AspNet.Http": "1.0.0-*"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": { },
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.IO;
|
|||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.WebUtilities
|
||||
{
|
||||
|
|
@ -21,8 +20,13 @@ namespace Microsoft.AspNet.WebUtilities
|
|||
private int _bufferCount = 0;
|
||||
private bool _disposed;
|
||||
|
||||
public BufferedReadStream([NotNull] Stream inner, int bufferSize)
|
||||
public BufferedReadStream(Stream inner, int bufferSize)
|
||||
{
|
||||
if (inner == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(inner));
|
||||
}
|
||||
|
||||
_inner = inner;
|
||||
_buffer = new byte[bufferSize];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.WebUtilities
|
||||
{
|
||||
|
|
@ -30,18 +29,38 @@ namespace Microsoft.AspNet.WebUtilities
|
|||
|
||||
// TODO: allow for an optional buffer size limit to prevent filling hard disks. 1gb?
|
||||
public FileBufferingReadStream(
|
||||
[NotNull] Stream inner,
|
||||
Stream inner,
|
||||
int memoryThreshold,
|
||||
[NotNull] Func<string> tempFileDirectoryAccessor)
|
||||
Func<string> tempFileDirectoryAccessor)
|
||||
{
|
||||
if (inner == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(inner));
|
||||
}
|
||||
|
||||
if (tempFileDirectoryAccessor == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(tempFileDirectoryAccessor));
|
||||
}
|
||||
|
||||
_inner = inner;
|
||||
_memoryThreshold = memoryThreshold;
|
||||
_tempFileDirectoryAccessor = tempFileDirectoryAccessor;
|
||||
}
|
||||
|
||||
// TODO: allow for an optional buffer size limit to prevent filling hard disks. 1gb?
|
||||
public FileBufferingReadStream([NotNull] Stream inner, int memoryThreshold, [NotNull] string tempFileDirectory)
|
||||
public FileBufferingReadStream(Stream inner, int memoryThreshold, string tempFileDirectory)
|
||||
{
|
||||
if (inner == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(inner));
|
||||
}
|
||||
|
||||
if (tempFileDirectory == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(tempFileDirectory));
|
||||
}
|
||||
|
||||
_inner = inner;
|
||||
_memoryThreshold = memoryThreshold;
|
||||
_tempFileDirectory = tempFileDirectory;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ using System.IO;
|
|||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.Primitives;
|
||||
|
||||
namespace Microsoft.AspNet.WebUtilities
|
||||
|
|
@ -23,13 +22,28 @@ namespace Microsoft.AspNet.WebUtilities
|
|||
private int _bufferOffset;
|
||||
private int _bufferCount;
|
||||
|
||||
public FormReader([NotNull] string data)
|
||||
public FormReader(string data)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
|
||||
_reader = new StringReader(data);
|
||||
}
|
||||
|
||||
public FormReader([NotNull] Stream stream, [NotNull] Encoding encoding)
|
||||
public FormReader(Stream stream, Encoding encoding)
|
||||
{
|
||||
if (stream == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(stream));
|
||||
}
|
||||
|
||||
if (encoding == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(encoding));
|
||||
}
|
||||
|
||||
_reader = new StreamReader(stream, encoding, detectEncodingFromByteOrderMarks: true, bufferSize: 1024 * 2, leaveOpen: true);
|
||||
}
|
||||
|
||||
|
|
@ -160,7 +174,7 @@ namespace Microsoft.AspNet.WebUtilities
|
|||
while (pair.HasValue)
|
||||
{
|
||||
accumulator.Append(pair.Value.Key, pair.Value.Value);
|
||||
pair = reader.ReadNextPair();
|
||||
pair = reader.ReadNextPair();
|
||||
}
|
||||
|
||||
return accumulator.GetResults();
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.Primitives;
|
||||
|
||||
namespace Microsoft.AspNet.WebUtilities
|
||||
|
|
@ -21,13 +20,23 @@ namespace Microsoft.AspNet.WebUtilities
|
|||
private readonly string _boundary;
|
||||
private MultipartReaderStream _currentStream;
|
||||
|
||||
public MultipartReader([NotNull] string boundary, [NotNull] Stream stream)
|
||||
public MultipartReader(string boundary, Stream stream)
|
||||
: this(boundary, stream, DefaultBufferSize)
|
||||
{
|
||||
}
|
||||
|
||||
public MultipartReader([NotNull] string boundary, [NotNull] Stream stream, int bufferSize)
|
||||
public MultipartReader(string boundary, Stream stream, int bufferSize)
|
||||
{
|
||||
if (boundary == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(boundary));
|
||||
}
|
||||
|
||||
if (stream == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(stream));
|
||||
}
|
||||
|
||||
if (bufferSize < boundary.Length + 8) // Size of the boundary + leading and trailing CRLF + leading and trailing '--' markers.
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(bufferSize), bufferSize, "Insufficient buffer space, the buffer must be larger than the boundary: " + boundary);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ using System.IO;
|
|||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.WebUtilities
|
||||
{
|
||||
|
|
@ -26,8 +25,18 @@ namespace Microsoft.AspNet.WebUtilities
|
|||
/// </summary>
|
||||
/// <param name="stream"></param>
|
||||
/// <param name="boundary"></param>
|
||||
public MultipartReaderStream([NotNull] BufferedReadStream stream, [NotNull] string boundary, bool expectLeadingCrlf = true)
|
||||
public MultipartReaderStream(BufferedReadStream stream, string boundary, bool expectLeadingCrlf = true)
|
||||
{
|
||||
if (stream == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(stream));
|
||||
}
|
||||
|
||||
if (boundary == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(boundary));
|
||||
}
|
||||
|
||||
_innerStream = stream;
|
||||
_innerOffset = _innerStream.CanSeek ? _innerStream.Position : 0;
|
||||
if (expectLeadingCrlf)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.Primitives;
|
||||
using Microsoft.Framework.WebEncoders;
|
||||
|
||||
|
|
@ -19,10 +18,25 @@ namespace Microsoft.AspNet.WebUtilities
|
|||
/// <param name="name">The name of the query key.</param>
|
||||
/// <param name="value">The query value.</param>
|
||||
/// <returns>The combined result.</returns>
|
||||
public static string AddQueryString([NotNull] string uri, [NotNull] string name, [NotNull] string value)
|
||||
public static string AddQueryString(string uri, string name, string value)
|
||||
{
|
||||
if (uri == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(uri));
|
||||
}
|
||||
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
return AddQueryString(
|
||||
uri, new [] { new KeyValuePair<string, string>(name, value) });
|
||||
uri, new[] { new KeyValuePair<string, string>(name, value) });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -31,15 +45,35 @@ namespace Microsoft.AspNet.WebUtilities
|
|||
/// <param name="uri">The base uri.</param>
|
||||
/// <param name="queryString">A collection of name value query pairs to append.</param>
|
||||
/// <returns>The combined result.</returns>
|
||||
public static string AddQueryString([NotNull] string uri, [NotNull] IDictionary<string, string> queryString)
|
||||
public static string AddQueryString(string uri, IDictionary<string, string> queryString)
|
||||
{
|
||||
if (uri == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(uri));
|
||||
}
|
||||
|
||||
if (queryString == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(queryString));
|
||||
}
|
||||
|
||||
return AddQueryString(uri, (IEnumerable<KeyValuePair<string, string>>)queryString);
|
||||
}
|
||||
|
||||
private static string AddQueryString(
|
||||
[NotNull] string uri,
|
||||
[NotNull] IEnumerable<KeyValuePair<string, string>> queryString)
|
||||
string uri,
|
||||
IEnumerable<KeyValuePair<string, string>> queryString)
|
||||
{
|
||||
if (uri == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(uri));
|
||||
}
|
||||
|
||||
if (queryString == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(queryString));
|
||||
}
|
||||
|
||||
var anchorIndex = uri.IndexOf('#');
|
||||
var uriToBeAppended = uri;
|
||||
var anchorText = "";
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.WebUtilities
|
||||
{
|
||||
|
|
@ -21,8 +20,13 @@ namespace Microsoft.AspNet.WebUtilities
|
|||
/// The input must not contain any whitespace or padding characters.
|
||||
/// Throws FormatException if the input is malformed.
|
||||
/// </remarks>
|
||||
public static byte[] Base64UrlDecode([NotNull] string input)
|
||||
public static byte[] Base64UrlDecode(string input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(input));
|
||||
}
|
||||
|
||||
return Base64UrlDecode(input, 0, input.Length);
|
||||
}
|
||||
|
||||
|
|
@ -37,8 +41,13 @@ namespace Microsoft.AspNet.WebUtilities
|
|||
/// The input must not contain any whitespace or padding characters.
|
||||
/// Throws FormatException if the input is malformed.
|
||||
/// </remarks>
|
||||
public static byte[] Base64UrlDecode([NotNull] string input, int offset, int count)
|
||||
public static byte[] Base64UrlDecode(string input, int offset, int count)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(input));
|
||||
}
|
||||
|
||||
ValidateParameters(input.Length, offset, count);
|
||||
|
||||
// Special-case empty input
|
||||
|
|
@ -83,8 +92,13 @@ namespace Microsoft.AspNet.WebUtilities
|
|||
/// </summary>
|
||||
/// <param name="input">The binary input to encode.</param>
|
||||
/// <returns>The base64url-encoded form of the input.</returns>
|
||||
public static string Base64UrlEncode([NotNull] byte[] input)
|
||||
public static string Base64UrlEncode(byte[] input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(input));
|
||||
}
|
||||
|
||||
return Base64UrlEncode(input, 0, input.Length);
|
||||
}
|
||||
|
||||
|
|
@ -95,8 +109,13 @@ namespace Microsoft.AspNet.WebUtilities
|
|||
/// <param name="offset">The offset into <paramref name="input"/> at which to begin encoding.</param>
|
||||
/// <param name="count">The number of bytes of <paramref name="input"/> to encode.</param>
|
||||
/// <returns>The base64url-encoded form of the input.</returns>
|
||||
public static string Base64UrlEncode([NotNull] byte[] input, int offset, int count)
|
||||
public static string Base64UrlEncode(byte[] input, int offset, int count)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(input));
|
||||
}
|
||||
|
||||
ValidateParameters(input.Length, offset, count);
|
||||
|
||||
// Special-case empty input
|
||||
|
|
|
|||
|
|
@ -5,8 +5,10 @@
|
|||
"type": "git",
|
||||
"url": "git://github.com/aspnet/httpabstractions"
|
||||
},
|
||||
"compilationOptions": {
|
||||
"warningsAsErrors": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.Framework.NotNullAttribute.Sources": { "type": "build", "version": "1.0.0-*" },
|
||||
"Microsoft.Framework.Primitives": "1.0.0-*",
|
||||
"Microsoft.Framework.WebEncoders.Core": "1.0.0-*"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -5,11 +5,8 @@
|
|||
"type": "git",
|
||||
"url": "git://github.com/aspnet/httpabstractions"
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.Framework.NotNullAttribute.Sources": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
}
|
||||
"compilationOptions": {
|
||||
"warningsAsErrors": true
|
||||
},
|
||||
"frameworks": {
|
||||
"net451": { },
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.Framework.WebEncoders
|
||||
{
|
||||
|
|
@ -25,8 +24,13 @@ namespace Microsoft.Framework.WebEncoders
|
|||
/// <summary>
|
||||
/// Instantiates the filter by cloning the allow list of another <see cref="ICodePointFilter"/>.
|
||||
/// </summary>
|
||||
public CodePointFilter([NotNull] ICodePointFilter other)
|
||||
public CodePointFilter(ICodePointFilter other)
|
||||
{
|
||||
if (other == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(other));
|
||||
}
|
||||
|
||||
CodePointFilter otherAsCodePointFilter = other as CodePointFilter;
|
||||
if (otherAsCodePointFilter != null)
|
||||
{
|
||||
|
|
@ -85,8 +89,13 @@ namespace Microsoft.Framework.WebEncoders
|
|||
/// <returns>
|
||||
/// The 'this' instance.
|
||||
/// </returns>
|
||||
public CodePointFilter AllowChars([NotNull] string chars)
|
||||
public CodePointFilter AllowChars(string chars)
|
||||
{
|
||||
if (chars == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(chars));
|
||||
}
|
||||
|
||||
for (int i = 0; i < chars.Length; i++)
|
||||
{
|
||||
_allowedCharsBitmap.AllowCharacter(chars[i]);
|
||||
|
|
@ -100,8 +109,13 @@ namespace Microsoft.Framework.WebEncoders
|
|||
/// <returns>
|
||||
/// The 'this' instance.
|
||||
/// </returns>
|
||||
public CodePointFilter AllowFilter([NotNull] ICodePointFilter filter)
|
||||
public CodePointFilter AllowFilter(ICodePointFilter filter)
|
||||
{
|
||||
if (filter == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(filter));
|
||||
}
|
||||
|
||||
foreach (var allowedCodePoint in filter.GetAllowedCodePoints())
|
||||
{
|
||||
// If the code point can't be represented as a BMP character, skip it.
|
||||
|
|
@ -120,8 +134,13 @@ namespace Microsoft.Framework.WebEncoders
|
|||
/// <returns>
|
||||
/// The 'this' instance.
|
||||
/// </returns>
|
||||
public CodePointFilter AllowRange([NotNull] UnicodeRange range)
|
||||
public CodePointFilter AllowRange(UnicodeRange range)
|
||||
{
|
||||
if (range == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(range));
|
||||
}
|
||||
|
||||
int firstCodePoint = range.FirstCodePoint;
|
||||
int rangeSize = range.RangeSize;
|
||||
for (int i = 0; i < rangeSize; i++)
|
||||
|
|
@ -197,8 +216,13 @@ namespace Microsoft.Framework.WebEncoders
|
|||
/// <returns>
|
||||
/// The 'this' instance.
|
||||
/// </returns>
|
||||
public CodePointFilter ForbidChars([NotNull] string chars)
|
||||
public CodePointFilter ForbidChars(string chars)
|
||||
{
|
||||
if (chars == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(chars));
|
||||
}
|
||||
|
||||
for (int i = 0; i < chars.Length; i++)
|
||||
{
|
||||
_allowedCharsBitmap.ForbidCharacter(chars[i]);
|
||||
|
|
@ -212,8 +236,13 @@ namespace Microsoft.Framework.WebEncoders
|
|||
/// <returns>
|
||||
/// The 'this' instance.
|
||||
/// </returns>
|
||||
public CodePointFilter ForbidRange([NotNull] UnicodeRange range)
|
||||
public CodePointFilter ForbidRange(UnicodeRange range)
|
||||
{
|
||||
if (range == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(range));
|
||||
}
|
||||
|
||||
int firstCodePoint = range.FirstCodePoint;
|
||||
int rangeSize = range.RangeSize;
|
||||
for (int i = 0; i < rangeSize; i++)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.Framework.WebEncoders
|
||||
{
|
||||
|
|
@ -51,9 +50,13 @@ namespace Microsoft.Framework.WebEncoders
|
|||
/// set returned by <paramref name="filter"/>'s <see cref="ICodePointFilter.GetAllowedCodePoints"/>
|
||||
/// method will be escaped.
|
||||
/// </summary>
|
||||
public HtmlEncoder([NotNull] ICodePointFilter filter)
|
||||
public HtmlEncoder(ICodePointFilter filter)
|
||||
: this(new HtmlUnicodeEncoder(CodePointFilter.Wrap(filter)))
|
||||
{
|
||||
if (filter == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(filter));
|
||||
}
|
||||
}
|
||||
|
||||
private HtmlEncoder(HtmlUnicodeEncoder innerEncoder)
|
||||
|
|
@ -97,6 +100,16 @@ namespace Microsoft.Framework.WebEncoders
|
|||
/// </summary>
|
||||
public void HtmlEncode(char[] value, int startIndex, int charCount, TextWriter output)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
if (output == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(output));
|
||||
}
|
||||
|
||||
_innerUnicodeEncoder.Encode(value, startIndex, charCount, output);
|
||||
}
|
||||
|
||||
|
|
@ -113,6 +126,16 @@ namespace Microsoft.Framework.WebEncoders
|
|||
/// </summary>
|
||||
public void HtmlEncode(string value, int startIndex, int charCount, TextWriter output)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
if (output == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(output));
|
||||
}
|
||||
|
||||
_innerUnicodeEncoder.Encode(value, startIndex, charCount, output);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.Framework.WebEncoders
|
||||
{
|
||||
|
|
@ -20,7 +18,7 @@ namespace Microsoft.Framework.WebEncoders
|
|||
/// The encoded value is also appropriately encoded for inclusion inside an HTML attribute
|
||||
/// as long as the attribute value is surrounded by single or double quotes.
|
||||
/// </remarks>
|
||||
void HtmlEncode([NotNull] char[] value, int startIndex, int charCount, [NotNull] TextWriter output);
|
||||
void HtmlEncode(char[] value, int startIndex, int charCount, TextWriter output);
|
||||
|
||||
/// <summary>
|
||||
/// HTML-encodes a given input string.
|
||||
|
|
@ -42,6 +40,6 @@ namespace Microsoft.Framework.WebEncoders
|
|||
/// The encoded value is also appropriately encoded for inclusion inside an HTML attribute
|
||||
/// as long as the attribute value is surrounded by single or double quotes.
|
||||
/// </remarks>
|
||||
void HtmlEncode([NotNull] string value, int startIndex, int charCount, [NotNull] TextWriter output);
|
||||
void HtmlEncode(string value, int startIndex, int charCount, TextWriter output);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.Framework.WebEncoders
|
||||
{
|
||||
|
|
@ -19,7 +17,7 @@ namespace Microsoft.Framework.WebEncoders
|
|||
/// <remarks>
|
||||
/// The encoded value is appropriately encoded for inclusion inside a quoted JSON string.
|
||||
/// </remarks>
|
||||
void JavaScriptStringEncode([NotNull] char[] value, int startIndex, int charCount, [NotNull] TextWriter output);
|
||||
void JavaScriptStringEncode(char[] value, int startIndex, int charCount, TextWriter output);
|
||||
|
||||
/// <summary>
|
||||
/// JavaScript-escapes a given input string.
|
||||
|
|
@ -37,6 +35,6 @@ namespace Microsoft.Framework.WebEncoders
|
|||
/// <remarks>
|
||||
/// The encoded value is appropriately encoded for inclusion inside a quoted JSON string.
|
||||
/// </remarks>
|
||||
void JavaScriptStringEncode([NotNull] string value, int startIndex, int charCount, [NotNull] TextWriter output);
|
||||
void JavaScriptStringEncode(string value, int startIndex, int charCount, TextWriter output);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.Framework.WebEncoders
|
||||
{
|
||||
|
|
@ -20,7 +18,7 @@ namespace Microsoft.Framework.WebEncoders
|
|||
/// The encoded value is appropriately encoded for inclusion in the segment, query, or
|
||||
/// fragment portion of a URI.
|
||||
/// </remarks>
|
||||
void UrlEncode([NotNull] char[] value, int startIndex, int charCount, [NotNull] TextWriter output);
|
||||
void UrlEncode(char[] value, int startIndex, int charCount, TextWriter output);
|
||||
|
||||
/// <summary>
|
||||
/// URL-escapes a given input string.
|
||||
|
|
@ -41,6 +39,6 @@ namespace Microsoft.Framework.WebEncoders
|
|||
/// The encoded value is appropriately encoded for inclusion in the segment, query, or
|
||||
/// fragment portion of a URI.
|
||||
/// </remarks>
|
||||
void UrlEncode([NotNull] string value, int startIndex, int charCount, [NotNull] TextWriter output);
|
||||
void UrlEncode(string value, int startIndex, int charCount, TextWriter output);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.Framework.WebEncoders
|
||||
{
|
||||
|
|
@ -51,9 +50,13 @@ namespace Microsoft.Framework.WebEncoders
|
|||
/// set returned by <paramref name="filter"/>'s <see cref="ICodePointFilter.GetAllowedCodePoints"/>
|
||||
/// method will be escaped.
|
||||
/// </summary>
|
||||
public JavaScriptStringEncoder([NotNull] ICodePointFilter filter)
|
||||
public JavaScriptStringEncoder(ICodePointFilter filter)
|
||||
: this(new JavaScriptStringUnicodeEncoder(CodePointFilter.Wrap(filter)))
|
||||
{
|
||||
if (filter == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(filter));
|
||||
}
|
||||
}
|
||||
|
||||
private JavaScriptStringEncoder(JavaScriptStringUnicodeEncoder innerEncoder)
|
||||
|
|
@ -97,6 +100,16 @@ namespace Microsoft.Framework.WebEncoders
|
|||
/// </summary>
|
||||
public void JavaScriptStringEncode(char[] value, int startIndex, int charCount, TextWriter output)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
if (output == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(output));
|
||||
}
|
||||
|
||||
_innerUnicodeEncoder.Encode(value, startIndex, charCount, output);
|
||||
}
|
||||
|
||||
|
|
@ -113,6 +126,16 @@ namespace Microsoft.Framework.WebEncoders
|
|||
/// </summary>
|
||||
public void JavaScriptStringEncode(string value, int startIndex, int charCount, TextWriter output)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
if (output == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(output));
|
||||
}
|
||||
|
||||
_innerUnicodeEncoder.Encode(value, startIndex, charCount, output);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.Framework.WebEncoders
|
||||
{
|
||||
|
|
@ -51,9 +50,13 @@ namespace Microsoft.Framework.WebEncoders
|
|||
/// set returned by <paramref name="filter"/>'s <see cref="ICodePointFilter.GetAllowedCodePoints"/>
|
||||
/// method will be escaped.
|
||||
/// </summary>
|
||||
public UrlEncoder([NotNull] ICodePointFilter filter)
|
||||
public UrlEncoder(ICodePointFilter filter)
|
||||
: this(new UrlUnicodeEncoder(CodePointFilter.Wrap(filter)))
|
||||
{
|
||||
if (filter == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(filter));
|
||||
}
|
||||
}
|
||||
|
||||
private UrlEncoder(UrlUnicodeEncoder innerEncoder)
|
||||
|
|
@ -97,6 +100,16 @@ namespace Microsoft.Framework.WebEncoders
|
|||
/// </summary>
|
||||
public void UrlEncode(char[] value, int startIndex, int charCount, TextWriter output)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
if (output == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(output));
|
||||
}
|
||||
|
||||
_innerUnicodeEncoder.Encode(value, startIndex, charCount, output);
|
||||
}
|
||||
|
||||
|
|
@ -113,6 +126,16 @@ namespace Microsoft.Framework.WebEncoders
|
|||
/// </summary>
|
||||
public void UrlEncode(string value, int startIndex, int charCount, TextWriter output)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
if (output == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(output));
|
||||
}
|
||||
|
||||
_innerUnicodeEncoder.Encode(value, startIndex, charCount, output);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,10 +6,8 @@
|
|||
"url": "git://github.com/aspnet/httpabstractions"
|
||||
},
|
||||
"compilationOptions": {
|
||||
"allowUnsafe": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.Framework.NotNullAttribute.Sources": { "type": "build", "version": "1.0.0-*" }
|
||||
"allowUnsafe": true,
|
||||
"warningsAsErrors": true
|
||||
},
|
||||
"frameworks": {
|
||||
"net45": { },
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System;
|
||||
using Microsoft.Framework.DependencyInjection.Extensions;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.OptionsModel;
|
||||
using Microsoft.Framework.WebEncoders;
|
||||
|
||||
|
|
@ -11,13 +10,23 @@ namespace Microsoft.Framework.DependencyInjection
|
|||
{
|
||||
public static class EncoderServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddWebEncoders([NotNull] this IServiceCollection services)
|
||||
public static IServiceCollection AddWebEncoders(this IServiceCollection services)
|
||||
{
|
||||
if (services == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(services));
|
||||
}
|
||||
|
||||
return AddWebEncoders(services, configureOptions: null);
|
||||
}
|
||||
|
||||
public static IServiceCollection AddWebEncoders([NotNull] this IServiceCollection services, Action<WebEncoderOptions> configureOptions)
|
||||
public static IServiceCollection AddWebEncoders(this IServiceCollection services, Action<WebEncoderOptions> configureOptions)
|
||||
{
|
||||
if (services == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(services));
|
||||
}
|
||||
|
||||
services.AddOptions();
|
||||
|
||||
// Register the default encoders
|
||||
|
|
|
|||
|
|
@ -5,10 +5,12 @@
|
|||
"type": "git",
|
||||
"url": "git://github.com/aspnet/httpabstractions"
|
||||
},
|
||||
"compilationOptions": {
|
||||
"warningsAsErrors": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.Framework.DependencyInjection.Abstractions": "1.0.0-*",
|
||||
"Microsoft.Framework.OptionsModel": "1.0.0-*",
|
||||
"Microsoft.Framework.NotNullAttribute.Sources": { "type": "build", "version": "1.0.0-*" },
|
||||
"Microsoft.Framework.WebEncoders.Core": "1.0.0-*"
|
||||
},
|
||||
"frameworks": {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Text;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.Net.Http.Headers
|
||||
{
|
||||
|
|
@ -23,13 +22,27 @@ namespace Microsoft.Net.Http.Headers
|
|||
// Used by the parser to create a new instance of this type.
|
||||
}
|
||||
|
||||
public CookieHeaderValue([NotNull] string name)
|
||||
public CookieHeaderValue(string name)
|
||||
: this(name, string.Empty)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
}
|
||||
|
||||
public CookieHeaderValue([NotNull] string name, [NotNull] string value)
|
||||
public CookieHeaderValue(string name, string value)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
Name = name;
|
||||
Value = value;
|
||||
}
|
||||
|
|
@ -219,16 +232,26 @@ namespace Microsoft.Net.Http.Headers
|
|||
return !(c == '"' || c == ',' || c == ';' || c == '\\');
|
||||
}
|
||||
|
||||
internal static void CheckNameFormat([NotNull] string name, string parameterName)
|
||||
internal static void CheckNameFormat(string name, string parameterName)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
if (HttpRuleParser.GetTokenLength(name, 0) != name.Length)
|
||||
{
|
||||
throw new ArgumentException("Invalid cookie name: " + name, parameterName);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void CheckValueFormat([NotNull] string value, string parameterName)
|
||||
internal static void CheckValueFormat(string value, string parameterName)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
string temp;
|
||||
if (GetCookieValueLength(value, 0, out temp) != value.Length)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.Framework.Internal;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Net.Http.Headers
|
||||
{
|
||||
|
|
@ -11,9 +11,14 @@ namespace Microsoft.Net.Http.Headers
|
|||
|
||||
private GetParsedValueLengthDelegate _getParsedValueLength;
|
||||
|
||||
internal GenericHeaderParser(bool supportsMultipleValues, [NotNull] GetParsedValueLengthDelegate getParsedValueLength)
|
||||
internal GenericHeaderParser(bool supportsMultipleValues, GetParsedValueLengthDelegate getParsedValueLength)
|
||||
: base(supportsMultipleValues)
|
||||
{
|
||||
if (getParsedValueLength == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(getParsedValueLength));
|
||||
}
|
||||
|
||||
_getParsedValueLength = getParsedValueLength;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Text;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.Net.Http.Headers
|
||||
{
|
||||
|
|
@ -33,13 +32,23 @@ namespace Microsoft.Net.Http.Headers
|
|||
// Used by the parser to create a new instance of this type.
|
||||
}
|
||||
|
||||
public SetCookieHeaderValue([NotNull] string name)
|
||||
public SetCookieHeaderValue(string name)
|
||||
: this(name, string.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
public SetCookieHeaderValue([NotNull] string name, [NotNull] string value)
|
||||
public SetCookieHeaderValue(string name, string value)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
Name = name;
|
||||
Value = value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.Net.Http.Headers
|
||||
{
|
||||
|
|
@ -39,9 +38,19 @@ namespace Microsoft.Net.Http.Headers
|
|||
/// <param name="stringWithQuality1">The first value to compare.</param>
|
||||
/// <param name="stringWithQuality2">The second value to compare</param>
|
||||
/// <returns>The result of the comparison.</returns>
|
||||
public int Compare([NotNull] StringWithQualityHeaderValue stringWithQuality1,
|
||||
[NotNull] StringWithQualityHeaderValue stringWithQuality2)
|
||||
public int Compare(StringWithQualityHeaderValue stringWithQuality1,
|
||||
StringWithQualityHeaderValue stringWithQuality2)
|
||||
{
|
||||
if (stringWithQuality1 == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(stringWithQuality1));
|
||||
}
|
||||
|
||||
if (stringWithQuality2 == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(stringWithQuality2));
|
||||
}
|
||||
|
||||
var quality1 = stringWithQuality1.Quality ?? HeaderQuality.Match;
|
||||
var quality2 = stringWithQuality2.Quality ?? HeaderQuality.Match;
|
||||
var qualityDifference = quality1 - quality2;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"dependencies": {
|
||||
"Microsoft.Framework.NotNullAttribute.Sources": { "type": "build", "version": "1.0.0-*" }
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/aspnet/httpabstractions"
|
||||
},
|
||||
"compilationOptions": {
|
||||
"warningsAsErrors": true
|
||||
},
|
||||
"frameworks" : {
|
||||
"net45" : { },
|
||||
"dnx451" : { },
|
||||
|
|
|
|||
|
|
@ -43,10 +43,8 @@ namespace Microsoft.AspNet.Builder.Extensions
|
|||
var builder = new ApplicationBuilder(serviceProvider: null);
|
||||
var noMiddleware = new ApplicationBuilder(serviceProvider: null).Build();
|
||||
var noOptions = new MapOptions();
|
||||
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => builder.Map(null, ActionNotImplemented));
|
||||
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => builder.Map("/foo", (Action<IBuilder>)null));
|
||||
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => new MapMiddleware(null, noOptions));
|
||||
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => new MapMiddleware(noMiddleware, null));
|
||||
Assert.Throws<ArgumentNullException>(() => builder.Map("/foo", configuration: null));
|
||||
Assert.Throws<ArgumentNullException>(() => new MapMiddleware(noMiddleware, null));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
|
|||
|
|
@ -11,9 +11,7 @@ using Xunit;
|
|||
|
||||
namespace Microsoft.AspNet.Builder.Extensions
|
||||
{
|
||||
using AppFunc = Func<IDictionary<string, object>, Task>;
|
||||
using Predicate = Func<HttpContext, bool>;
|
||||
using PredicateAsync = Func<HttpContext, Task<bool>>;
|
||||
|
||||
public class MapPredicateMiddlewareTests
|
||||
{
|
||||
|
|
@ -56,15 +54,12 @@ namespace Microsoft.AspNet.Builder.Extensions
|
|||
var builder = new ApplicationBuilder(serviceProvider: null);
|
||||
var noMiddleware = new ApplicationBuilder(serviceProvider: null).Build();
|
||||
var noOptions = new MapWhenOptions();
|
||||
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => builder.MapWhen(null, UseNotImplemented));
|
||||
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => builder.MapWhen(NotImplementedPredicate, (Action<IBuilder>)null));
|
||||
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => new MapWhenMiddleware(null, noOptions));
|
||||
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => new MapWhenMiddleware(noMiddleware, null));
|
||||
|
||||
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => builder.MapWhenAsync(null, UseNotImplemented));
|
||||
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => builder.MapWhenAsync(NotImplementedPredicateAsync, (Action<IBuilder>)null));
|
||||
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => new MapWhenMiddleware(null, noOptions));
|
||||
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => new MapWhenMiddleware(noMiddleware, null));
|
||||
Assert.Throws<ArgumentNullException>(() => builder.MapWhen(null, UseNotImplemented));
|
||||
Assert.Throws<ArgumentNullException>(() => builder.MapWhen(NotImplementedPredicate, configuration: null));
|
||||
Assert.Throws<ArgumentNullException>(() => new MapWhenMiddleware(null, noOptions));
|
||||
Assert.Throws<ArgumentNullException>(() => new MapWhenMiddleware(noMiddleware, null));
|
||||
Assert.Throws<ArgumentNullException>(() => new MapWhenMiddleware(null, noOptions));
|
||||
Assert.Throws<ArgumentNullException>(() => new MapWhenMiddleware(noMiddleware, null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ namespace Microsoft.AspNet.Http.Authentication.Internal
|
|||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(null)]
|
||||
[InlineData("Foo")]
|
||||
public async Task ChallengeWithNoAuthMiddlewareMayThrow(string scheme)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue