Skip to content

Add WSGI tests for missing input and invalid content length #177

Description

@DevilsAutumn

Problem

The WSGI adapter has a few small branches that are important but not directly covered by tests yet.

Current tests cover normal request body reads, negative CONTENT_LENGTH, body limits, missing CONTENT_LENGTH, path decoding, event-loop calls, and response finalizers:

But these two WSGI adapter paths are still easy to miss:

  • missing wsgi.input returns an empty body: adapter code
  • invalid non-numeric CONTENT_LENGTH is treated as invalid by the request safety layer before the body is read: adapter code

This is small test coverage work, but it protects compatibility behavior for WSGI deployments.

Proposed behavior

Add focused tests in tests/integration/test_wsgi_adapter.py:

  • when wsgi.input is missing, a handler that reads the body should receive b"";
  • when CONTENT_LENGTH is invalid, the response should be 400 Bad Request with Invalid Content-Length header, and the input stream should not be read.

Keep the tests narrow. No runtime behavior change is expected unless the tests reveal a bug.

Alternatives considered

We could leave this to broader adapter tests, but these branches are small and easy to assert directly.

API sketch

# No public API change.

Working on this?

Please wait until a maintainer marks the issue accepted. After that, comment before starting and make sure nobody else is assigned or already working on it.

Metadata

Metadata

Labels

acceptedMaintainer accepted this issue for contributionenhancementNew feature or requestgood first issueGood for newcomers

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions