Remove or make public pubternals for Http #11312 (#11429)

This commit is contained in:
Chris Ross 2019-06-21 17:56:53 -07:00 committed by GitHub
parent f35564ba06
commit 4ef204e13b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
90 changed files with 222 additions and 536 deletions

View File

@ -5,8 +5,8 @@ using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.Extensions.Primitives;
using Microsoft.Net.Http.Headers;
using Moq;
using Xunit;
@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Antiforgery.Internal
public void GetCookieToken_CookieDoesNotExist_ReturnsNull()
{
// Arrange
var httpContext = GetHttpContext(new RequestCookieCollection());
var httpContext = GetHttpContext();
var options = new AntiforgeryOptions
{
Cookie = { Name = _cookieName }
@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.Antiforgery.Internal
public async Task GetRequestTokens_CookieIsEmpty_ReturnsNullTokens()
{
// Arrange
var httpContext = GetHttpContext(new RequestCookieCollection());
var httpContext = GetHttpContext();
httpContext.Request.Form = FormCollection.Empty;
var options = new AntiforgeryOptions
@ -407,18 +407,14 @@ namespace Microsoft.AspNetCore.Antiforgery.Internal
private HttpContext GetHttpContext(string cookieName, string cookieValue)
{
var cookies = new RequestCookieCollection(new Dictionary<string, string>
{
{ cookieName, cookieValue },
});
return GetHttpContext(cookies);
var context = GetHttpContext();
context.Request.Headers[HeaderNames.Cookie] = $"{cookieName}={cookieValue}";
return context;
}
private HttpContext GetHttpContext(IRequestCookieCollection cookies)
private HttpContext GetHttpContext()
{
var httpContext = new DefaultHttpContext();
httpContext.Request.Cookies = cookies;
return httpContext;
}

View File

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

View File

@ -3,7 +3,6 @@
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.AspNetCore.Http.Features;
namespace Microsoft.AspNetCore.Hosting.Builder

View File

@ -4,7 +4,6 @@
using System;
using System.Reflection;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.AspNetCore.Hosting.Internal;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
@ -52,4 +51,4 @@ namespace Microsoft.AspNetCore.Hosting.Tests
}
}
}
}
}

View File

@ -5,7 +5,6 @@ using System;
using System.Collections.Generic;
using System.Reflection;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.AspNetCore.Hosting.Fakes;
using Microsoft.AspNetCore.Hosting.Internal;
using Microsoft.AspNetCore.Hosting.Tests.Internal;

View File

