Skip to content

perf(dispatch): route/method decision before full body read for 404/405 fast-fail #71

Description

@ZhuchkaTriplesix

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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions