Skip to content

Name the 'not handled' ResponseNo sentinel HTTP_NOT_HANDLED - #568

Merged
michaelJustin merged 1 commit into
masterfrom
555-http-not-handled-constant
Oct 14, 2026
Merged

michaelJustin merged 1 commit into
masterfrom
555-http-not-handled-constant

Conversation

@michaelJustin

Copy link
Copy Markdown
Owner

Closes #555.

TdjHTTPConnector.OnCommand sets Response.ResponseNo := -1 before dispatching, and later handlers check for that value to detect a request no earlier handler answered. The -1 is a Daraja convention, not an Indy one, but the bare literal made it look like an Indy magic number.

Changes

  • djHTTPConstants: new documented constant HTTP_NOT_HANDLED = -1.
  • Used in all three places that rely on the value:
    • TdjHTTPConnector.OnCommand, which sets it, plus the comment in its exception handler. djHTTPConstants goes back into its uses clause, after Reset the response before sending a 500 after an exception #566 had removed it.
    • TdjDefaultHandler.Handle, which was ResponseNo = -1.
    • TdjHandlerList.Handle, which was ResponseNo > 0 / ResponseNo < 0. This one wasn't in the patch attached to the issue, though that patch's own doc comment named TdjHandlerList as a user. It now compares with the constant. That would only behave differently if ResponseNo were 0 or another negative value, which nothing sets.
  • ContentLength = -1 ("length unknown") is Indy's own convention, so it is left as it is.
  • CHANGELOG: Internal entry.

No behavior change.

Verification

Run locally before the rebase onto the merged #567, which touches none of these files:

  • FPC (run-fpc.cmd): 202 tests, 0 errors, 0 failures; heap trace at the clean baseline (6 blocks / 744 bytes).
  • Delphi 2009 (run-delphi.cmd): OK, 202 tests.

🤖 Generated with Claude Code

TdjHTTPConnector.OnCommand sets Response.ResponseNo to -1 before
dispatching, and later handlers check for it to detect a request no
earlier handler answered. The value is a Daraja convention, not an Indy
one, but the bare literal made it look like an Indy magic number.

Introduce HTTP_NOT_HANDLED in djHTTPConstants and use it in the
connector, TdjDefaultHandler and TdjHandlerList (which tested the same
sentinel as '> 0' / '< 0'). No behavior change.

Based on the patch attached to #555, rebased onto the #564 connector
change and extended to TdjHandlerList.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@michaelJustin michaelJustin added this to the 3.5.0 milestone Oct 14, 2026
@michaelJustin
michaelJustin merged commit 29029d2 into master Oct 14, 2026
2 checks passed
@michaelJustin
michaelJustin deleted the 555-http-not-handled-constant branch October 14, 2026 17:57
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.

Use a constant instead of -1

1 participant