Skip to content

Commit

Permalink
Add test for ExpectContinue with no content (dotnet#30065)
Browse files Browse the repository at this point in the history
* Add test for ExpectContinue with no content

* Address PR feedback
  • Loading branch information
stephentoub authored Jun 2, 2018
1 parent 3c2ce7b commit 3ae01e9
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions src/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,7 @@ await TestHelper.WhenAllCompletedOrAnyFailed(
}
}

[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Doesn't send fragments")]
[ActiveIssue(29802, TargetFrameworkMonikers.Uap)]
[Theory]
[InlineData("#origFragment", "", "#origFragment", false)]
Expand All @@ -1199,12 +1200,6 @@ public async Task GetAsync_AllowAutoRedirectTrue_RetainsOriginalFragmentIfApprop
return;
}

if (IsNetfxHandler)
{
// Similarly, netfx doesn't send fragments at all.
return;
}

if (IsWinHttpHandler)
{
// According to https://tools.ietf.org/html/rfc7231#section-7.1.2,
Expand Down Expand Up @@ -1893,15 +1888,10 @@ await LoopbackServer.CreateServerAsync(async (server, url) =>
});
}

[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "No exception thrown")]
[Fact]
public async Task SendAsync_TransferEncodingSetButNoRequestContent_Throws()
{
if (IsNetfxHandler)
{
// no exception thrown
return;
}

var req = new HttpRequestMessage(HttpMethod.Post, "http://bing.com");
req.Headers.TransferEncodingChunked = true;
using (HttpClient c = CreateHttpClient())
Expand Down Expand Up @@ -2599,6 +2589,25 @@ public async Task PostAsync_ExpectContinue_Success(bool? expectContinue, string
}
}

[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Doesn't send content for get requests")]
[ActiveIssue(29802, TargetFrameworkMonikers.Uap)]
[Fact]
public async Task GetAsync_ExpectContinueTrue_NoContent_StillSendsHeader()
{
await LoopbackServer.CreateClientAndServerAsync(async uri =>
{
using (var client = CreateHttpClient())
{
client.DefaultRequestHeaders.ExpectContinue = true;
await client.GetStringAsync(uri);
}
}, async server =>
{
List<string> headers = await server.AcceptConnectionSendResponseAndCloseAsync();
Assert.Contains("Expect: 100-continue", headers);
});
}

[ActiveIssue(29802, TargetFrameworkMonikers.Uap)]
[Theory]
[InlineData(false)]
Expand Down

0 comments on commit 3ae01e9

Please sign in to comment.