logging: log_append Early option, Supports {http.response.body}
#7368
+84
−6
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.
Related to #7367, I wanted some more conveniences for logging request/response bodies.
Adding a
<prefix to thelog_appendkey to enable theEarlyoption; makeslog_appendpull the value and add to the log on the way in (default is doing it on the way out, after the terminal response handler ran). This is necessary to be able to use{http.request.body}because it has to apply the request body buffer before it callsreverse_proxyor whatever.Adding a special case to
log_appendto allow buffering and logging the response body. This isn't implemented as an actual placeholder because placeholders aren't able to replacewsince the placeholder-replacer is created at the start of the request and it would be impossible to replace w in a callback and affect the callback chain. Also added a{http.response.body_base64}for the same reason as in caddyhttp:{http.request.body_base64}placeholder #7367, e.g. when the body is binary or whatever.Caddyfile for testing:
Test:
Log ends up with:
Assistance Disclosure
Used Github Copilot (Sonnet 4.5, GPT-5)