Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Commit

Permalink
Add test for 100-continue + response.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cesar Blum Silveira committed Mar 22, 2017
1 parent 0277c60 commit 6031abd
Showing 1 changed file with 48 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ await connection.Receive(
}

[Fact]
public async Task WhenResponseAlreadyStartedResponseEndedBeforeDrainingRequestBody()
public async Task WhenResponseAlreadyStartedResponseEndedBeforeConsumingRequestBody()
{
using (var server = new TestServer(async httpContext =>
{
Expand Down Expand Up @@ -1405,7 +1405,7 @@ await connection.Receive(
}

[Fact]
public async Task WhenResponseNotStartedResponseEndedAfterDrainingRequestBody()
public async Task WhenResponseNotStartedResponseEndedAfterConsumingRequestBody()
{
using (var server = new TestServer(httpContext =>
{
Expand Down Expand Up @@ -1475,6 +1475,52 @@ await connection.ReceiveForcedEnd(
}
}

[Fact]
public async Task Sending100ContinueAndResponseSendsChunkTerminatorBeforeConsumingRequestBody()
{
using (var server = new TestServer(async httpContext =>
{
await httpContext.Request.Body.ReadAsync(new byte[1], 0, 1);
await httpContext.Response.WriteAsync("hello, world");
}))
{
using (var connection = server.CreateConnection())
{
await connection.Send(
"POST / HTTP/1.1",
"Content-Length: 2",
"Expect: 100-continue",
"",
"");

await connection.Receive(
"HTTP/1.1 100 Continue",
"",
"");

await connection.Send(
"a");

await connection.Receive(
"HTTP/1.1 200 OK",
$"Date: {server.Context.DateHeaderValue}",
$"Transfer-Encoding: chunked",
"",
"c",
"hello, world",
"");

// If the expected behavior is regressed, this will hang because the
// server will try to consume the request body before flushing the chunked
// terminator.
await connection.Receive(
"0",
"",
"");
}
}
}

public static TheoryData<string, StringValues, string> NullHeaderData
{
get
Expand Down

0 comments on commit 6031abd

Please sign in to comment.