diff --git a/chromium.go b/chromium.go index 6c2b423..e8e2155 100644 --- a/chromium.go +++ b/chromium.go @@ -62,12 +62,24 @@ func (req *chromiumRequest) FailOnHTTPStatusCodes(statusCodes []byte) { req.fields[fieldChromiumFailOnHTTPStatusCodes] = string(statusCodes) } +// FailOnResourceHTTPStatusCodes forces Gotenberg to return a 409 Conflict response +// if the HTTP status code from at least one resource is not acceptable. +func (req *chromiumRequest) FailOnResourceHTTPStatusCodes(statusCodes []byte) { + req.fields[fieldChromiumFailOnResourceHTTPStatusCodes] = string(statusCodes) +} + // FailOnConsoleExceptions forces Gotenberg to return a 409 Conflict response // if there are exceptions in the Chromium console. func (req *chromiumRequest) FailOnConsoleExceptions() { req.fields[fieldChromiumFailOnConsoleExceptions] = strconv.FormatBool(true) } +// FailOnResourceLoadingFailed forces Gotenberg to return a 409 Conflict if Chromium +// fails to load at least one resource. +func (req *chromiumRequest) FailOnResourceLoadingFailed() { + req.fields[fieldChromiumFailOnResourceLoadingFailed] = strconv.FormatBool(true) +} + // SkipNetworkIdleEvent specifies whether Chromium have to wait or not for its network to be idle. // Enabled by default in Gotenberg >= 8.11.0. func (req *chromiumRequest) SkipNetworkIdleEvent() { diff --git a/fields.go b/fields.go index 1fe5f12..4155670 100644 --- a/fields.go +++ b/fields.go @@ -15,15 +15,17 @@ const ( // Chromium request configuration. const ( - fieldChromiumWaitDelay formField = "waitDelay" - fieldChromiumWaitForExpression formField = "waitForExpression" - fieldChromiumEmulatedMediaType formField = "emulatedMediaType" - fieldChromiumCookies formField = "cookies" - fieldChromiumUserAgent formField = "userAgent" - fieldChromiumExtraHTTPHeaders formField = "extraHttpHeaders" - fieldChromiumFailOnHTTPStatusCodes formField = "failOnHttpStatusCodes" - fieldChromiumFailOnConsoleExceptions formField = "failOnConsoleExceptions" - fieldChromiumSkipNetworkIdleEvent formField = "skipNetworkIdleEvent" + fieldChromiumWaitDelay formField = "waitDelay" + fieldChromiumWaitForExpression formField = "waitForExpression" + fieldChromiumEmulatedMediaType formField = "emulatedMediaType" + fieldChromiumCookies formField = "cookies" + fieldChromiumUserAgent formField = "userAgent" + fieldChromiumExtraHTTPHeaders formField = "extraHttpHeaders" + fieldChromiumFailOnHTTPStatusCodes formField = "failOnHttpStatusCodes" + fieldChromiumFailOnResourceHTTPStatusCodes formField = "failOnResourceHttpStatusCodes" + fieldChromiumFailOnConsoleExceptions formField = "failOnConsoleExceptions" + fieldChromiumFailOnResourceLoadingFailed formField = "failOnResourceLoadingFailed" + fieldChromiumSkipNetworkIdleEvent formField = "skipNetworkIdleEvent" ) // PDF page property. diff --git a/go.sum b/go.sum index 60ce688..8565daa 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=