]> git.ipfire.org Git - thirdparty/rspamd.git/commit
[Feature] protocol: Expose custom metadata for /checkv3 6074/head
authorVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 2 Jun 2026 18:04:34 +0000 (19:04 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 2 Jun 2026 18:09:26 +0000 (19:09 +0100)
commitecd173f5a4806b10bb64bb107d37daad4769ba8b
treec792fdb0b765d3dc711102b3d0edcce59b4d845f
parent398691f5e3795428d61693592f574b2130a12736
[Feature] protocol: Expose custom metadata for /checkv3

Add two complementary ways to read custom fields sent with a /checkv3
multipart scan request, both free of the 80KB HTTP header limit that v2
hits, since the metadata travels in the multipart body:

  * A "headers" sub-object in the metadata part is injected into the
    task request headers, so task:get_request_header() works for custom
    fields exactly like v2 HTTP request headers. Reserved control-header
    names (shm/file/path/dictionary/Content-Encoding...) are skipped so
    client metadata cannot collide with the message-loading channel, and
    a repeated name (collapsed by UCL into an array) expands to a
    multi-valued request header.

  * The parsed metadata object is kept on task->meta and exposed to Lua
    via task:get_metadata() and task:get_metadata_field(key), mirroring
    get_settings()/lookup_settings(). The task now owns the object and
    frees it once in rspamd_task_free instead of via a pool destructor.

rspamc gains a repeatable --metadata-header KEY=VALUE option that builds
the metadata "headers" sub-object for v3 requests. Also drop a dead
is_msgpack variable in the v3 request handler.

Tests: functional cases in 430_checkv3.robot plus a checkv3_meta.lua
plugin exercising both options via raw multipart and rspamc.
src/client/rspamc.cxx
src/libserver/protocol.c
src/libserver/task.c
src/libserver/task.h
src/lua/lua_task.c
test/functional/cases/001_merged/430_checkv3.robot
test/functional/configs/merged.conf
test/functional/lua/checkv3_meta.lua [new file with mode: 0644]