Skip to content

Fix HTTPConnection.communicate() to pass server proxy and strict mode settings#831

Open
andrewkernel wants to merge 1 commit into
cherrypy:mainfrom
andrewkernel:fix-unservicable-request-flags
Open

Fix HTTPConnection.communicate() to pass server proxy and strict mode settings#831
andrewkernel wants to merge 1 commit into
cherrypy:mainfrom
andrewkernel:fix-unservicable-request-flags

Conversation

@andrewkernel

@andrewkernel andrewkernel commented Jun 27, 2026

Copy link
Copy Markdown

What kind of change does this PR introduce?

  • 🐞 bug fix
  • 🐣 feature
  • 📋 docs update
  • 📋 tests/coverage improvement
  • 📋 refactoring
  • 💥 other

📋 What is the related issue number (starting with #)

Resolves #823.

What is the current behavior? (You can also link to an open issue here)

HTTPConnection.communicate() initialized request handlers with default proxy_mode and strict_mode values instead of the server's configured values.

What is the new behavior (if this is a feature change)?

HTTPConnection.communicate() now passes proxy_mode=self.server.proxy_mode and strict_mode=self.server.strict_mode when constructing the request handler.

📋 Other information:

Added docs/changelog-fragments.d/831.bugfix.rst.

Testing:

  • .venv\Scripts\python.exe -m pytest --no-cov -n 0 cheroot/test/test_server.py -k communicate_uses_server_proxy_and_strict_mode

📋 Contribution checklist:

  • I wrote descriptive pull request text above
  • I think the code is well written
  • I wrote good commit messages
  • I have squashed related commits together after the changes have been approved
  • Unit tests for the changes exist
  • Integration tests for the changes exist (if applicable)
  • I used the same coding conventions as the rest of the project
  • The new code doesn't generate linter offenses
  • Documentation reflects the changes
  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences

@read-the-docs-community

read-the-docs-community Bot commented Jun 27, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cheroot | 🛠️ Build #33486629 | 📁 Comparing d258498 against latest (3937fe1)

  🔍 Preview build  

6 files changed · ± 6 modified

± Modified

@codecov

codecov Bot commented Jun 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.74%. Comparing base (3937fe1) to head (d258498).

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #831       +/-   ##
===========================================
- Coverage   78.19%   54.74%   -23.46%     
===========================================
  Files          41       12       -29     
  Lines        4788      411     -4377     
  Branches      547        1      -546     
===========================================
- Hits         3744      225     -3519     
+ Misses        905      186      -719     
+ Partials      139        0      -139     

@julianz- julianz- self-assigned this Jul 1, 2026
@julianz-

julianz- commented Jul 1, 2026

Copy link
Copy Markdown
Member

This PR addresses an inconsistency in _serve_unservicable but the real issue from #823 is in communicate() at line 1309, where RequestHandlerClass is always initialized with default proxy_mode and strict_mode. The fix should be to pass proxy_mode=self.server.proxy_mode, strict_mode=self.server.strict_mode there instead.

@andrewkernel andrewkernel force-pushed the fix-unservicable-request-flags branch from a433c69 to d258498 Compare July 7, 2026 21:58
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided A mark meaning that a new change log entry is present within the patch. label Jul 7, 2026
Pass the server proxy and strict mode settings into HTTP request parsing from HTTPConnection.communicate. This preserves the configured request handling flags for accepted connections and covers the constructor arguments with a focused regression test.
@julianz- julianz- changed the title Fix 503 request flags in unservicable connections Fix HTTPConnection.communicate() to pass server proxy and strict mode settings Jul 7, 2026
@julianz-

julianz- commented Jul 7, 2026

Copy link
Copy Markdown
Member

I updated the title of this PR as your original one no longer applied. You need to update your commit message similarly and also ensure the body is line-wrapped at ~72 characters - there is a linter error about this currently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided A mark meaning that a new change log entry is present within the patch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTPConnection not passing proxy_mode and strict_mode to HTTPRequest __init__

2 participants