Skip to content

Cloudflare adapter: add native test coverage for the wasm-only HTTP client (redirect/cap/header logic) #829

Description

@prk-Jr

Description

Follow-up from PR #643 review (inline comment).

The wasm32-only CloudflareHttpClient (execute/select, redirect handling, response-body cap, and hop-by-hop header stripping) has no test target — CI only cargo checks it for wasm32-unknown-unknown, never exercises it. This is how the round-7 redirect-follow SSRF bug went unverified.

Not blocking for PR #643 (the logic is now reviewed and the fixes are in), but this path needs real coverage.

What to do

  • Extract the redirect, body-cap, and header-stripping logic out of the wasm-only CloudflareHttpClient into native-testable free functions, as the Axum and Fastly adapters already do for their HTTP clients.
  • Add native unit tests exercising:
    • manual redirect handling / per-hop allowlist behavior (no auto-follow),
    • the 10 MiB response-body cap (Content-Length pre-check + post-buffer check),
    • hop-by-hop header stripping (is_hop_by_hop_response_header + Connection-token list).

Done when

  • Redirect / cap / header-stripping logic lives in native-testable free functions.
  • Native unit tests cover redirect, body-cap, and header-stripping behavior.
  • Tests run in CI on a native target (not only cargo check on wasm).

Affected area

Cloudflare runtime / CI / Tooling

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions