Copy EndpointFeature when using LongPolling (#8730)
This commit is contained in:
parent
26a118e462
commit
4b230ec419
|
|
@ -12,6 +12,7 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Connections;
|
||||
using Microsoft.AspNetCore.Http.Connections.Internal.Transports;
|
||||
using Microsoft.AspNetCore.Http.Endpoints;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using Microsoft.AspNetCore.Internal;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
|
@ -567,7 +568,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
|
|||
requestFeature.PathBase = existingRequestFeature.PathBase;
|
||||
requestFeature.QueryString = existingRequestFeature.QueryString;
|
||||
requestFeature.RawTarget = existingRequestFeature.RawTarget;
|
||||
var requestHeaders = new Dictionary<string, StringValues>(existingRequestFeature.Headers.Count, StringComparer.Ordinal);
|
||||
var requestHeaders = new Dictionary<string, StringValues>(existingRequestFeature.Headers.Count, StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var header in existingRequestFeature.Headers)
|
||||
{
|
||||
requestHeaders[header.Key] = header.Value;
|
||||
|
|
@ -600,6 +601,9 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
|
|||
var newHttpContext = new DefaultHttpContext(features);
|
||||
newHttpContext.TraceIdentifier = context.TraceIdentifier;
|
||||
|
||||
var endpointFeature = context.Features.Get<IEndpointFeature>();
|
||||
newHttpContext.SetEndpoint(endpointFeature?.Endpoint);
|
||||
|
||||
CloneUser(newHttpContext, context);
|
||||
|
||||
// Making request services function property could be tricky and expensive as it would require
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ using Microsoft.AspNetCore.Connections;
|
|||
using Microsoft.AspNetCore.Connections.Features;
|
||||
using Microsoft.AspNetCore.Http.Connections.Internal;
|
||||
using Microsoft.AspNetCore.Http.Connections.Internal.Transports;
|
||||
using Microsoft.AspNetCore.Http.Endpoints;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using Microsoft.AspNetCore.Http.Internal;
|
||||
using Microsoft.AspNetCore.SignalR.Tests;
|
||||
|
|
@ -627,6 +628,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
context.Connection.LocalPort = 4563;
|
||||
context.Connection.RemoteIpAddress = IPAddress.IPv6Any;
|
||||
context.Connection.RemotePort = 43456;
|
||||
context.SetEndpoint(new Endpoint(null, null, "TestName"));
|
||||
|
||||
var builder = new ConnectionBuilder(services.BuildServiceProvider());
|
||||
builder.UseConnectionHandler<HttpContextConnectionHandler>();
|
||||
|
|
@ -679,6 +681,9 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
Assert.Equal(Stream.Null, connectionHttpContext.Response.Body);
|
||||
Assert.NotNull(connectionHttpContext.Response.Headers);
|
||||
Assert.Equal("application/xml", connectionHttpContext.Response.ContentType);
|
||||
var endpointFeature = connectionHttpContext.Features.Get<IEndpointFeature>();
|
||||
Assert.NotNull(endpointFeature);
|
||||
Assert.Equal("TestName", endpointFeature.Endpoint.DisplayName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue