From 10588efe259dd7492d92588bf21e0fdd7f82cb85 Mon Sep 17 00:00:00 2001 From: stephentgrammer <36522622+stephentgrammer@users.noreply.github.com> Date: Thu, 3 Apr 2025 18:04:14 -0700 Subject: [PATCH] fix(webhook): content-disposition header (#1164) * fix(webhook): pass content-disposition header through and fix spelling of attachment on default * code review Co-authored-by: Julien Neuhart * formatting --------- Co-authored-by: Julien Neuhart --- pkg/modules/webhook/middleware.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/modules/webhook/middleware.go b/pkg/modules/webhook/middleware.go index 63150cce..aa6ac125 100644 --- a/pkg/modules/webhook/middleware.go +++ b/pkg/modules/webhook/middleware.go @@ -239,10 +239,16 @@ func webhookMiddleware(w *Webhook) api.Middleware { } headers := map[string]string{ - echo.HeaderContentDisposition: fmt.Sprintf("attachement; filename=%q", ctx.OutputFilename(outputPath)), - echo.HeaderContentType: http.DetectContentType(fileHeader), - echo.HeaderContentLength: strconv.FormatInt(fileStat.Size(), 10), - traceHeader: trace, + echo.HeaderContentType: http.DetectContentType(fileHeader), + echo.HeaderContentLength: strconv.FormatInt(fileStat.Size(), 10), + traceHeader: trace, + } + + // Allow for custom Content-Disposition header. + // See https://github.com/gotenberg/gotenberg/issues/1165. + _, ok := extraHttpHeaders[echo.HeaderContentDisposition] + if !ok { + headers[echo.HeaderContentDisposition] = fmt.Sprintf("attachment; filename=%q", ctx.OutputFilename(outputPath)) } // Send the output file to the webhook.