Skip to content

Use strict detection of http line ending for docker response#40932

Open
yao-msft wants to merge 4 commits into
masterfrom
user/yaosun/strictcrlf
Open

Use strict detection of http line ending for docker response#40932
yao-msft wants to merge 4 commits into
masterfrom
user/yaosun/strictcrlf

Conversation

@yao-msft

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

Follow up pr for #40849 (comment)

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

New unit test and existing tests

Copilot AI review requested due to automatic review settings June 26, 2026 22:53

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 PR tightens Docker HTTP response header termination detection by switching from a loose \n-count heuristic to an explicit \r\n\r\n state machine, and adds a unit test to lock the behavior in.

Changes:

  • Introduces HttpHeaderEndDetector, a byte-at-a-time detector for the HTTP header terminator (\r\n\r\n).
  • Updates DockerHTTPClient header scanning to use the detector for strict end-of-header detection.
  • Adds a unit test validating strictness and a few edge cases around the terminator.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
test/windows/WSLCTests.cpp Adds unit coverage for strict \r\n\r\n header end detection behavior.
src/windows/wslcsession/DockerHTTPClient.h Replaces the old linefeed counter state with HttpHeaderEndDetector.
src/windows/wslcsession/DockerHTTPClient.cpp Uses HttpHeaderEndDetector in both streaming header parsing and MSG_PEEK-based header scanning.
src/windows/common/HttpHeaderEndDetector.h Adds a small state machine utility for strict \r\n\r\n detection.

Comment thread src/windows/common/HttpHeaderEndDetector.h Outdated
@yao-msft yao-msft marked this pull request as ready for review June 27, 2026 04:32
@yao-msft yao-msft requested a review from a team as a code owner June 27, 2026 04:32
Copilot AI review requested due to automatic review settings June 27, 2026 04:32

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment on lines +1 to +15
/*++

Copyright (c) Microsoft. All rights reserved.

Module Name:

HttpHeaderEndDetector.h

Abstract:

This file contains a small state machine that detects the end-of-header
marker ("\r\n\r\n") in an HTTP message, one byte at a time.

--*/

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.

2 participants