HttpSysServer 720 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. commit fbc5b64cd8fee5e966b51ce0dbb9f32fd524fce4
  2. Author: Chris Ross <[email protected]>
  3. Date: Fri Mar 16 10:56:36 2018 -0700
  4. React to new SocketHttpHandler (#434)
  5. diff --git a/build/dependencies.props b/build/dependencies.props
  6. index f2976b08b8a..5aaa28edec4 100644
  7. --- a/build/dependencies.props
  8. +++ b/build/dependencies.props
  9. @@ -4,17 +4,17 @@
  10. </PropertyGroup>
  11. <PropertyGroup Label="Package Versions">
  12. <InternalAspNetCoreSdkPackageVersion>2.1.0-preview2-15728</InternalAspNetCoreSdkPackageVersion>
  13. - <MicrosoftAspNetCoreAuthenticationCorePackageVersion>2.1.0-preview2-30272</MicrosoftAspNetCoreAuthenticationCorePackageVersion>
  14. - <MicrosoftAspNetCoreHostingPackageVersion>2.1.0-preview2-30272</MicrosoftAspNetCoreHostingPackageVersion>
  15. - <MicrosoftAspNetCoreTestingPackageVersion>2.1.0-preview2-30272</MicrosoftAspNetCoreTestingPackageVersion>
  16. - <MicrosoftExtensionsLoggingConsolePackageVersion>2.1.0-preview2-30272</MicrosoftExtensionsLoggingConsolePackageVersion>
  17. + <MicrosoftAspNetCoreAuthenticationCorePackageVersion>2.1.0-preview2-30301</MicrosoftAspNetCoreAuthenticationCorePackageVersion>
  18. + <MicrosoftAspNetCoreHostingPackageVersion>2.1.0-preview2-30301</MicrosoftAspNetCoreHostingPackageVersion>
  19. + <MicrosoftAspNetCoreTestingPackageVersion>2.1.0-preview2-30301</MicrosoftAspNetCoreTestingPackageVersion>
  20. + <MicrosoftExtensionsLoggingConsolePackageVersion>2.1.0-preview2-30301</MicrosoftExtensionsLoggingConsolePackageVersion>
  21. <MicrosoftNETCoreApp20PackageVersion>2.0.0</MicrosoftNETCoreApp20PackageVersion>
  22. - <MicrosoftNETCoreApp21PackageVersion>2.1.0-preview2-26225-03</MicrosoftNETCoreApp21PackageVersion>
  23. - <MicrosoftNetHttpHeadersPackageVersion>2.1.0-preview2-30272</MicrosoftNetHttpHeadersPackageVersion>
  24. + <MicrosoftNETCoreApp21PackageVersion>2.1.0-preview2-26308-01</MicrosoftNETCoreApp21PackageVersion>
  25. + <MicrosoftNetHttpHeadersPackageVersion>2.1.0-preview2-30301</MicrosoftNetHttpHeadersPackageVersion>
  26. <MicrosoftNETTestSdkPackageVersion>15.6.0</MicrosoftNETTestSdkPackageVersion>
  27. - <MicrosoftWin32RegistryPackageVersion>4.5.0-preview2-26224-02</MicrosoftWin32RegistryPackageVersion>
  28. - <SystemNetHttpWinHttpHandlerPackageVersion>4.5.0-preview2-26224-02</SystemNetHttpWinHttpHandlerPackageVersion>
  29. - <SystemSecurityPrincipalWindowsPackageVersion>4.5.0-preview2-26224-02</SystemSecurityPrincipalWindowsPackageVersion>
  30. + <MicrosoftWin32RegistryPackageVersion>4.5.0-preview2-26308-02</MicrosoftWin32RegistryPackageVersion>
  31. + <SystemNetHttpWinHttpHandlerPackageVersion>4.5.0-preview2-26308-02</SystemNetHttpWinHttpHandlerPackageVersion>
  32. + <SystemSecurityPrincipalWindowsPackageVersion>4.5.0-preview2-26308-02</SystemSecurityPrincipalWindowsPackageVersion>
  33. <XunitPackageVersion>2.3.1</XunitPackageVersion>
  34. <XunitRunnerVisualStudioPackageVersion>2.4.0-beta.1.build3945</XunitRunnerVisualStudioPackageVersion>
  35. </PropertyGroup>
  36. diff --git a/src/Microsoft.AspNetCore.Server.HttpSys/RequestProcessing/RequestStream.cs b/src/Microsoft.AspNetCore.Server.HttpSys/RequestProcessing/RequestStream.cs
  37. index 284a3d856ec..6e0cb2ace51 100644
  38. --- a/src/Microsoft.AspNetCore.Server.HttpSys/RequestProcessing/RequestStream.cs
  39. +++ b/src/Microsoft.AspNetCore.Server.HttpSys/RequestProcessing/RequestStream.cs
  40. @@ -133,12 +133,10 @@ namespace Microsoft.AspNetCore.Server.HttpSys
  41. dataRead = _requestContext.Request.GetChunks(ref _dataChunkIndex, ref _dataChunkOffset, buffer, offset, size);
  42. }
  43. - if (_dataChunkIndex == -1 && dataRead < size)
  44. + if (_dataChunkIndex == -1 && dataRead == 0)
  45. {
  46. uint statusCode = 0;
  47. uint extraDataRead = 0;
  48. - offset += (int)dataRead;
  49. - size -= (int)dataRead;
  50. // the http.sys team recommends that we limit the size to 128kb
  51. if (size > MaxReadSize)
  52. @@ -209,72 +207,68 @@ namespace Microsoft.AspNetCore.Server.HttpSys
  53. {
  54. dataRead = _requestContext.Request.GetChunks(ref _dataChunkIndex, ref _dataChunkOffset, buffer, offset, size);
  55. - if (_dataChunkIndex != -1 && dataRead == size)
  56. + if (dataRead > 0)
  57. {
  58. asyncResult = new RequestStreamAsyncResult(this, state, callback, buffer, offset, 0);
  59. asyncResult.Complete((int)dataRead);
  60. + return asyncResult;
  61. }
  62. }
  63. - if (_dataChunkIndex == -1 && dataRead < size)
  64. - {
  65. - uint statusCode = 0;
  66. - offset += (int)dataRead;
  67. - size -= (int)dataRead;
  68. + uint statusCode = 0;
  69. - // the http.sys team recommends that we limit the size to 128kb
  70. - if (size > MaxReadSize)
  71. - {
  72. - size = MaxReadSize;
  73. - }
  74. + // the http.sys team recommends that we limit the size to 128kb
  75. + if (size > MaxReadSize)
  76. + {
  77. + size = MaxReadSize;
  78. + }
  79. - asyncResult = new RequestStreamAsyncResult(this, state, callback, buffer, offset, dataRead);
  80. - uint bytesReturned;
  81. + asyncResult = new RequestStreamAsyncResult(this, state, callback, buffer, offset, dataRead);
  82. + uint bytesReturned;
  83. - try
  84. - {
  85. - uint flags = 0;
  86. -
  87. - statusCode =
  88. - HttpApi.HttpReceiveRequestEntityBody(
  89. - RequestQueueHandle,
  90. - RequestId,
  91. - flags,
  92. - asyncResult.PinnedBuffer,
  93. - (uint)size,
  94. - out bytesReturned,
  95. - asyncResult.NativeOverlapped);
  96. - }
  97. - catch (Exception e)
  98. - {
  99. - LogHelper.LogException(Logger, "BeginRead", e);
  100. - asyncResult.Dispose();
  101. - throw;
  102. - }
  103. + try
  104. + {
  105. + uint flags = 0;
  106. +
  107. + statusCode =
  108. + HttpApi.HttpReceiveRequestEntityBody(
  109. + RequestQueueHandle,
  110. + RequestId,
  111. + flags,
  112. + asyncResult.PinnedBuffer,
  113. + (uint)size,
  114. + out bytesReturned,
  115. + asyncResult.NativeOverlapped);
  116. + }
  117. + catch (Exception e)
  118. + {
  119. + LogHelper.LogException(Logger, "BeginRead", e);
  120. + asyncResult.Dispose();
  121. + throw;
  122. + }
  123. - if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS && statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_IO_PENDING)
  124. + if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS && statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_IO_PENDING)
  125. + {
  126. + asyncResult.Dispose();
  127. + if (statusCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_HANDLE_EOF)
  128. {
  129. - asyncResult.Dispose();
  130. - if (statusCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_HANDLE_EOF)
  131. - {
  132. - asyncResult = new RequestStreamAsyncResult(this, state, callback, dataRead);
  133. - asyncResult.Complete((int)bytesReturned);
  134. - }
  135. - else
  136. - {
  137. - Exception exception = new IOException(string.Empty, new HttpSysException((int)statusCode));
  138. - LogHelper.LogException(Logger, "BeginRead", exception);
  139. - Abort();
  140. - throw exception;
  141. - }
  142. + asyncResult = new RequestStreamAsyncResult(this, state, callback, dataRead);
  143. + asyncResult.Complete((int)bytesReturned);
  144. }
  145. - else if (statusCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS &&
  146. - HttpSysListener.SkipIOCPCallbackOnSuccess)
  147. + else
  148. {
  149. - // IO operation completed synchronously - callback won't be called to signal completion.
  150. - asyncResult.IOCompleted(statusCode, bytesReturned);
  151. + Exception exception = new IOException(string.Empty, new HttpSysException((int)statusCode));
  152. + LogHelper.LogException(Logger, "BeginRead", exception);
  153. + Abort();
  154. + throw exception;
  155. }
  156. }
  157. + else if (statusCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS &&
  158. + HttpSysListener.SkipIOCPCallbackOnSuccess)
  159. + {
  160. + // IO operation completed synchronously - callback won't be called to signal completion.
  161. + asyncResult.IOCompleted(statusCode, bytesReturned);
  162. + }
  163. return asyncResult;
  164. }
  165. @@ -322,7 +316,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
  166. if (_dataChunkIndex != -1)
  167. {
  168. dataRead = _requestContext.Request.GetChunks(ref _dataChunkIndex, ref _dataChunkOffset, buffer, offset, size);
  169. - if (_dataChunkIndex != -1 && dataRead == size)
  170. + if (dataRead > 0)
  171. {
  172. UpdateAfterRead(UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS, dataRead);
  173. if (TryCheckSizeLimit((int)dataRead, out var exception))
  174. @@ -334,85 +328,82 @@ namespace Microsoft.AspNetCore.Server.HttpSys
  175. }
  176. }
  177. - if (_dataChunkIndex == -1 && dataRead < size)
  178. - {
  179. - uint statusCode = 0;
  180. - offset += (int)dataRead;
  181. - size -= (int)dataRead;
  182. + uint statusCode = 0;
  183. + offset += (int)dataRead;
  184. + size -= (int)dataRead;
  185. - // the http.sys team recommends that we limit the size to 128kb
  186. - if (size > MaxReadSize)
  187. - {
  188. - size = MaxReadSize;
  189. - }
  190. -
  191. - var cancellationRegistration = default(CancellationTokenRegistration);
  192. - if (cancellationToken.CanBeCanceled)
  193. - {
  194. - cancellationRegistration = RequestContext.RegisterForCancellation(cancellationToken);
  195. - }
  196. + // the http.sys team recommends that we limit the size to 128kb
  197. + if (size > MaxReadSize)
  198. + {
  199. + size = MaxReadSize;
  200. + }
  201. - asyncResult = new RequestStreamAsyncResult(this, null, null, buffer, offset, dataRead, cancellationRegistration);
  202. - uint bytesReturned;
  203. + var cancellationRegistration = default(CancellationTokenRegistration);
  204. + if (cancellationToken.CanBeCanceled)
  205. + {
  206. + cancellationRegistration = RequestContext.RegisterForCancellation(cancellationToken);
  207. + }
  208. - try
  209. - {
  210. - uint flags = 0;
  211. + asyncResult = new RequestStreamAsyncResult(this, null, null, buffer, offset, dataRead, cancellationRegistration);
  212. + uint bytesReturned;
  213. - statusCode =
  214. - HttpApi.HttpReceiveRequestEntityBody(
  215. - RequestQueueHandle,
  216. - RequestId,
  217. - flags,
  218. - asyncResult.PinnedBuffer,
  219. - (uint)size,
  220. - out bytesReturned,
  221. - asyncResult.NativeOverlapped);
  222. - }
  223. - catch (Exception e)
  224. - {
  225. - asyncResult.Dispose();
  226. - Abort();
  227. - LogHelper.LogException(Logger, "ReadAsync", e);
  228. - throw;
  229. - }
  230. + try
  231. + {
  232. + uint flags = 0;
  233. +
  234. + statusCode =
  235. + HttpApi.HttpReceiveRequestEntityBody(
  236. + RequestQueueHandle,
  237. + RequestId,
  238. + flags,
  239. + asyncResult.PinnedBuffer,
  240. + (uint)size,
  241. + out bytesReturned,
  242. + asyncResult.NativeOverlapped);
  243. + }
  244. + catch (Exception e)
  245. + {
  246. + asyncResult.Dispose();
  247. + Abort();
  248. + LogHelper.LogException(Logger, "ReadAsync", e);
  249. + throw;
  250. + }
  251. - if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS && statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_IO_PENDING)
  252. - {
  253. - asyncResult.Dispose();
  254. - if (statusCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_HANDLE_EOF)
  255. - {
  256. - uint totalRead = dataRead + bytesReturned;
  257. - UpdateAfterRead(statusCode, totalRead);
  258. - if (TryCheckSizeLimit((int)totalRead, out var exception))
  259. - {
  260. - return Task.FromException<int>(exception);
  261. - }
  262. - // TODO: Verbose log totalRead
  263. - return Task.FromResult<int>((int)totalRead);
  264. - }
  265. - else
  266. - {
  267. - Exception exception = new IOException(string.Empty, new HttpSysException((int)statusCode));
  268. - LogHelper.LogException(Logger, "ReadAsync", exception);
  269. - Abort();
  270. - throw exception;
  271. - }
  272. - }
  273. - else if (statusCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS &&
  274. - HttpSysListener.SkipIOCPCallbackOnSuccess)
  275. + if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS && statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_IO_PENDING)
  276. + {
  277. + asyncResult.Dispose();
  278. + if (statusCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_HANDLE_EOF)
  279. {
  280. - // IO operation completed synchronously - callback won't be called to signal completion.
  281. - asyncResult.Dispose();
  282. uint totalRead = dataRead + bytesReturned;
  283. UpdateAfterRead(statusCode, totalRead);
  284. if (TryCheckSizeLimit((int)totalRead, out var exception))
  285. {
  286. return Task.FromException<int>(exception);
  287. }
  288. - // TODO: Verbose log
  289. + // TODO: Verbose log totalRead
  290. return Task.FromResult<int>((int)totalRead);
  291. }
  292. + else
  293. + {
  294. + Exception exception = new IOException(string.Empty, new HttpSysException((int)statusCode));
  295. + LogHelper.LogException(Logger, "ReadAsync", exception);
  296. + Abort();
  297. + throw exception;
  298. + }
  299. + }
  300. + else if (statusCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS &&
  301. + HttpSysListener.SkipIOCPCallbackOnSuccess)
  302. + {
  303. + // IO operation completed synchronously - callback won't be called to signal completion.
  304. + asyncResult.Dispose();
  305. + uint totalRead = dataRead + bytesReturned;
  306. + UpdateAfterRead(statusCode, totalRead);
  307. + if (TryCheckSizeLimit((int)totalRead, out var exception))
  308. + {
  309. + return Task.FromException<int>(exception);
  310. + }
  311. + // TODO: Verbose log
  312. + return Task.FromResult<int>((int)totalRead);
  313. }
  314. return asyncResult.Task;
  315. }
  316. diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/RequestBodyTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/RequestBodyTests.cs
  317. index 9ea7f4805fd..baec5a82044 100644
  318. --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/RequestBodyTests.cs
  319. +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/RequestBodyTests.cs
  320. @@ -344,7 +344,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
  321. content.Block.Release();
  322. context.Dispose();
  323. - await Assert.ThrowsAsync<TaskCanceledException>(async () => await responseTask);
  324. + await Assert.ThrowsAnyAsync<OperationCanceledException>(async () => await responseTask);
  325. }
  326. }
  327. @@ -421,6 +421,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
  328. protected async override Task SerializeToStreamAsync(Stream stream, TransportContext context)
  329. {
  330. await stream.WriteAsync(new byte[5], 0, 5);
  331. + await stream.FlushAsync();
  332. await Block.WaitAsync();
  333. await stream.WriteAsync(new byte[5], 0, 5);
  334. }
  335. diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseBodyTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseBodyTests.cs
  336. index ef56e997cb4..0c91833773f 100644
  337. --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseBodyTests.cs
  338. +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseBodyTests.cs
  339. @@ -427,7 +427,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
  340. var context = await server.AcceptAsync(Utilities.DefaultTimeout);
  341. // First write sends headers
  342. cts.Cancel();
  343. - await Assert.ThrowsAsync<TaskCanceledException>(() => responseTask);
  344. + await Assert.ThrowsAnyAsync<OperationCanceledException>(() => responseTask);
  345. Assert.True(context.DisconnectToken.WaitHandle.WaitOne(TimeSpan.FromSeconds(5)));
  346. Assert.Throws<IOException>(() =>
  347. {
  348. @@ -458,7 +458,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
  349. // First write sends headers
  350. cts.Cancel();
  351. - await Assert.ThrowsAsync<TaskCanceledException>(() => responseTask);
  352. + await Assert.ThrowsAnyAsync<OperationCanceledException>(() => responseTask);
  353. Assert.True(context.DisconnectToken.WaitHandle.WaitOne(TimeSpan.FromSeconds(5)));
  354. await Assert.ThrowsAsync<IOException>(async () =>
  355. @@ -489,7 +489,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
  356. var context = await server.AcceptAsync(Utilities.DefaultTimeout);
  357. // First write sends headers
  358. cts.Cancel();
  359. - await Assert.ThrowsAsync<TaskCanceledException>(() => responseTask);
  360. + await Assert.ThrowsAnyAsync<OperationCanceledException>(() => responseTask);
  361. Assert.True(context.DisconnectToken.WaitHandle.WaitOne(TimeSpan.FromSeconds(5)));
  362. // It can take several tries before Write notices the disconnect.
  363. for (int i = 0; i < Utilities.WriteRetryLimit; i++)
  364. @@ -512,7 +512,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
  365. var context = await server.AcceptAsync(Utilities.DefaultTimeout);
  366. // First write sends headers
  367. cts.Cancel();
  368. - await Assert.ThrowsAsync<TaskCanceledException>(() => responseTask);
  369. + await Assert.ThrowsAnyAsync<OperationCanceledException>(() => responseTask);
  370. Assert.True(context.DisconnectToken.WaitHandle.WaitOne(TimeSpan.FromSeconds(5)));
  371. // It can take several tries before Write notices the disconnect.
  372. for (int i = 0; i < Utilities.WriteRetryLimit; i++)
  373. diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseSendFileTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseSendFileTests.cs
  374. index 2a962c69f2e..990af071e71 100644
  375. --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseSendFileTests.cs
  376. +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseSendFileTests.cs
  377. @@ -468,7 +468,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
  378. // First write sends headers
  379. cts.Cancel();
  380. - await Assert.ThrowsAsync<TaskCanceledException>(() => responseTask);
  381. + await Assert.ThrowsAnyAsync<OperationCanceledException>(() => responseTask);
  382. Assert.True(context.DisconnectToken.WaitHandle.WaitOne(TimeSpan.FromSeconds(5)));
  383. await Assert.ThrowsAsync<IOException>(async () =>
  384. @@ -499,7 +499,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
  385. var context = await server.AcceptAsync(Utilities.DefaultTimeout);
  386. // First write sends headers
  387. cts.Cancel();
  388. - await Assert.ThrowsAsync<TaskCanceledException>(() => responseTask);
  389. + await Assert.ThrowsAnyAsync<OperationCanceledException>(() => responseTask);
  390. Assert.True(context.DisconnectToken.WaitHandle.WaitOne(TimeSpan.FromSeconds(5)));
  391. // It can take several tries before Send notices the disconnect.
  392. for (int i = 0; i < Utilities.WriteRetryLimit; i++)
  393. diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ServerTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ServerTests.cs
  394. index 60c95a94f1c..c15d47fd15a 100644
  395. --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ServerTests.cs
  396. +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ServerTests.cs
  397. @@ -96,7 +96,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
  398. Assert.True(canceled.WaitOne(interval), "canceled");
  399. Assert.True(ct.IsCancellationRequested, "IsCancellationRequested");
  400. - await Assert.ThrowsAsync<TaskCanceledException>(() => responseTask);
  401. + await Assert.ThrowsAnyAsync<OperationCanceledException>(() => responseTask);
  402. context.Dispose();
  403. }
  404. @@ -119,7 +119,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
  405. var context = await server.AcceptAsync(Utilities.DefaultTimeout);
  406. client.CancelPendingRequests();
  407. - await Assert.ThrowsAsync<TaskCanceledException>(() => responseTask);
  408. + await Assert.ThrowsAnyAsync<OperationCanceledException>(() => responseTask);
  409. var ct = context.DisconnectToken;
  410. Assert.True(ct.CanBeCanceled, "CanBeCanceled");
  411. diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/RequestBodyLimitTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/RequestBodyLimitTests.cs
  412. index ebc0fa9f988..ae203ceab1f 100644
  413. --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/RequestBodyLimitTests.cs
  414. +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/RequestBodyLimitTests.cs
  415. @@ -413,6 +413,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
  416. protected async override Task SerializeToStreamAsync(Stream stream, TransportContext context)
  417. {
  418. await stream.WriteAsync(new byte[10], 0, 10);
  419. + await stream.FlushAsync();
  420. Assert.True(await Block.WaitAsync(TimeSpan.FromSeconds(10)));
  421. await stream.WriteAsync(new byte[10], 0, 10);
  422. }
  423. diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/RequestBodyTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/RequestBodyTests.cs
  424. index 1b879201032..b7a18867d9c 100644
  425. --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/RequestBodyTests.cs
  426. +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/RequestBodyTests.cs
  427. @@ -232,7 +232,8 @@ namespace Microsoft.AspNetCore.Server.HttpSys
  428. protected async override Task SerializeToStreamAsync(Stream stream, TransportContext context)
  429. {
  430. await stream.WriteAsync(new byte[5], 0, 5);
  431. - await Block.WaitAsync();
  432. + await stream.FlushAsync();
  433. + Assert.True(await Block.WaitAsync(TimeSpan.FromSeconds(10)));
  434. await stream.WriteAsync(new byte[5], 0, 5);
  435. }