Harden operator-set target headers (closes #233) (#242)
All checks were successful
check / check (push) Successful in 2m58s

This commit was merged in pull request #242.
This commit is contained in:
2026-08-20 10:54:43 +02:00
parent 03cd1859d7
commit 687405993e
9 changed files with 746 additions and 62 deletions

View File

@@ -6,6 +6,7 @@ import (
"net"
"net/http"
"net/netip"
"net/url"
"time"
"go.uber.org/fx"
@@ -70,13 +71,14 @@ func ExportIsForwardableHeader(name string) bool {
}
// ExportApplyRequestHeaders exposes applyRequestHeaders, so a test
// can inspect the header set an outbound delivery actually carries.
// can inspect the header set an outbound delivery actually carries
// and the origin-scoped names it reports for the redirect policy.
func ExportApplyRequestHeaders(
req *http.Request,
event *database.Event,
cfg *HTTPTargetConfig,
) {
applyRequestHeaders(req, event, cfg)
) []string {
return applyRequestHeaders(req, event, cfg)
}
// ExportTruncate exposes truncate for testing.
@@ -186,12 +188,27 @@ func (e *Engine) ExportDoHTTPRequest(
return e.httpTarget.doHTTPRequest(ctx, cfg, event)
}
// ExportClientForConfig exposes the http target's
// clientForConfig.
func (e *Engine) ExportClientForConfig(
// ExportClientForRequest exposes the http target's
// clientForRequest.
func (e *Engine) ExportClientForRequest(
cfg *HTTPTargetConfig,
originScoped []string,
) *http.Client {
return e.httpTarget.clientForConfig(cfg)
return e.httpTarget.clientForRequest(cfg, originScoped)
}
// ErrExportTooManyRedirects exposes the sentinel the redirect
// policy returns once a chain exceeds the hop cap. It carries the
// Err prefix rather than this file's usual Export one because it
// is a sentinel error.
var ErrExportTooManyRedirects = errTooManyRedirects
// ExportMaxDeliveryRedirects exposes the redirect hop cap.
const ExportMaxDeliveryRedirects = maxDeliveryRedirects
// ExportSameDeliveryOrigin exposes sameDeliveryOrigin.
func ExportSameDeliveryOrigin(origin, dest *url.URL) bool {
return sameDeliveryOrigin(origin, dest)
}
// ExportClient returns the http target's shared HTTP client.