fix(pdfengines): read metadata better webhook error - fixes #1148

This commit is contained in:
Julien Neuhart
2025-05-15 09:22:52 +02:00
parent 66317197b6
commit 9aaab97d6a
5 changed files with 48 additions and 24 deletions

View File

@@ -19,9 +19,10 @@ import (
)
type server struct {
srv *echo.Echo
req *http.Request
errChan chan error
srv *echo.Echo
req *http.Request
bodyCopy []byte
errChan chan error
}
func newServer(ctx context.Context, workdir string) (*server, error) {
@@ -51,6 +52,8 @@ func newServer(ctx context.Context, workdir string) (*server, error) {
return webhookErr(fmt.Errorf("read request body: %w", err))
}
s.bodyCopy = body
cd := s.req.Header.Get("Content-Disposition")
if cd == "" {
return webhookErr(fmt.Errorf("no Content-Disposition header"))
@@ -125,6 +128,11 @@ func newServer(ctx context.Context, workdir string) (*server, error) {
}
webhookErrorHandler := func(c echo.Context) error {
s.req = c.Request()
body, err := io.ReadAll(s.req.Body)
if err != nil {
return webhookErr(fmt.Errorf("read request body: %w", err))
}
s.bodyCopy = body
return webhookErr(c.String(http.StatusOK, http.StatusText(http.StatusOK)))
}