mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-18 21:22:15 +01:00
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 <neuhart.julien@gmail.com> * formatting --------- Co-authored-by: Julien Neuhart <neuhart.julien@gmail.com>
This commit is contained in:
@@ -239,12 +239,18 @@ func webhookMiddleware(w *Webhook) api.Middleware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
headers := map[string]string{
|
headers := map[string]string{
|
||||||
echo.HeaderContentDisposition: fmt.Sprintf("attachement; filename=%q", ctx.OutputFilename(outputPath)),
|
|
||||||
echo.HeaderContentType: http.DetectContentType(fileHeader),
|
echo.HeaderContentType: http.DetectContentType(fileHeader),
|
||||||
echo.HeaderContentLength: strconv.FormatInt(fileStat.Size(), 10),
|
echo.HeaderContentLength: strconv.FormatInt(fileStat.Size(), 10),
|
||||||
traceHeader: trace,
|
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.
|
// Send the output file to the webhook.
|
||||||
err = client.send(bufio.NewReader(outputFile), headers, false)
|
err = client.send(bufio.NewReader(outputFile), headers, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user