Skip to content

fix: commit response status before flushing - #3184

Draft
Plastic-time wants to merge 2 commits into
labstack:masterfrom
Plastic-time:fix/commit-status-before-flush
Draft

Plastic-time wants to merge 2 commits into
labstack:masterfrom
Plastic-time:fix/commit-status-before-flush

Conversation

@Plastic-time

Copy link
Copy Markdown

Problem

Flushing an Echo response before writing its body commits the underlying HTTP headers, but leaves Echo's Committed flag false and skips Before callbacks. A staged status such as 202 also becomes 200 on the wire. The delayed status writer has the same discrepancy.

Commit the configured status (defaulting to 200) before delegating Flush in both writers. This makes subsequent writes observe the already committed response and runs Before hooks exactly once.

Validation

Go 1.27.3 on Windows:

  • Four regression subtests failed before the implementation change (default/custom statuses for both writers).
  • go test -race ./... passed, including middleware and echotest.
  • go vet ./... passed.
  • go run honnef.co/go/tools/cmd/staticcheck@latest ./... passed.
  • go run golang.org/x/lint/golint@latest -set_exit_status ./... passed.
  • gofmt and git diff --check passed.

Tests also cover headers added by Before hooks, repeated Flush calls, and a body write after flushing. No new public API or dependencies.

AI assistance

Codex (GPT-6) assisted with investigation, implementation, tests, and this description. Submitted as a draft for human review.

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