Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting HasStarted to true when calling StartAsync #1808

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,8 @@ string IHttpResponseFeature.ReasonPhrase
set;
}

bool IHttpResponseFeature.HasStarted
{
get;
}
bool _hasStarted;
bool IHttpResponseFeature.HasStarted => _hasStarted;

IHeaderDictionary IHttpResponseFeature.Headers
{
Expand Down Expand Up @@ -320,6 +318,7 @@ async Task IHttpResponseBodyFeature.SendFileAsync(

Task IHttpResponseBodyFeature.StartAsync(CancellationToken cancellationToken)
{
_hasStarted = true;
return Task.CompletedTask;
}
#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,27 @@ public void EnsureTraceIdStaysTheSame()
Assert.Equal(traceId1, traceId2);
}

[Fact]
public void TestDefaultResponseHasStartedFalse()
{
var features = new InvokeFeatures();
var response = (IHttpResponseFeature)features;

Assert.False(response.HasStarted);
}

[Fact]
public async Task TestStartAsyncSetsHasStartedTrue()
{
var features = new InvokeFeatures();
var responseBody = (IHttpResponseBodyFeature)features;

await responseBody.StartAsync();

var response = (IHttpResponseFeature)features;
Assert.True(response.HasStarted);
}

private async Task<APIGatewayProxyResponse> InvokeAPIGatewayRequest(string fileName, bool configureApiToReturnExceptionDetail = false)
{
return await InvokeAPIGatewayRequest(new TestLambdaContext(), fileName, configureApiToReturnExceptionDetail);
Expand Down