Skip to content

Disallow synchronous IIS response flushes - #68763

Merged
halter73 merged 2 commits into
dotnet:mainfrom
halter73:halter73-iis-sync-flush-guard
Sep 1, 2026
Merged

halter73 merged 2 commits into
dotnet:mainfrom
halter73:halter73-iis-sync-flush-guard

Conversation

@halter73

@halter73 halter73 commented Aug 25, 2026 •

Copy link
Copy Markdown
Member

Disallow synchronous IIS response flushes

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Honor AllowSynchronousIO when flushing IIS responses

Description

IIS HttpResponseStream.Flush() did not check IHttpBodyControlFeature.AllowSynchronousIO, even though synchronous writes do and the behavior described in #7644 includes Stream.Flush.

This adds the same guard used by Write(), preserving FlushAsync() and explicit per-request opt-in behavior. HttpUpgradeStream.Flush() delegates to HttpResponseStream.Flush(), so upgraded connections inherit the check without a duplicate guard. Stream-level regression tests cover both direct and upgraded response streams, and IIS in-process tests cover the default disallowed setting and opt-in behavior.

Related to #7644

Copilot AI lite review requested due to automatic review settings August 25, 2026 02:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request updates IIS in-process response flushing to honor IHttpBodyControlFeature.AllowSynchronousIO, bringing Stream.Flush() in line with existing synchronous write behavior and the repo’s “sync IO disabled by default” policy.

Changes:

  • Add an AllowSynchronousIO guard to HttpResponseStream.Flush() while keeping FlushAsync() behavior unchanged.
  • Add a new stream-level regression test covering sync flush when disallowed.
  • Extend IIS in-process tests to cover sync flush both when disallowed by default and when explicitly enabled per-request.
Show a summary per file
File Description
src/Servers/IIS/IIS/src/Core/HttpResponseStream.cs Adds the AllowSynchronousIO check to Flush() before executing the synchronous flush path.
src/Servers/IIS/IIS/test/IIS.Tests/HttpResponseStreamTests.cs Introduces a regression test asserting Flush() throws when sync IO is disabled.
src/Servers/IIS/IIS/test/IIS.Tests/HttpBodyControlFeatureTests.cs Expands IIS in-process coverage to validate sync Flush() is blocked by default and permitted when opted in.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

@halter73
halter73 enabled auto-merge (squash) August 28, 2026 19:55
@halter73
halter73 merged commit eb23a80 into dotnet:main Sep 1, 2026
28 of 29 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants