Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Todd Menier 2018-03-30 15:08:38 -05:00
commit 2c25acb5da
2 changed files with 11 additions and 1 deletions

View File

@ -215,6 +215,16 @@ namespace Flurl.Test.Http
CallAndAssertCountAsync(6));
}
[Test]
public async Task does_not_throw_nullref_for_empty_content() {
await "http://some-api.com".AppendPathSegment("foo").SendAsync(HttpMethod.Post, null);
await "http://some-api.com".AppendPathSegment("foo").PostJsonAsync(new { foo = "bar" });
HttpTest.ShouldHaveCalled("http://some-api.com/foo")
.WithVerb(HttpMethod.Post)
.WithContentType("application/json");
}
private async Task CallAndAssertCountAsync(int calls) {
using (var test = new HttpTest()) {
for (int i = 0; i < calls; i++) {

View File

@ -189,7 +189,7 @@ namespace Flurl.Http.Testing
/// </summary>
public HttpCallAssertion WithContentType(string mediaType) {
_expectedConditions.Add("content type " + mediaType);
return With(c => c.Request.Content.Headers.ContentType.MediaType == mediaType);
return With(c => c.Request.Content?.Headers?.ContentType?.MediaType == mediaType);
}
/// <summary>