Send the build version in the outbound User-Agent (closes #313)
check / check (push) Successful in 3m13s

The http and slack targets sent the fixed User-Agent webhooker/1.0. The
delivery engine now takes the version from Globals, the value the web UI
footer shows, and one method builds webhooker/<version> for both
targets. The http target still sets it after the configured headers, so
a configured or inbound User-Agent never reaches the wire.

A test builds the engine through its real constructor with a known
version and checks the header each target sends.

Model: opus-5-5
This commit is contained in:
2026-10-02 07:15:38 +00:00
parent eb4c4cc849
commit d13e7e885c
7 changed files with 117 additions and 9 deletions
+7 -2
View File
@@ -442,7 +442,9 @@ func (t *httpTarget) doHTTPRequest(
)
}
originScoped := applyRequestHeaders(req, event, cfg)
originScoped := applyRequestHeaders(
req, event, cfg, t.eng.userAgent(),
)
client := t.clientForRequest(cfg, originScoped)
@@ -562,10 +564,13 @@ func isForwardableHeader(name string) bool {
// Content-Type goes out once: a Content-Type configured on the target
// wins, otherwise the event's ContentType, otherwise none. The inbound
// Content-Type in the event's headers is never forwarded.
//
// userAgent is set last, over any configured or inbound User-Agent.
func applyRequestHeaders(
req *http.Request,
event *database.Event,
cfg *HTTPTargetConfig,
userAgent string,
) []string {
if event.ContentType != "" {
req.Header.Set(
@@ -580,7 +585,7 @@ func applyRequestHeaders(
originScoped[http.CanonicalHeaderKey(k)] = struct{}{}
}
req.Header.Set("User-Agent", "webhooker/1.0")
req.Header.Set("User-Agent", userAgent)
// A Content-Type configured on the target describes the body
// being sent rather than the sender. A 307/308 preserves the