Skip to content

Add InvalidChunkExtension mapping and fast parser support for ASGI tests#3565

Merged
benoitc merged 3 commits into
masterfrom
add-invalid-chunk-extension-mapping
Mar 31, 2026
Merged

Add InvalidChunkExtension mapping and fast parser support for ASGI tests#3565
benoitc merged 3 commits into
masterfrom
add-invalid-chunk-extension-mapping

Conversation

@benoitc

@benoitc benoitc commented Mar 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add InvalidChunkExtension to treq_asgi.py imports and EXCEPTION_MAP for proper test coverage of bare CR rejection in chunk extensions per RFC 9112 Section 7.1.1
  • Add fast parser (H1CProtocol) support to ASGI invalid request tests, matching the WSGI test infrastructure
  • Handle gunicorn_h1c limit exceptions (LimitRequestLine, LimitRequestHeaders) in ASGI protocol with appropriate HTTP status codes

Changes

tests/treq_asgi.py:

  • Add InvalidChunkExtension import and mapping
  • Add get_parser_class() to support both Python and fast parsers
  • Update map_exception() to handle gunicorn_h1c exceptions
  • Update badrequest.check() to accept http_parser parameter

tests/test_asgi_invalid_requests.py:

  • Add http_parser fixture to test both parsers
  • Add skip conditions for tests with different validation behavior

gunicorn/asgi/protocol.py:

  • Store gunicorn_h1c limit exception classes during initialization
  • Handle LimitRequestLine (414) and LimitRequestHeaders (431) from fast parser

benoitc added 3 commits March 28, 2026 15:46
- Add InvalidChunkExtension import and exception mapping for proper test
  coverage of bare CR rejection in chunk extensions per RFC 9112 7.1.1
- Add fast parser (H1CProtocol) support to treq_asgi.py and the ASGI
  invalid request tests
- Fast parser now receives limit configuration (limit_request_line,
  limit_request_fields, limit_request_field_size)
- Handle gunicorn_h1c's multiple ParseError classes from different modules
- Skip tests where fast parser has different validation than Python parser
Add handling for gunicorn_h1c.LimitRequestLine and
gunicorn_h1c.LimitRequestHeaders exceptions, matching the behavior
of the Python parser exceptions with appropriate HTTP status codes:
- LimitRequestLine: 414 URI Too Long
- LimitRequestHeaders: 431 Request Header Fields Too Large
@benoitc benoitc merged commit 3e2167c into master Mar 31, 2026
24 checks passed
@benoitc benoitc deleted the add-invalid-chunk-extension-mapping branch March 31, 2026 01:08
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.

1 participant