mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-17 04:32:15 +01:00
fix(pdfengines): read metadata better webhook error - fixes #1148
This commit is contained in:
@@ -407,11 +407,7 @@ func (s *scenario) theBodyShouldMatchString(kind string, expectedDoc *godog.DocS
|
||||
} else if s.server.req == nil {
|
||||
return errors.New("no webhook request found")
|
||||
} else {
|
||||
body, err := io.ReadAll(s.server.req.Body)
|
||||
if err != nil {
|
||||
return fmt.Errorf("read request body: %w", err)
|
||||
}
|
||||
actual = string(body)
|
||||
actual = string(s.server.bodyCopy)
|
||||
}
|
||||
|
||||
expected := strings.ReplaceAll(expectedDoc.Content, "{version}", GotenbergVersion)
|
||||
@@ -431,11 +427,7 @@ func (s *scenario) theBodyShouldContainString(kind string, expectedDoc *godog.Do
|
||||
} else if s.server.req == nil {
|
||||
return errors.New("no webhook request found")
|
||||
} else {
|
||||
body, err := io.ReadAll(s.server.req.Body)
|
||||
if err != nil {
|
||||
return fmt.Errorf("read request body: %w", err)
|
||||
}
|
||||
actual = string(body)
|
||||
actual = string(s.server.bodyCopy)
|
||||
}
|
||||
|
||||
expected := strings.ReplaceAll(expectedDoc.Content, "{version}", GotenbergVersion)
|
||||
@@ -455,11 +447,7 @@ func (s *scenario) theBodyShouldMatchJSON(kind string, expectedDoc *godog.DocStr
|
||||
} else if s.server.req == nil {
|
||||
return errors.New("no webhook request found")
|
||||
} else {
|
||||
b, err := io.ReadAll(s.server.req.Body)
|
||||
if err != nil {
|
||||
return fmt.Errorf("read request body: %w", err)
|
||||
}
|
||||
body = b
|
||||
body = s.server.bodyCopy
|
||||
}
|
||||
|
||||
var expected, actual interface{}
|
||||
|
||||
@@ -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)))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user