Reset Frame.Scheme on each request (#366).

This commit is contained in:
Cesar Blum Silveira 2015-11-13 14:29:03 -08:00
parent 2ac5e4c790
commit a3a49d21b8
3 changed files with 30 additions and 3 deletions

View File

@ -24,7 +24,6 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
// then the list of `implementedFeatures` in the generated code project MUST also be updated.
// See also: tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/FrameFeatureCollection.cs
private string _scheme;
private string _pathBase;
private int _featureRevision;
@ -90,12 +89,12 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
{
get
{
return _scheme ?? "http";
return Scheme ?? "http";
}
set
{
_scheme = value;
Scheme = value;
}
}

View File

@ -67,6 +67,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
Reset();
}
public string Scheme { get; set; }
public string Method { get; set; }
public string RequestUri { get; set; }
public string Path { get; set; }
@ -102,6 +103,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
ResetResponseHeaders();
ResetFeatureCollection();
Scheme = null;
Method = null;
RequestUri = null;
Path = null;

View File

@ -0,0 +1,26 @@
// 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.AspNet.Http.Features;
using Microsoft.AspNet.Server.Kestrel.Http;
using Xunit;
namespace Microsoft.AspNet.Server.KestrelTests
{
public class FrameFacts
{
[Fact]
public void ResetResetsScheme()
{
// Arrange
var frame = new Frame(new ConnectionContext() { DateHeaderValueManager = new DateHeaderValueManager() });
frame.Scheme = "https";
// Act
frame.Reset();
// Assert
Assert.Equal("http", frame.Get<IHttpRequestFeature>().Scheme);
}
}
}