Context
Rust dispatcher currently reads full request body before route/method resolution in many paths. This increases cost for invalid endpoints/methods and enables cheap high-volume junk traffic to force unnecessary body buffering.
Current code
src/dispatch.rs reads protocol body first, then computes route outcome and 404/405 handling.
Goal
Move route/method match decision earlier so 404/405 can fail fast without reading full body.
Desired behavior
- For non-matching paths/methods: return 404/405 early, avoid body read.
- For matched routes: preserve existing body-read semantics and size checks.
Acceptance criteria
- Dispatcher computes 404/405 before body consumption when possible.
- No functional regression in current tests.
- Add/extend tests proving body is not consumed in 404/405 cases (or equivalent behavioral proof).
Notes
This is primarily performance + robustness hardening; no API change intended.
Context
Rust dispatcher currently reads full request body before route/method resolution in many paths. This increases cost for invalid endpoints/methods and enables cheap high-volume junk traffic to force unnecessary body buffering.
Current code
src/dispatch.rsreads protocol body first, then computes route outcome and 404/405 handling.Goal
Move route/method match decision earlier so 404/405 can fail fast without reading full body.
Desired behavior
Acceptance criteria
Notes
This is primarily performance + robustness hardening; no API change intended.