Skip to content

Allow custom responses for malformed request headers - #1004

Open
pederbe wants to merge 1 commit into
cloudflare:mainfrom
pederbe:learn/pingora-919-request-error-response
Open

Allow custom responses for malformed request headers#1004
pederbe wants to merge 1 commit into
cloudflare:mainfrom
pederbe:learn/pingora-919-request-error-response

Conversation

@pederbe

@pederbe pederbe commented Sep 10, 2026

Copy link
Copy Markdown

Summary

Malformed HTTP/1 request headers receive a fixed 400 response before the normal proxy session and request context are created. Add ProxyHttp::request_error_filter so applications can log the rejection and send their own response headers and body, or close silently.

The default callback preserves the existing 400 response. Rejected connections still close, including when a custom callback returns an error, and do not enter normal request processing.

Fixes #919.

Testing

  • cargo test --locked -p pingora-proxy --lib: 66 passed, including 8 new tests.
  • cargo test --locked -p pingora-proxy --doc: 1 passed; 2 existing examples ignored.
  • cargo check --locked --workspace
  • cargo fmt --all -- --check
  • cargo clippy --locked -p pingora-proxy --all-targets -- --allow=unknown-lints --deny=warnings

The new tests cover custom responses, unchanged defaults, callback errors, HEAD body suppression, pipelined input after rejection, and requests that must bypass the callback.

@pederbe
pederbe marked this pull request as ready for review September 10, 2026 07:36
@pederbe

pederbe commented Sep 10, 2026

Copy link
Copy Markdown
Author

The nightly job failed in the existing test_backends test while checking 1.0.0.1:80, which has a one-second connection timeout. This looks like a transient network failure: the same test passed on Rust 1.97.1, and all 66 proxy tests passed on nightly.

Could someone with permission please rerun the failed job?

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.

Malformed HTTP requests bypass ProxyHttp layer, preventing custom error handling and logging

1 participant