Turn demo_api into a full showcase of the HTTP engine, fix bugs found… - #56
Merged
Conversation
… along the way
demo_api now demonstrates every HTTP engine capability (http_version, custom
reason phrases, etags/conditional GET, deploy-time vars, form parsing,
per-request templating, static files, error/unknown-method handling) so it
can serve as the reference config for writing new skins.
Building it surfaced three real bugs in trapster/modules/http.py:
- .j2 was missing from the Jinja-renderable suffix list, so every .j2
template (including the pre-existing settings.j2/user.j2) was served as
raw, unrendered source instead of being executed.
- per-request templates' etag()/deploy_seed globals silently used an empty
seed instead of the real deploy-time one.
- the custom reason-phrase mechanism only worked for non-standard HTTP
methods; standard methods run through FastAPI's @app.middleware("http"),
which executes the endpoint in a separate task via Starlette's
BaseHTTPMiddleware, breaking the contextvar it relied on. Replaced with
the ASGI scope "state" extension, which survives that task split.
Also updated the README to document demo_api's purpose, and added a
disclaimer (collapsed by default) that AI-generated responses are
fingerprintable and meant for CTI research, not intrusion detection.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
demo_api now demonstrates every HTTP engine capability (http_version, custom reason phrases, etags/conditional GET, deploy-time vars, form parsing, per-request templating, static files, error/unknown-method handling) so it can serve as the reference config for writing new skins.
Building it surfaced three real bugs in trapster/modules/http.py:
Also updated the README to document demo_api's purpose, and added a disclaimer (collapsed by default) that AI-generated responses are fingerprintable and meant for CTI research, not intrusion detection.