Do not block on async calls
This commit is contained in:
Родитель
17852e5217
Коммит
dc8d1d0788
|
@ -253,7 +253,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
|
|||
Assert.True(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length");
|
||||
Assert.Equal(FileLength.ToString(), contentLength.First());
|
||||
Assert.Null(response.Headers.TransferEncodingChunked);
|
||||
Assert.Equal(FileLength, response.Content.ReadAsByteArrayAsync().Result.Length);
|
||||
Assert.Equal(FileLength, (await response.Content.ReadAsByteArrayAsync()).Length);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
Assert.Equal(200, (int)response.StatusCode);
|
||||
Assert.False(response.Headers.TransferEncodingChunked.HasValue, "Chunked");
|
||||
Assert.Equal(0, response.Content.Headers.ContentLength);
|
||||
Assert.Equal(string.Empty, response.Content.ReadAsStringAsync().Result);
|
||||
Assert.Equal(string.Empty, await response.Content.ReadAsStringAsync());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
|
||||
[ConditionalFact]
|
||||
public void ResponseBody_WriteContentLengthNotEnoughWritten_Throws()
|
||||
public async Task ResponseBody_WriteContentLengthNotEnoughWritten_Throws()
|
||||
{
|
||||
string address;
|
||||
using (Utilities.CreateHttpServer(out address, httpContext =>
|
||||
|
@ -131,7 +131,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
return httpContext.Response.Body.WriteAsync(new byte[5], 0, 5);
|
||||
}))
|
||||
{
|
||||
Assert.Throws<AggregateException>(() => SendRequestAsync(address).Result);
|
||||
await Assert.ThrowsAsync<HttpRequestException>(async () => await SendRequestAsync(address));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -274,7 +274,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
Assert.True(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length");
|
||||
Assert.Equal(FileLength.ToString(), contentLength.First());
|
||||
Assert.Null(response.Headers.TransferEncodingChunked);
|
||||
Assert.Equal(FileLength, response.Content.ReadAsByteArrayAsync().Result.Length);
|
||||
Assert.Equal(FileLength, (await response.Content.ReadAsByteArrayAsync()).Length);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
|
||||
[ConditionalFact]
|
||||
public void Server_AppException_ClientReset()
|
||||
public async Task Server_AppException_ClientReset()
|
||||
{
|
||||
string address;
|
||||
using (Utilities.CreateHttpServer(out address, httpContext =>
|
||||
|
@ -144,11 +144,11 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}))
|
||||
{
|
||||
Task<string> requestTask = SendRequestAsync(address);
|
||||
Assert.Throws<AggregateException>(() => requestTask.Result);
|
||||
await Assert.ThrowsAsync<HttpRequestException>(async () => await requestTask);
|
||||
|
||||
// Do it again to make sure the server didn't crash
|
||||
requestTask = SendRequestAsync(address);
|
||||
Assert.Throws<AggregateException>(() => requestTask.Result);
|
||||
await Assert.ThrowsAsync<HttpRequestException>(async () => await requestTask);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче