feat: add addWebhookExtraHeaders to merge with existing webhook headers#263
Open
Jean-Beru wants to merge 1 commit intosensiolabs:1.xfrom
Open
feat: add addWebhookExtraHeaders to merge with existing webhook headers#263Jean-Beru wants to merge 1 commit intosensiolabs:1.xfrom
Jean-Beru wants to merge 1 commit intosensiolabs:1.xfrom
Conversation
Mirrors the existing extraHttpHeaders / addExtraHttpHeaders pair: when webhook headers are already defined (e.g. an Authorization header coming from bundle config), addWebhookExtraHeaders lets callers append per-request headers instead of replacing the whole set. Closes sensiolabs#248. Assisted-by: Claude:claude-opus-4-7
Neirda24
approved these changes
Apr 29, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Adds
addWebhookExtraHeaders(array $extraHttpHeaders): statictoWebhookTrait, mirroring the existingextraHttpHeaders()/addExtraHttpHeaders()pair (overwrite vs. merge).Use case: when webhook headers are already defined in bundle config (e.g. a static
Authorization), callers can now append per-request headers (e.g. a correlation id) without replacing the whole set. Today,webhookExtraHeaders()always overwrites, so any caller-provided values wipe the configured ones.The implementation reads the current
Gotenberg-Webhook-Extra-Http-Headersheader (stored as a JSON string in the headers bag),array_merges the new headers on top, and re-encodes by delegating towebhookExtraHeaders(). An empty array short-circuits as a no-op, matchingaddExtraHttpHeaders().All 13 builders that compose
WebhookTrait(10 PDF + 3 Screenshot) inherit the method via trait composition. Three test cases inWebhookTestCaseTrait(merge, empty no-op, no prior headers) are therefore exercised against every builder.Note on naming: the issue suggests
webhookAddExtraHeaders; this PR usesaddWebhookExtraHeadersinstead, to stay consistent with the existingextraHttpHeaders/addExtraHttpHeadersconvention. Happy to rename if you'd prefer the original spelling.