@ -474,58 +474,6 @@ namespace Microsoft.AspNetCore.Http.Features
Microsoft.AspNetCore.Routing.RouteValueDictionary RouteValues { get; set; }
}
}
namespace Microsoft.AspNetCore.Http.Internal
{
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct HeaderSegment : System.IEquatable<Microsoft.AspNetCore.Http.Internal.HeaderSegment>
{
private readonly object _dummy;
public HeaderSegment(Microsoft.Extensions.Primitives.StringSegment formatting, Microsoft.Extensions.Primitives.StringSegment data) { throw null; }
public Microsoft.Extensions.Primitives.StringSegment Data { get { throw null; } }
public Microsoft.Extensions.Primitives.StringSegment Formatting { get { throw null; } }
public bool Equals(Microsoft.AspNetCore.Http.Internal.HeaderSegment other) { throw null; }
public override bool Equals(object obj) { throw null; }
public override int GetHashCode() { throw null; }
public static bool operator ==(Microsoft.AspNetCore.Http.Internal.HeaderSegment left, Microsoft.AspNetCore.Http.Internal.HeaderSegment right) { throw null; }
public static bool operator !=(Microsoft.AspNetCore.Http.Internal.HeaderSegment left, Microsoft.AspNetCore.Http.Internal.HeaderSegment right) { throw null; }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct HeaderSegmentCollection : System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Http.Internal.HeaderSegment>, System.Collections.IEnumerable, System.IEquatable<Microsoft.AspNetCore.Http.Internal.HeaderSegmentCollection>
{
private readonly object _dummy;
public HeaderSegmentCollection(Microsoft.Extensions.Primitives.StringValues headers) { throw null; }
public bool Equals(Microsoft.AspNetCore.Http.Internal.HeaderSegmentCollection other) { throw null; }
public override bool Equals(object obj) { throw null; }
public Microsoft.AspNetCore.Http.Internal.HeaderSegmentCollection.Enumerator GetEnumerator() { throw null; }
public override int GetHashCode() { throw null; }
public static bool operator ==(Microsoft.AspNetCore.Http.Internal.HeaderSegmentCollection left, Microsoft.AspNetCore.Http.Internal.HeaderSegmentCollection right) { throw null; }
public static bool operator !=(Microsoft.AspNetCore.Http.Internal.HeaderSegmentCollection left, Microsoft.AspNetCore.Http.Internal.HeaderSegmentCollection right) { throw null; }
System.Collections.Generic.IEnumerator<Microsoft.AspNetCore.Http.Internal.HeaderSegment> System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Http.Internal.HeaderSegment>.GetEnumerator() { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public partial struct Enumerator : System.Collections.Generic.IEnumerator<Microsoft.AspNetCore.Http.Internal.HeaderSegment>, System.Collections.IEnumerator, System.IDisposable
{
private object _dummy;
private int _dummyPrimitive;
public Enumerator(Microsoft.Extensions.Primitives.StringValues headers) { throw null; }
public Microsoft.AspNetCore.Http.Internal.HeaderSegment Current { get { throw null; } }
object System.Collections.IEnumerator.Current { get { throw null; } }
public void Dispose() { }
public bool MoveNext() { throw null; }
public void Reset() { }
}
}
public static partial class ParsingHelpers
{
public static void AppendHeaderJoined(Microsoft.AspNetCore.Http.IHeaderDictionary headers, string key, params string[] values) { }
public static void AppendHeaderUnmodified(Microsoft.AspNetCore.Http.IHeaderDictionary headers, string key, Microsoft.Extensions.Primitives.StringValues values) { }
public static Microsoft.Extensions.Primitives.StringValues GetHeader(Microsoft.AspNetCore.Http.IHeaderDictionary headers, string key) { throw null; }
public static Microsoft.Extensions.Primitives.StringValues GetHeaderSplit(Microsoft.AspNetCore.Http.IHeaderDictionary headers, string key) { throw null; }
public static Microsoft.Extensions.Primitives.StringValues GetHeaderUnmodified(Microsoft.AspNetCore.Http.IHeaderDictionary headers, string key) { throw null; }
public static void SetHeaderJoined(Microsoft.AspNetCore.Http.IHeaderDictionary headers, string key, Microsoft.Extensions.Primitives.StringValues value) { }
public static void SetHeaderUnmodified(Microsoft.AspNetCore.Http.IHeaderDictionary headers, string key, Microsoft.Extensions.Primitives.StringValues? values) { }
}
}
namespace Microsoft.AspNetCore.Routing
{
public partial class RouteValueDictionary : System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, object>>, System.Collections.Generic.IDictionary<string, object>, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>>, System.Collections.Generic.IReadOnlyCollection<System.Collections.Generic.KeyValuePair<string, object>>, System.Collections.Generic.IReadOnlyDictionary<string, object>, System.Collections.IEnumerable

View File

@ -1,7 +1,6 @@
// 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.AspNetCore.Http.Internal;
using Microsoft.Extensions.Primitives;
namespace Microsoft.AspNetCore.Http

View File

@ -5,7 +5,6 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using Microsoft.AspNetCore.Http.Abstractions;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.Extensions.Primitives;
namespace Microsoft.AspNetCore.Http

View File

@ -4,9 +4,9 @@
using System;
using Microsoft.Extensions.Primitives;
namespace Microsoft.AspNetCore.Http.Internal
namespace Microsoft.AspNetCore.Http
{
public readonly struct HeaderSegment : IEquatable<HeaderSegment>
internal readonly struct HeaderSegment : IEquatable<HeaderSegment>
{
private readonly StringSegment _formatting;
private readonly StringSegment _data;

View File

@ -6,9 +6,9 @@ using System.Collections;
using System.Collections.Generic;
using Microsoft.Extensions.Primitives;
namespace Microsoft.AspNetCore.Http.Internal
namespace Microsoft.AspNetCore.Http
{
public readonly struct HeaderSegmentCollection : IEnumerable<HeaderSegment>, IEquatable<HeaderSegmentCollection>
internal readonly struct HeaderSegmentCollection : IEnumerable<HeaderSegment>, IEquatable<HeaderSegmentCollection>
{
private readonly StringValues _headers;

View File

@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.
namespace Microsoft.AspNetCore.Http.Internal
namespace Microsoft.AspNetCore.Http
{
internal class HostStringHelper
{

View File

@ -2,13 +2,12 @@
// 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.Linq;
using Microsoft.Extensions.Primitives;
namespace Microsoft.AspNetCore.Http.Internal
namespace Microsoft.AspNetCore.Http
{
public static class ParsingHelpers
internal static class ParsingHelpers
{
public static StringValues GetHeader(IHeaderDictionary headers, string key)
{

View File

@ -4,7 +4,7 @@
using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace Microsoft.AspNetCore.Http.Internal
namespace Microsoft.AspNetCore.Http
{
internal static class PathStringHelper
{

View File

@ -25,4 +25,8 @@ Microsoft.AspNetCore.Http.HttpResponse</Description>
<Reference Include="Microsoft.Net.Http.Headers" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="Microsoft.AspNetCore.Http.Microbenchmarks" />
</ItemGroup>
</Project>

View File

@ -6,7 +6,6 @@ using System.ComponentModel;
using System.Globalization;
using System.Text;
using Microsoft.AspNetCore.Http.Abstractions;
using Microsoft.AspNetCore.Http.Internal;
namespace Microsoft.AspNetCore.Http
{

View File

@ -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.
namespace Microsoft.AspNetCore.Builder.Internal
namespace Microsoft.AspNetCore.Builder
{
public partial class ApplicationBuilder : Microsoft.AspNetCore.Builder.IApplicationBuilder
{
@ -17,6 +17,20 @@ namespace Microsoft.AspNetCore.Builder.Internal
}
namespace Microsoft.AspNetCore.Http
{
public partial class BindingAddress
{
public BindingAddress() { }
public string Host { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public bool IsUnixPipe { get { throw null; } }
public string PathBase { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public int Port { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string Scheme { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string UnixPipePath { get { throw null; } }
public override bool Equals(object obj) { throw null; }
public override int GetHashCode() { throw null; }
public static Microsoft.AspNetCore.Http.BindingAddress Parse(string address) { throw null; }
public override string ToString() { throw null; }
}
public sealed partial class DefaultHttpContext : Microsoft.AspNetCore.Http.HttpContext
{
public DefaultHttpContext() { }
@ -71,6 +85,27 @@ namespace Microsoft.AspNetCore.Http
void System.Collections.IEnumerator.Reset() { }
}
}
public partial class FormFile : Microsoft.AspNetCore.Http.IFormFile
{
public FormFile(System.IO.Stream baseStream, long baseStreamOffset, long length, string name, string fileName) { }
public string ContentDisposition { get { throw null; } set { } }
public string ContentType { get { throw null; } set { } }
public string FileName { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Http.IHeaderDictionary Headers { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public long Length { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string Name { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public void CopyTo(System.IO.Stream target) { }
[System.Diagnostics.DebuggerStepThroughAttribute]
public System.Threading.Tasks.Task CopyToAsync(System.IO.Stream target, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public System.IO.Stream OpenReadStream() { throw null; }
}
public partial class FormFileCollection : System.Collections.Generic.List<Microsoft.AspNetCore.Http.IFormFile>, Microsoft.AspNetCore.Http.IFormFileCollection, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Http.IFormFile>, System.Collections.Generic.IReadOnlyCollection<Microsoft.AspNetCore.Http.IFormFile>, System.Collections.Generic.IReadOnlyList<Microsoft.AspNetCore.Http.IFormFile>, System.Collections.IEnumerable
{
public FormFileCollection() { }
public Microsoft.AspNetCore.Http.IFormFile this[string name] { get { throw null; } }
public Microsoft.AspNetCore.Http.IFormFile GetFile(string name) { throw null; }
public System.Collections.Generic.IReadOnlyList<Microsoft.AspNetCore.Http.IFormFile> GetFiles(string name) { throw null; }
}
public partial class HeaderDictionary : Microsoft.AspNetCore.Http.IHeaderDictionary, System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, Microsoft.Extensions.Primitives.StringValues>>, System.Collections.Generic.IDictionary<string, Microsoft.Extensions.Primitives.StringValues>, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, Microsoft.Extensions.Primitives.StringValues>>, System.Collections.IEnumerable
{
public HeaderDictionary() { }
@ -139,6 +174,33 @@ namespace Microsoft.AspNetCore.Http
public Microsoft.AspNetCore.Http.IMiddleware Create(System.Type middlewareType) { throw null; }
public void Release(Microsoft.AspNetCore.Http.IMiddleware middleware) { }
}
public partial class QueryCollection : Microsoft.AspNetCore.Http.IQueryCollection, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, Microsoft.Extensions.Primitives.StringValues>>, System.Collections.IEnumerable
{
public static readonly Microsoft.AspNetCore.Http.QueryCollection Empty;
public QueryCollection() { }
public QueryCollection(Microsoft.AspNetCore.Http.QueryCollection store) { }
public QueryCollection(System.Collections.Generic.Dictionary<string, Microsoft.Extensions.Primitives.StringValues> store) { }
public QueryCollection(int capacity) { }
public int Count { get { throw null; } }
public Microsoft.Extensions.Primitives.StringValues this[string key] { get { throw null; } }
public System.Collections.Generic.ICollection<string> Keys { get { throw null; } }
public bool ContainsKey(string key) { throw null; }
public Microsoft.AspNetCore.Http.QueryCollection.Enumerator GetEnumerator() { throw null; }
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<string, Microsoft.Extensions.Primitives.StringValues>> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String,Microsoft.Extensions.Primitives.StringValues>>.GetEnumerator() { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
public bool TryGetValue(string key, out Microsoft.Extensions.Primitives.StringValues value) { throw null; }
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public partial struct Enumerator : System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<string, Microsoft.Extensions.Primitives.StringValues>>, System.Collections.IEnumerator, System.IDisposable
{
private object _dummy;
private int _dummyPrimitive;
public System.Collections.Generic.KeyValuePair<string, Microsoft.Extensions.Primitives.StringValues> Current { get { throw null; } }
object System.Collections.IEnumerator.Current { get { throw null; } }
public void Dispose() { }
public bool MoveNext() { throw null; }
void System.Collections.IEnumerator.Reset() { }
}
}
public static partial class RequestFormReaderExtensions
{
public static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IFormCollection> ReadFormAsync(this Microsoft.AspNetCore.Http.HttpRequest request, Microsoft.AspNetCore.Http.Features.FormOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
@ -289,204 +351,6 @@ namespace Microsoft.AspNetCore.Http.Features.Authentication
public System.Security.Claims.ClaimsPrincipal User { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
}
}
namespace Microsoft.AspNetCore.Http.Internal
{
public partial class BindingAddress
{
public BindingAddress() { }
public string Host { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public bool IsUnixPipe { get { throw null; } }
public string PathBase { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public int Port { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string Scheme { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string UnixPipePath { get { throw null; } }
public override bool Equals(object obj) { throw null; }
public override int GetHashCode() { throw null; }
public static Microsoft.AspNetCore.Http.Internal.BindingAddress Parse(string address) { throw null; }
public override string ToString() { throw null; }
}
public static partial class BufferingHelper
{
public static Microsoft.AspNetCore.Http.HttpRequest EnableRewind(this Microsoft.AspNetCore.Http.HttpRequest request, int bufferThreshold = 30720, long? bufferLimit = default(long?)) { throw null; }
public static Microsoft.AspNetCore.WebUtilities.MultipartSection EnableRewind(this Microsoft.AspNetCore.WebUtilities.MultipartSection section, System.Action<System.IDisposable> registerForDispose, int bufferThreshold = 30720, long? bufferLimit = default(long?)) { throw null; }
}
public sealed partial class DefaultConnectionInfo : Microsoft.AspNetCore.Http.ConnectionInfo
{
public DefaultConnectionInfo(Microsoft.AspNetCore.Http.Features.IFeatureCollection features) { }
public override System.Security.Cryptography.X509Certificates.X509Certificate2 ClientCertificate { get { throw null; } set { } }
public override string Id { get { throw null; } set { } }
public override System.Net.IPAddress LocalIpAddress { get { throw null; } set { } }
public override int LocalPort { get { throw null; } set { } }
public override System.Net.IPAddress RemoteIpAddress { get { throw null; } set { } }
public override int RemotePort { get { throw null; } set { } }
public override System.Threading.Tasks.Task<System.Security.Cryptography.X509Certificates.X509Certificate2> GetClientCertificateAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public void Initialize(Microsoft.AspNetCore.Http.Features.IFeatureCollection features) { }
public void Initialize(Microsoft.AspNetCore.Http.Features.IFeatureCollection features, int revision) { }
public void Uninitialize() { }
}
public sealed partial class DefaultHttpRequest : Microsoft.AspNetCore.Http.HttpRequest
{
public DefaultHttpRequest(Microsoft.AspNetCore.Http.DefaultHttpContext context) { }
public override System.IO.Stream Body { get { throw null; } set { } }
public override System.IO.Pipelines.PipeReader BodyReader { get { throw null; } }
public override long? ContentLength { get { throw null; } set { } }
public override string ContentType { get { throw null; } set { } }
public override Microsoft.AspNetCore.Http.IRequestCookieCollection Cookies { get { throw null; } set { } }
public override Microsoft.AspNetCore.Http.IFormCollection Form { get { throw null; } set { } }
public override bool HasFormContentType { get { throw null; } }
public override Microsoft.AspNetCore.Http.IHeaderDictionary Headers { get { throw null; } }
public override Microsoft.AspNetCore.Http.HostString Host { get { throw null; } set { } }
public override Microsoft.AspNetCore.Http.HttpContext HttpContext { get { throw null; } }
public override bool IsHttps { get { throw null; } set { } }
public override string Method { get { throw null; } set { } }
public override Microsoft.AspNetCore.Http.PathString Path { get { throw null; } set { } }
public override Microsoft.AspNetCore.Http.PathString PathBase { get { throw null; } set { } }
public override string Protocol { get { throw null; } set { } }
public override Microsoft.AspNetCore.Http.IQueryCollection Query { get { throw null; } set { } }
public override Microsoft.AspNetCore.Http.QueryString QueryString { get { throw null; } set { } }
public override Microsoft.AspNetCore.Routing.RouteValueDictionary RouteValues { get { throw null; } set { } }
public override string Scheme { get { throw null; } set { } }
public void Initialize() { }
public void Initialize(int revision) { }
public override System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IFormCollection> ReadFormAsync(System.Threading.CancellationToken cancellationToken) { throw null; }
public void Uninitialize() { }
}
public sealed partial class DefaultHttpResponse : Microsoft.AspNetCore.Http.HttpResponse
{
public DefaultHttpResponse(Microsoft.AspNetCore.Http.DefaultHttpContext context) { }
public override System.IO.Stream Body { get { throw null; } set { } }
public override System.IO.Pipelines.PipeWriter BodyWriter { get { throw null; } }
public override long? ContentLength { get { throw null; } set { } }
public override string ContentType { get { throw null; } set { } }
public override Microsoft.AspNetCore.Http.IResponseCookies Cookies { get { throw null; } }
public override bool HasStarted { get { throw null; } }
public override Microsoft.AspNetCore.Http.IHeaderDictionary Headers { get { throw null; } }
public override Microsoft.AspNetCore.Http.HttpContext HttpContext { get { throw null; } }
public override int StatusCode { get { throw null; } set { } }
public void Initialize() { }
public void Initialize(int revision) { }
public override void OnCompleted(System.Func<object, System.Threading.Tasks.Task> callback, object state) { }
public override void OnStarting(System.Func<object, System.Threading.Tasks.Task> callback, object state) { }
public override void Redirect(string location, bool permanent) { }
public override System.Threading.Tasks.Task StartAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public void Uninitialize() { }
}
public sealed partial class DefaultWebSocketManager : Microsoft.AspNetCore.Http.WebSocketManager
{
public DefaultWebSocketManager(Microsoft.AspNetCore.Http.Features.IFeatureCollection features) { }
public override bool IsWebSocketRequest { get { throw null; } }
public override System.Collections.Generic.IList<string> WebSocketRequestedProtocols { get { throw null; } }
public override System.Threading.Tasks.Task<System.Net.WebSockets.WebSocket> AcceptWebSocketAsync(string subProtocol) { throw null; }
public void Initialize(Microsoft.AspNetCore.Http.Features.IFeatureCollection features) { }
public void Initialize(Microsoft.AspNetCore.Http.Features.IFeatureCollection features, int revision) { }
public void Uninitialize() { }
}
public partial class FormFile : Microsoft.AspNetCore.Http.IFormFile
{
public FormFile(System.IO.Stream baseStream, long baseStreamOffset, long length, string name, string fileName) { }
public string ContentDisposition { get { throw null; } set { } }
public string ContentType { get { throw null; } set { } }
public string FileName { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Http.IHeaderDictionary Headers { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public long Length { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string Name { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public void CopyTo(System.IO.Stream target) { }
[System.Diagnostics.DebuggerStepThroughAttribute]
public System.Threading.Tasks.Task CopyToAsync(System.IO.Stream target, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public System.IO.Stream OpenReadStream() { throw null; }
}
public partial class FormFileCollection : System.Collections.Generic.List<Microsoft.AspNetCore.Http.IFormFile>, Microsoft.AspNetCore.Http.IFormFileCollection, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Http.IFormFile>, System.Collections.Generic.IReadOnlyCollection<Microsoft.AspNetCore.Http.IFormFile>, System.Collections.Generic.IReadOnlyList<Microsoft.AspNetCore.Http.IFormFile>, System.Collections.IEnumerable
{
public FormFileCollection() { }
public Microsoft.AspNetCore.Http.IFormFile this[string name] { get { throw null; } }
public Microsoft.AspNetCore.Http.IFormFile GetFile(string name) { throw null; }
public System.Collections.Generic.IReadOnlyList<Microsoft.AspNetCore.Http.IFormFile> GetFiles(string name) { throw null; }
}
public partial class ItemsDictionary : System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<object, object>>, System.Collections.Generic.IDictionary<object, object>, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<object, object>>, System.Collections.IEnumerable
{
public ItemsDictionary() { }
public ItemsDictionary(System.Collections.Generic.IDictionary<object, object> items) { }
public System.Collections.Generic.IDictionary<object, object> Items { get { throw null; } }
int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.Object,System.Object>>.Count { get { throw null; } }
bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.Object,System.Object>>.IsReadOnly { get { throw null; } }
object System.Collections.Generic.IDictionary<System.Object,System.Object>.this[object key] { get { throw null; } set { } }
System.Collections.Generic.ICollection<object> System.Collections.Generic.IDictionary<System.Object,System.Object>.Keys { get { throw null; } }
System.Collections.Generic.ICollection<object> System.Collections.Generic.IDictionary<System.Object,System.Object>.Values { get { throw null; } }
void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.Object,System.Object>>.Add(System.Collections.Generic.KeyValuePair<object, object> item) { }
void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.Object,System.Object>>.Clear() { }
bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.Object,System.Object>>.Contains(System.Collections.Generic.KeyValuePair<object, object> item) { throw null; }
void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.Object,System.Object>>.CopyTo(System.Collections.Generic.KeyValuePair<object, object>[] array, int arrayIndex) { }
bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.Object,System.Object>>.Remove(System.Collections.Generic.KeyValuePair<object, object> item) { throw null; }
void System.Collections.Generic.IDictionary<System.Object,System.Object>.Add(object key, object value) { }
bool System.Collections.Generic.IDictionary<System.Object,System.Object>.ContainsKey(object key) { throw null; }
bool System.Collections.Generic.IDictionary<System.Object,System.Object>.Remove(object key) { throw null; }
bool System.Collections.Generic.IDictionary<System.Object,System.Object>.TryGetValue(object key, out object value) { throw null; }
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<object, object>> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.Object,System.Object>>.GetEnumerator() { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
public partial class QueryCollection : Microsoft.AspNetCore.Http.IQueryCollection, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, Microsoft.Extensions.Primitives.StringValues>>, System.Collections.IEnumerable
{
public static readonly Microsoft.AspNetCore.Http.Internal.QueryCollection Empty;
public QueryCollection() { }
public QueryCollection(Microsoft.AspNetCore.Http.Internal.QueryCollection store) { }
public QueryCollection(System.Collections.Generic.Dictionary<string, Microsoft.Extensions.Primitives.StringValues> store) { }
public QueryCollection(int capacity) { }
public int Count { get { throw null; } }
public Microsoft.Extensions.Primitives.StringValues this[string key] { get { throw null; } }
public System.Collections.Generic.ICollection<string> Keys { get { throw null; } }
public bool ContainsKey(string key) { throw null; }
public Microsoft.AspNetCore.Http.Internal.QueryCollection.Enumerator GetEnumerator() { throw null; }
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<string, Microsoft.Extensions.Primitives.StringValues>> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String,Microsoft.Extensions.Primitives.StringValues>>.GetEnumerator() { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
public bool TryGetValue(string key, out Microsoft.Extensions.Primitives.StringValues value) { throw null; }
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public partial struct Enumerator : System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<string, Microsoft.Extensions.Primitives.StringValues>>, System.Collections.IEnumerator, System.IDisposable
{
private object _dummy;
private int _dummyPrimitive;
public System.Collections.Generic.KeyValuePair<string, Microsoft.Extensions.Primitives.StringValues> Current { get { throw null; } }
object System.Collections.IEnumerator.Current { get { throw null; } }
public void Dispose() { }
public bool MoveNext() { throw null; }
void System.Collections.IEnumerator.Reset() { }
}
}
public partial class RequestCookieCollection : Microsoft.AspNetCore.Http.IRequestCookieCollection, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, string>>, System.Collections.IEnumerable
{
public static readonly Microsoft.AspNetCore.Http.Internal.RequestCookieCollection Empty;
public RequestCookieCollection() { }
public RequestCookieCollection(System.Collections.Generic.Dictionary<string, string> store) { }
public RequestCookieCollection(int capacity) { }
public int Count { get { throw null; } }
public string this[string key] { get { throw null; } }
public System.Collections.Generic.ICollection<string> Keys { get { throw null; } }
public bool ContainsKey(string key) { throw null; }
public Microsoft.AspNetCore.Http.Internal.RequestCookieCollection.Enumerator GetEnumerator() { throw null; }
public static Microsoft.AspNetCore.Http.Internal.RequestCookieCollection Parse(System.Collections.Generic.IList<string> values) { throw null; }
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<string, string>> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String,System.String>>.GetEnumerator() { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
public bool TryGetValue(string key, out string value) { throw null; }
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public partial struct Enumerator : System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<string, string>>, System.Collections.IEnumerator, System.IDisposable
{
private object _dummy;
private int _dummyPrimitive;
public System.Collections.Generic.KeyValuePair<string, string> Current { get { throw null; } }
object System.Collections.IEnumerator.Current { get { throw null; } }
public void Dispose() { }
public bool MoveNext() { throw null; }
public void Reset() { }
}
}
public partial class ResponseCookies : Microsoft.AspNetCore.Http.IResponseCookies
{
public ResponseCookies(Microsoft.AspNetCore.Http.IHeaderDictionary headers, Microsoft.Extensions.ObjectPool.ObjectPool<System.Text.StringBuilder> builderPool) { }
public void Append(string key, string value) { }
public void Append(string key, string value, Microsoft.AspNetCore.Http.CookieOptions options) { }
public void Delete(string key) { }
public void Delete(string key, Microsoft.AspNetCore.Http.CookieOptions options) { }
}
}
namespace Microsoft.Extensions.DependencyInjection
{
public static partial class HttpServiceCollectionExtensions

View File

@ -2,13 +2,14 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Diagnostics;
using System.Globalization;
namespace Microsoft.AspNetCore.Http.Internal
namespace Microsoft.AspNetCore.Http
{
public class BindingAddress
{
private const string UnixPipeHostPrefix = "unix:/";
public string Host { get; private set; }
public string PathBase { get; private set; }
public int Port { get; internal set; }
@ -18,7 +19,7 @@ namespace Microsoft.AspNetCore.Http.Internal
{
get
{
return Host.StartsWith(Constants.UnixPipeHostPrefix, StringComparison.Ordinal);
return Host.StartsWith(UnixPipeHostPrefix, StringComparison.Ordinal);
}
}
@ -31,7 +32,7 @@ namespace Microsoft.AspNetCore.Http.Internal
throw new InvalidOperationException("Binding address is not a unix pipe.");
}
return Host.Substring(Constants.UnixPipeHostPrefix.Length - 1);
return Host.Substring(UnixPipeHostPrefix.Length - 1);
}
}
@ -76,7 +77,7 @@ namespace Microsoft.AspNetCore.Http.Internal
}
int schemeDelimiterEnd = schemeDelimiterStart + "://".Length;
var isUnixPipe = address.IndexOf(Constants.UnixPipeHostPrefix, schemeDelimiterEnd, StringComparison.Ordinal) == schemeDelimiterEnd;
var isUnixPipe = address.IndexOf(UnixPipeHostPrefix, schemeDelimiterEnd, StringComparison.Ordinal) == schemeDelimiterEnd;
int pathDelimiterStart;
int pathDelimiterEnd;
@ -87,7 +88,7 @@ namespace Microsoft.AspNetCore.Http.Internal
}
else
{
pathDelimiterStart = address.IndexOf(":", schemeDelimiterEnd + Constants.UnixPipeHostPrefix.Length, StringComparison.Ordinal);
pathDelimiterStart = address.IndexOf(":", schemeDelimiterEnd + UnixPipeHostPrefix.Length, StringComparison.Ordinal);
pathDelimiterEnd = pathDelimiterStart + ":".Length;
}
@ -152,4 +153,4 @@ namespace Microsoft.AspNetCore.Http.Internal
return serverAddress;
}
}
}
}

View File

@ -7,13 +7,15 @@ using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Builder.Internal
namespace Microsoft.AspNetCore.Builder
{
public class ApplicationBuilder : IApplicationBuilder
{
private const string ServerFeaturesKey = "server.Features";
private const string ApplicationServicesKey = "application.Services";
private readonly IList<Func<RequestDelegate, RequestDelegate>> _components = new List<Func<RequestDelegate, RequestDelegate>>();
public ApplicationBuilder(IServiceProvider serviceProvider)
@ -25,7 +27,7 @@ namespace Microsoft.AspNetCore.Builder.Internal
public ApplicationBuilder(IServiceProvider serviceProvider, object server)
: this(serviceProvider)
{
SetProperty(Constants.BuilderProperties.ServerFeatures, server);
SetProperty(ServerFeaturesKey, server);
}
private ApplicationBuilder(ApplicationBuilder builder)
@ -37,11 +39,11 @@ namespace Microsoft.AspNetCore.Builder.Internal
{
get
{
return GetProperty<IServiceProvider>(Constants.BuilderProperties.ApplicationServices);
return GetProperty<IServiceProvider>(ApplicationServicesKey);
}
set
{
SetProperty<IServiceProvider>(Constants.BuilderProperties.ApplicationServices, value);
SetProperty<IServiceProvider>(ApplicationServicesKey, value);
}
}
@ -49,7 +51,7 @@ namespace Microsoft.AspNetCore.Builder.Internal
{
get
{
return GetProperty<IFeatureCollection>(Constants.BuilderProperties.ServerFeatures);
return GetProperty<IFeatureCollection>(ServerFeaturesKey);
}
}

View File

@ -8,7 +8,6 @@ using System.Security.Claims;
using System.Threading;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Http.Features.Authentication;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.AspNetCore.Http

View File

@ -1,8 +1,6 @@
// 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.AspNetCore.Http.Internal;
namespace Microsoft.AspNetCore.Http
{
/// <summary>

View File

@ -6,7 +6,6 @@ using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Primitives;
using Microsoft.Net.Http.Headers;

View File

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using Microsoft.AspNetCore.Http.Internal;
namespace Microsoft.AspNetCore.Http.Features
{
@ -15,4 +14,4 @@ namespace Microsoft.AspNetCore.Http.Features
public IDictionary<object, object> Items { get; set; }
}
}
}

View File

@ -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.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.WebUtilities;
namespace Microsoft.AspNetCore.Http.Features
@ -90,4 +89,4 @@ namespace Microsoft.AspNetCore.Http.Features
}
}
}
}
}

View File

@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.Extensions.Primitives;
using Microsoft.Net.Http.Headers;
@ -93,4 +92,4 @@ namespace Microsoft.AspNetCore.Http.Features
}
}
}
}
}

View File

@ -3,7 +3,6 @@
using System;
using System.Text;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.Extensions.ObjectPool;
namespace Microsoft.AspNetCore.Http.Features
@ -66,4 +65,4 @@ namespace Microsoft.AspNetCore.Http.Features
}
}
}
}
}

View File

@ -4,7 +4,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.Extensions.Primitives;
namespace Microsoft.AspNetCore.Http

View File

@ -7,8 +7,11 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.Http.Internal
namespace Microsoft.AspNetCore.Http
{
/// <summary>
/// Default implementation of <see cref="IFormFile"/>.
/// </summary>
public class FormFile : IFormFile
{
// Stream.CopyTo method uses 80KB as the default buffer size.

View File

@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;
namespace Microsoft.AspNetCore.Http.Internal
namespace Microsoft.AspNetCore.Http
{
/// <summary>
/// Default implementation of <see cref="IFormFileCollection"/>.
@ -44,4 +44,4 @@ namespace Microsoft.AspNetCore.Http.Internal
return files;
}
}
}
}

View File

@ -5,9 +5,9 @@ using System;
using Microsoft.AspNetCore.Internal;
using Microsoft.AspNetCore.WebUtilities;
namespace Microsoft.AspNetCore.Http.Internal
namespace Microsoft.AspNetCore.Http
{
public static class BufferingHelper
internal static class BufferingHelper
{
internal const int DefaultBufferThreshold = 1024 * 30;

View File

@ -1,18 +0,0 @@
// 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.
namespace Microsoft.AspNetCore.Http.Internal
{
internal static class Constants
{
internal const string Http = "http";
internal const string Https = "https";
internal const string UnixPipeHostPrefix = "unix:/";
internal static class BuilderProperties
{
internal static string ServerFeatures = "server.Features";
internal static string ApplicationServices = "application.Services";
}
}
}

View File

@ -8,9 +8,9 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http.Features;
namespace Microsoft.AspNetCore.Http.Internal
namespace Microsoft.AspNetCore.Http
{
public sealed class DefaultConnectionInfo : ConnectionInfo
internal sealed class DefaultConnectionInfo : ConnectionInfo
{
// Lambdas hoisted to static readonly fields to improve inlining https://github.com/dotnet/roslyn/issues/13624
private readonly static Func<IFeatureCollection, IHttpConnectionFeature> _newHttpConnectionFeature = f => new HttpConnectionFeature();

View File

@ -10,10 +10,13 @@ using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Routing;
using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.Http.Internal
namespace Microsoft.AspNetCore.Http
{
public sealed class DefaultHttpRequest : HttpRequest
internal sealed class DefaultHttpRequest : HttpRequest
{
private const string Http = "http";
private const string Https = "https";
// Lambdas hoisted to static readonly fields to improve inlining https://github.com/dotnet/roslyn/issues/13624
private readonly static Func<IFeatureCollection, IHttpRequestFeature> _nullRequestFeature = f => null;
private readonly static Func<IFeatureCollection, IQueryFeature> _newQueryFeature = f => new QueryFeature(f);
@ -110,8 +113,8 @@ namespace Microsoft.AspNetCore.Http.Internal
public override bool IsHttps
{
get { return string.Equals(Constants.Https, Scheme, StringComparison.OrdinalIgnoreCase); }
set { Scheme = value ? Constants.Https : Constants.Http; }
get { return string.Equals(Https, Scheme, StringComparison.OrdinalIgnoreCase); }
set { Scheme = value ? Https : Http; }
}
public override HostString Host

View File

@ -9,9 +9,9 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.Http.Internal
namespace Microsoft.AspNetCore.Http
{
public sealed class DefaultHttpResponse : HttpResponse
internal sealed class DefaultHttpResponse : HttpResponse
{
// Lambdas hoisted to static readonly fields to improve inlining https://github.com/dotnet/roslyn/issues/13624
private readonly static Func<IFeatureCollection, IHttpResponseFeature> _nullResponseFeature = f => null;

View File

@ -8,9 +8,9 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.Http.Internal
namespace Microsoft.AspNetCore.Http
{
public sealed class DefaultWebSocketManager : WebSocketManager
internal sealed class DefaultWebSocketManager : WebSocketManager
{
// Lambdas hoisted to static readonly fields to improve inlining https://github.com/dotnet/roslyn/issues/13624
private readonly static Func<IFeatureCollection, IHttpRequestFeature> _nullRequestFeature = f => null;
@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Http.Internal
{
get
{
return ParsingHelpers.GetHeaderSplit(HttpRequestFeature.Headers, HeaderNames.WebSocketSubProtocols);
return HttpRequestFeature.Headers.GetCommaSeparatedValues(HeaderNames.WebSocketSubProtocols);
}
}

View File

@ -4,9 +4,9 @@
using System.Collections;
using System.Collections.Generic;
namespace Microsoft.AspNetCore.Http.Internal
namespace Microsoft.AspNetCore.Http
{
public class ItemsDictionary : IDictionary<object, object>
internal class ItemsDictionary : IDictionary<object, object>
{
private IDictionary<object, object> _items;
@ -159,4 +159,4 @@ namespace Microsoft.AspNetCore.Http.Internal
public static ICollection<KeyValuePair<object, object>> Collection => Dictionary;
}
}
}
}

View File

@ -6,7 +6,7 @@ using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Http.Internal
namespace Microsoft.AspNetCore.Http
{
/// <summary>
/// A Stream that wraps another stream starting at a certain offset and reading for the given length.

View File

@ -6,9 +6,9 @@ using System.Collections;
using System.Collections.Generic;
using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.Http.Internal
namespace Microsoft.AspNetCore.Http
{
public class RequestCookieCollection : IRequestCookieCollection
internal class RequestCookieCollection : IRequestCookieCollection
{
public static readonly RequestCookieCollection Empty = new RequestCookieCollection();
private static readonly string[] EmptyKeys = Array.Empty<string>();
@ -229,4 +229,4 @@ namespace Microsoft.AspNetCore.Http.Internal
}
}
}
}
}

View File

@ -8,12 +8,12 @@ using Microsoft.Extensions.ObjectPool;
using Microsoft.Extensions.Primitives;
using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.Http.Internal
namespace Microsoft.AspNetCore.Http
{
/// <summary>
/// A wrapper for the response Set-Cookie header.
/// </summary>
public class ResponseCookies : IResponseCookies
internal class ResponseCookies : IResponseCookies
{
/// <summary>
/// Create a new wrapper.

View File

@ -6,7 +6,7 @@ using System.Collections;
using System.Collections.Generic;
using Microsoft.Extensions.Primitives;
namespace Microsoft.AspNetCore.Http.Internal
namespace Microsoft.AspNetCore.Http
{
/// <summary>
/// The HttpRequest query string collection

View File

@ -1,11 +1,11 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.Text;
using Xunit;
namespace Microsoft.AspNetCore.Http.Internal.Tests
namespace Microsoft.AspNetCore.Http.Tests
{
public class BindingAddressTests
{

View File

@ -11,7 +11,7 @@ using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Primitives;
using Xunit;
namespace Microsoft.AspNetCore.Http.Internal
namespace Microsoft.AspNetCore.Http
{
public class DefaultHttpRequestTests
{

View File

@ -13,7 +13,7 @@ using Microsoft.Extensions.Primitives;
using Moq;
using Xunit;
namespace Microsoft.AspNetCore.Http.Internal
namespace Microsoft.AspNetCore.Http
{
public class DefaultHttpResponseTests
{

View File

@ -1,8 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.Linq;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.Extensions.Primitives;
using Xunit;

View File

@ -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.AspNetCore.Http.Internal;
using Microsoft.Net.Http.Headers;
using Xunit;

View File

@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Owin;

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Xunit;

View File

@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Routing;

View File

@ -3,7 +3,6 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;

View File

@ -5,7 +5,6 @@ using System;
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;

View File

@ -12,7 +12,6 @@ using IdentityServer4.Services;
using IdentityServer4.Validation;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;

View File

@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Identity.Test;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.EntityFrameworkCore;

View File

@ -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.AspNetCore.Builder.Internal;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;

View File

@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Identity.Test;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.EntityFrameworkCore;

View File

@ -3,7 +3,7 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Identity.Test;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.EntityFrameworkCore;

View File

@ -4,7 +4,7 @@
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity.Test;
using Microsoft.Extensions.Configuration;

View File

@ -6,7 +6,6 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.HttpsPolicy.Internal;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

View File

@ -4,7 +4,6 @@ using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.WebUtilities;
using MusicStore.Mocks.Common;

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Logging;
using Microsoft.Net.Http.Headers;

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Logging;
using Microsoft.Net.Http.Headers;

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Logging;
using Microsoft.Net.Http.Headers;
@ -95,4 +95,4 @@ namespace E2ETests
_logger.LogInformation("Middleware events were fired successfully");
}
}
}
}

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Logging;
using Microsoft.Net.Http.Headers;

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Logging;
using Xunit;
@ -92,4 +92,4 @@ namespace E2ETests
_logger.LogInformation("Middleware events were fired successfully");
}
}
}
}

View File

@ -4,7 +4,6 @@
using System;
using System.Diagnostics;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;

View File

@ -3,7 +3,6 @@
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.Extensions.DependencyInjection;
using Xunit;

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Runtime.ExceptionServices;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Mvc.Abstractions;

View File

@ -9,7 +9,6 @@ using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Controllers;

View File

@ -5,13 +5,13 @@ using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Net.Http.Headers;
using Moq;
using Xunit;
@ -71,11 +71,8 @@ namespace Microsoft.AspNetCore.Mvc
var appRoot = "/";
var contentPath = "~/Home/About";
var expectedPath = "/Home/About";
var httpResponse = new Mock<HttpResponse>();
httpResponse.Setup(o => o.Redirect(expectedPath, false))
.Verifiable();
var httpContext = GetHttpContext(appRoot, contentPath, expectedPath, httpResponse.Object);
var httpContext = GetHttpContext(appRoot);
var actionContext = GetActionContext(httpContext);
var result = new LocalRedirectResult(contentPath);
@ -83,27 +80,23 @@ namespace Microsoft.AspNetCore.Mvc
await result.ExecuteResultAsync(actionContext);
// Assert
httpResponse.Verify();
Assert.Equal(expectedPath, httpContext.Response.Headers[HeaderNames.Location].ToString());
Assert.Equal(StatusCodes.Status302Found, httpContext.Response.StatusCode);
}
[Theory]
[InlineData("", "//", "/test")]
[InlineData("", "/\\", "/test")]
[InlineData("", "//foo", "/test")]
[InlineData("", "/\\foo", "/test")]
[InlineData("", "Home/About", "/Home/About")]
[InlineData("/myapproot", "http://www.example.com", "/test")]
[InlineData("", "//")]
[InlineData("", "/\\")]
[InlineData("", "//foo")]
[InlineData("", "/\\foo")]
[InlineData("", "Home/About")]
[InlineData("/myapproot", "http://www.example.com")]
public async Task Execute_Throws_ForNonLocalUrl(
string appRoot,
string contentPath,
string expectedPath)
string contentPath)
{
// Arrange
var httpResponse = new Mock<HttpResponse>();
httpResponse.Setup(o => o.Redirect(expectedPath, false))
.Verifiable();
var httpContext = GetHttpContext(appRoot, contentPath, expectedPath, httpResponse.Object);
var httpContext = GetHttpContext(appRoot);
var actionContext = GetActionContext(httpContext);
var result = new LocalRedirectResult(contentPath);
@ -116,21 +109,16 @@ namespace Microsoft.AspNetCore.Mvc
}
[Theory]
[InlineData("", "~//", "//")]
[InlineData("", "~/\\", "/\\")]
[InlineData("", "~//foo", "//foo")]
[InlineData("", "~/\\foo", "/\\foo")]
[InlineData("", "~//")]
[InlineData("", "~/\\")]
[InlineData("", "~//foo")]
[InlineData("", "~/\\foo")]
public async Task Execute_Throws_ForNonLocalUrlTilde(
string appRoot,
string contentPath,
string expectedPath)
string contentPath)
{
// Arrange
var httpResponse = new Mock<HttpResponse>();
httpResponse.Setup(o => o.Redirect(expectedPath, false))
.Verifiable();
var httpContext = GetHttpContext(appRoot, contentPath, expectedPath, httpResponse.Object);
var httpContext = GetHttpContext(appRoot);
var actionContext = GetActionContext(httpContext);
var result = new LocalRedirectResult(contentPath);
@ -160,26 +148,12 @@ namespace Microsoft.AspNetCore.Mvc
}
private static HttpContext GetHttpContext(
string appRoot,
string contentPath,
string expectedPath,
HttpResponse response)
string appRoot)
{
var httpContext = new Mock<HttpContext>();
var serviceProvider = GetServiceProvider();
httpContext.Setup(o => o.Response)
.Returns(response);
httpContext.SetupGet(o => o.RequestServices)
.Returns(serviceProvider);
httpContext.SetupGet(o => o.Items)
.Returns(new ItemsDictionary());
httpContext.Setup(o => o.Request.PathBase)
.Returns(new PathString(appRoot));
httpContext.SetupGet(h => h.Features)
.Returns(new FeatureCollection());
return httpContext.Object;
var httpContext = new DefaultHttpContext();
httpContext.RequestServices = GetServiceProvider();
httpContext.Request.PathBase = new PathString(appRoot);
return httpContext;
}
}
}

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using Microsoft.Extensions.Logging.Abstractions;
using Moq;

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.Extensions.Primitives;
using Moq;
using Xunit;

View File

@ -7,7 +7,6 @@ using System.Diagnostics;
using System.Globalization;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

View File

@ -5,7 +5,6 @@ using System.Collections.Generic;
using System.Globalization;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Primitives;

View File

@ -5,7 +5,6 @@ using System.Collections.Generic;
using System.Globalization;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Primitives;

View File

@ -3,7 +3,7 @@
using System.Collections.Generic;
using System.Globalization;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;
namespace Microsoft.AspNetCore.Mvc.ModelBinding

View File

@ -5,13 +5,13 @@ using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Net.Http.Headers;
using Moq;
using Xunit;
@ -73,11 +73,7 @@ namespace Microsoft.AspNetCore.Mvc
string expectedPath)
{
// Arrange
var httpResponse = new Mock<HttpResponse>();
httpResponse.Setup(o => o.Redirect(expectedPath, false))
.Verifiable();
var httpContext = GetHttpContext(appRoot, contentPath, expectedPath, httpResponse.Object);
var httpContext = GetHttpContext(appRoot);
var actionContext = GetActionContext(httpContext);
var result = new RedirectResult(contentPath);
@ -86,7 +82,8 @@ namespace Microsoft.AspNetCore.Mvc
// Assert
// Verifying if Redirect was called with the specific Url and parameter flag.
httpResponse.Verify();
Assert.Equal(expectedPath, httpContext.Response.Headers[HeaderNames.Location].ToString());
Assert.Equal(StatusCodes.Status302Found, httpContext.Response.StatusCode);
}
[Theory]
@ -101,11 +98,7 @@ namespace Microsoft.AspNetCore.Mvc
string expectedPath)
{
// Arrange
var httpResponse = new Mock<HttpResponse>();
httpResponse.Setup(o => o.Redirect(expectedPath, false))
.Verifiable();
var httpContext = GetHttpContext(appRoot, contentPath, expectedPath, httpResponse.Object);
var httpContext = GetHttpContext(appRoot);
var actionContext = GetActionContext(httpContext);
var result = new RedirectResult(contentPath);
@ -114,7 +107,8 @@ namespace Microsoft.AspNetCore.Mvc
// Assert
// Verifying if Redirect was called with the specific Url and parameter flag.
httpResponse.Verify();
Assert.Equal(expectedPath, httpContext.Response.Headers[HeaderNames.Location].ToString());
Assert.Equal(StatusCodes.Status302Found, httpContext.Response.StatusCode);
}
private static ActionContext GetActionContext(HttpContext httpContext)
@ -137,26 +131,12 @@ namespace Microsoft.AspNetCore.Mvc
}
private static HttpContext GetHttpContext(
string appRoot,
string contentPath,
string expectedPath,
HttpResponse response)
string appRoot)
{
var httpContext = new Mock<HttpContext>();
var serviceProvider = GetServiceProvider();
httpContext.Setup(o => o.Response)
.Returns(response);
httpContext.SetupGet(o => o.RequestServices)
.Returns(serviceProvider);
httpContext.SetupGet(o => o.Items)
.Returns(new ItemsDictionary());
httpContext.Setup(o => o.Request.PathBase)
.Returns(new PathString(appRoot));
httpContext.SetupGet(h => h.Features)
.Returns(new FeatureCollection());
return httpContext.Object;
var httpContext = new DefaultHttpContext();
httpContext.RequestServices = GetServiceProvider();
httpContext.Request.PathBase = new PathString(appRoot);
return httpContext;
}
}
}

View File

@ -4,10 +4,10 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc.ViewFeatures.Infrastructure;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Logging.Abstractions;
@ -86,10 +86,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
var base64AndUrlEncodedDataInCookie = WebEncoders.Base64UrlEncode(expectedDataToUnprotect);
var context = new DefaultHttpContext();
context.Request.Cookies = new RequestCookieCollection(new Dictionary<string, string>()
{
{ CookieTempDataProvider.CookieName, base64AndUrlEncodedDataInCookie }
});
context.Request.Headers[HeaderNames.Cookie] = $"{CookieTempDataProvider.CookieName}={base64AndUrlEncodedDataInCookie}";
// Act
var tempDataDictionary = tempDataProvider.LoadTempData(context);
@ -110,17 +107,11 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
var base64AndUrlEncodedDataInCookie = WebEncoders.Base64UrlEncode(expectedDataToUnprotect);
var dataProtector = new PassThroughDataProtector();
var tempDataProvider = GetProvider(dataProtector);
var requestCookies = new RequestCookieCollection(new Dictionary<string, string>()
{
{ CookieTempDataProvider.CookieName, base64AndUrlEncodedDataInCookie }
});
var httpContext = new Mock<HttpContext>();
httpContext
.Setup(hc => hc.Request.Cookies)
.Returns(requestCookies);
var httpContext = new DefaultHttpContext();
httpContext.Request.Headers[HeaderNames.Cookie] = $"{CookieTempDataProvider.CookieName}={base64AndUrlEncodedDataInCookie}";
// Act
var actualValues = tempDataProvider.LoadTempData(httpContext.Object);
var actualValues = tempDataProvider.LoadTempData(httpContext);
// Assert
Assert.Equal(expectedDataToUnprotect, dataProtector.DataToUnprotect);
@ -311,35 +302,23 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
var base64AndUrlEncodedData = WebEncoders.Base64UrlEncode(serializedData);
var dataProtector = new PassThroughDataProtector();
var tempDataProvider = GetProvider(dataProtector);
var requestCookies = new RequestCookieCollection(new Dictionary<string, string>()
{
{ CookieTempDataProvider.CookieName, base64AndUrlEncodedData }
});
var responseCookies = new MockResponseCookieCollection();
var httpContext = new Mock<HttpContext>();
httpContext
.SetupGet(hc => hc.Request.PathBase)
.Returns("/");
httpContext
.Setup(hc => hc.Request.Cookies)
.Returns(requestCookies);
httpContext
.Setup(hc => hc.Response.Cookies)
.Returns(responseCookies);
httpContext
.Setup(hc => hc.Response.Headers)
.Returns(new HeaderDictionary());
var requestCookies = $"{CookieTempDataProvider.CookieName}={base64AndUrlEncodedData}";
var httpContext = new DefaultHttpContext();
httpContext.Request.PathBase = "/";
httpContext.Request.Headers[HeaderNames.Cookie] = requestCookies;
// Act
tempDataProvider.SaveTempData(httpContext.Object, new Dictionary<string, object>());
tempDataProvider.SaveTempData(httpContext, new Dictionary<string, object>());
// Assert
Assert.Equal(1, responseCookies.Count);
var cookie = responseCookies[CookieTempDataProvider.CookieName];
var responseCookies = httpContext.Response.GetTypedHeaders().SetCookie;
Assert.Single(responseCookies);
var cookie = responseCookies.Single();
Assert.NotNull(cookie);
Assert.Equal(CookieTempDataProvider.CookieName, cookie.Name);
Assert.Equal(string.Empty, cookie.Value);
Assert.NotNull(cookie.Options.Expires);
Assert.True(cookie.Options.Expires.Value < DateTimeOffset.Now); // expired cookie
Assert.NotNull(cookie.Expires);
Assert.True(cookie.Expires.Value < DateTimeOffset.Now); // expired cookie
}
[Fact]
@ -364,30 +343,28 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
private static HttpContext GetHttpContext()
{
var context = new Mock<HttpContext>();
context
.SetupGet(hc => hc.Request.PathBase)
.Returns("/");
context
.SetupGet(hc => hc.Response.Cookies)
.Returns(new MockResponseCookieCollection());
return context.Object;
var context = new DefaultHttpContext();
context.Request.PathBase = "/";
return context;
}
private void UpdateRequestWithCookies(HttpContext httpContext)
{
var responseCookies = (MockResponseCookieCollection)httpContext.Response.Cookies;
var responseCookies = httpContext.Response.GetTypedHeaders().SetCookie;
var values = new Dictionary<string, string>();
foreach (var responseCookie in responseCookies)
if (responseCookies.Count > 0)
{
values.Add(responseCookie.Key, responseCookie.Value);
}
var stringBuilder = new StringBuilder();
foreach (var cookie in responseCookies)
{
stringBuilder.Append(cookie.Name.AsSpan());
stringBuilder.Append("=");
stringBuilder.Append(cookie.Value.AsSpan());
stringBuilder.Append(";");
}
if (values.Count > 0)
{
httpContext.Request.Cookies = new RequestCookieCollection(values);
httpContext.Request.Headers[HeaderNames.Cookie] = stringBuilder.ToString();
}
}

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Net;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Xunit;

View File

@ -7,7 +7,6 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;

View File

@ -8,7 +8,6 @@ using System.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;

View File

@ -6,7 +6,6 @@ using System.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.Extensions.Primitives;

View File

@ -6,7 +6,6 @@ using System.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.Extensions.Primitives;

View File

@ -9,7 +9,6 @@ using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.Extensions.Primitives;

View File

@ -7,7 +7,6 @@ using System.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.Extensions.Primitives;
using Xunit;

View File

@ -3,7 +3,6 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
namespace HtmlGenerationWebSite.Models
{

View File

@ -6,7 +6,6 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization.Test.TestObjects;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.DependencyInjection;

View File

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.AspNetCore.Http;
namespace Microsoft.AspNetCore.IISIntegration.FunctionalTests

View File

@ -10,7 +10,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
using Microsoft.Extensions.Logging;

View File

@ -7,7 +7,7 @@ using System.Net;
using System.Net.Sockets;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal;
using Microsoft.AspNetCore.Testing;
using Microsoft.AspNetCore.Testing.xunit;

View File

@ -9,7 +9,6 @@ using System.Text;
using BenchmarkDotNet.Attributes;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
@ -197,7 +196,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
_responseHeadersDirect = (HttpResponseHeaders)http1Connection.ResponseHeaders;
var context = new DefaultHttpContext(http1Connection);
_response = new DefaultHttpResponse(context);
_response = context.Response;
switch (Type)
{

View File

@ -19,7 +19,6 @@ using Microsoft.AspNetCore.Connections.Features;
using Microsoft.AspNetCore.Http.Connections.Internal;
using Microsoft.AspNetCore.Http.Connections.Internal.Transports;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Internal;
using Microsoft.AspNetCore.SignalR.Tests;
using Microsoft.AspNetCore.Testing;