Skip to content

Improve Captcha Post Error Handling - #39

Merged
rswalkden merged 2 commits into
masterfrom
captcha-post-error-handling
Nov 5, 2026
Merged

rswalkden merged 2 commits into
masterfrom
captcha-post-error-handling

Conversation

@rswalkden

@rswalkden rswalkden commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes response handling when captcha validation fails, and adds protector API status and latency to ingest records.

Changes

Captcha validation (handleCaptcha)

  • The response status is now set before the body is written. Previously the headers went out as 200 first, and nginx logged attempt to set status ... via ngx.exit after sending out the response status 200.
  • When the protector API call fails (timeout, connection error), the client now gets a 502 instead of an unhandled Lua error.
  • Protector 2xx and 4xx responses are passed through with their Content-Type. Any other status returns a generic 502.

Ingest

  • Added ProtectorStatus: the HTTP status returned by the protector API, or 0 if no response was received. The field is omitted when no protector call was made.
  • Added ProtectorLatencyMs: how long the protector API call took, in milliseconds.
  • BytesReceived now uses $request_length and is always a number. It was always 0 before, because $bytes_received only exists in nginx's stream module.

@rswalkden
rswalkden requested a review from a team as a code owner October 28, 2026 17:23
@rswalkden
rswalkden merged commit 11891f2 into master Nov 5, 2026
3 checks passed
@rswalkden
rswalkden deleted the captcha-post-error-handling branch November 5, 2026 09:25
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.

2 participants