diff --git a/docs/pdf/builders_api/HtmlPdfBuilder.md b/docs/pdf/builders_api/HtmlPdfBuilder.md
index b9f22407..1f28676c 100644
--- a/docs/pdf/builders_api/HtmlPdfBuilder.md
+++ b/docs/pdf/builders_api/HtmlPdfBuilder.md
@@ -109,6 +109,14 @@ document. (default None).
Return a 409 Conflict response if the HTTP status code from
the main page is not acceptable. (default [499,599]). (overrides any previous configuration).
+* `failOnResourceHttpStatusCodes(array $statusCodes)`:
+Return a 409 Conflict response if the HTTP status code from at least one resource is not acceptable.
+(default None). (overrides any previous configuration).
+
+* `failOnResourceLoadingFailed(bool $bool)`:
+Forces GotenbergScreenshot to return a 409 Conflict response if there are
+exceptions load at least one resource. (default false).
+
* `failOnConsoleExceptions(bool $bool)`:
Forces GotenbergPdf to return a 409 Conflict response if there are
exceptions in the Chromium console. (default false).
diff --git a/docs/pdf/builders_api/MarkdownPdfBuilder.md b/docs/pdf/builders_api/MarkdownPdfBuilder.md
index ce31f9c8..d9122180 100644
--- a/docs/pdf/builders_api/MarkdownPdfBuilder.md
+++ b/docs/pdf/builders_api/MarkdownPdfBuilder.md
@@ -112,6 +112,14 @@ document. (default None).
Return a 409 Conflict response if the HTTP status code from
the main page is not acceptable. (default [499,599]). (overrides any previous configuration).
+* `failOnResourceHttpStatusCodes(array $statusCodes)`:
+Return a 409 Conflict response if the HTTP status code from at least one resource is not acceptable.
+(default None). (overrides any previous configuration).
+
+* `failOnResourceLoadingFailed(bool $bool)`:
+Forces GotenbergScreenshot to return a 409 Conflict response if there are
+exceptions load at least one resource. (default false).
+
* `failOnConsoleExceptions(bool $bool)`:
Forces GotenbergPdf to return a 409 Conflict response if there are
exceptions in the Chromium console. (default false).
diff --git a/docs/pdf/builders_api/UrlPdfBuilder.md b/docs/pdf/builders_api/UrlPdfBuilder.md
index 22219eea..5d121319 100644
--- a/docs/pdf/builders_api/UrlPdfBuilder.md
+++ b/docs/pdf/builders_api/UrlPdfBuilder.md
@@ -111,6 +111,14 @@ document. (default None).
Return a 409 Conflict response if the HTTP status code from
the main page is not acceptable. (default [499,599]). (overrides any previous configuration).
+* `failOnResourceHttpStatusCodes(array $statusCodes)`:
+Return a 409 Conflict response if the HTTP status code from at least one resource is not acceptable.
+(default None). (overrides any previous configuration).
+
+* `failOnResourceLoadingFailed(bool $bool)`:
+Forces GotenbergScreenshot to return a 409 Conflict response if there are
+exceptions load at least one resource. (default false).
+
* `failOnConsoleExceptions(bool $bool)`:
Forces GotenbergPdf to return a 409 Conflict response if there are
exceptions in the Chromium console. (default false).
diff --git a/docs/pdf/customization.md b/docs/pdf/customization.md
index 479492d7..d0341b58 100644
--- a/docs/pdf/customization.md
+++ b/docs/pdf/customization.md
@@ -44,6 +44,8 @@
[extraHttpHeaders](#extraHttpHeaders)
[addExtraHttpHeaders](#addExtraHttpHeaders)
[failOnHttpStatusCodes](#failOnHttpStatusCodes)
+[failOnResourceHttpStatusCodes](#failOnResourceHttpStatusCodes)
+[failOnResourceLoadingFailed](#failOnResourceLoadingFailed)
[failOnConsoleExceptions](#failOnConsoleExceptions)
[skipNetworkIdleEvent](#skipNetworkIdleEvent)
@@ -896,6 +898,70 @@ class YourController
> [!TIP]
> For more information go to [Gotenberg documentations](https://gotenberg.dev/docs/routes#invalid-http-status-codes-chromium).
+### failOnResourceHttpStatusCodes
+
+default: `None`
+
+Return a 409 Conflict response if the HTTP status code from at least one resource
+is not acceptable.
+
+```php
+namespace App\Controller;
+
+use Sensiolabs\GotenbergBundle\GotenbergPdfInterface;
+
+class YourController
+{
+ public function yourControllerMethod(GotenbergPdfInterface $gotenberg): Response
+ {
+ return $gotenberg
+ ->html()
+ ->content('content.html.twig', [
+ 'my_var' => 'value'
+ ])
+ ->failOnResourceHttpStatusCodes([401, 403])
+ ->generate()
+ ->stream()
+ ;
+ }
+}
+```
+
+> [!TIP]
+> For more information go to [Gotenberg documentations](https://gotenberg.dev/docs/routes#invalid-http-status-codes-chromium).
+
+### failOnResourceLoadingFailed
+
+default: `false`
+
+Return a 409 Conflict response if there are exceptions to load at least one resource
+in the Chromium.
+
+```php
+namespace App\Controller;
+
+use Sensiolabs\GotenbergBundle\GotenbergPdfInterface;
+
+class YourController
+{
+ public function yourControllerMethod(GotenbergPdfInterface $gotenberg): Response
+ {
+ return $gotenberg
+ ->html()
+ ->content('content.html.twig', [
+ 'my_var' => 'value'
+ ])
+ ->failOnResourceLoadingFailed()
+ ->generate()
+ ->stream()
+ ;
+ }
+}
+```
+
+> [!TIP]
+> For more information go to [Gotenberg documentations](https://gotenberg.dev/docs/routes#network-errors-chromium).
+
### failOnConsoleExceptions
default: `false`
diff --git a/docs/screenshot/builders_api/HtmlScreenshotBuilder.md b/docs/screenshot/builders_api/HtmlScreenshotBuilder.md
index 8a87f455..c28cb55a 100644
--- a/docs/screenshot/builders_api/HtmlScreenshotBuilder.md
+++ b/docs/screenshot/builders_api/HtmlScreenshotBuilder.md
@@ -60,6 +60,14 @@ document. (default None).
Return a 409 Conflict response if the HTTP status code from
the main page is not acceptable. (default [499,599]). (overrides any previous configuration).
+* `failOnResourceHttpStatusCodes(array $statusCodes)`:
+Return a 409 Conflict response if the HTTP status code from at least one resource is not acceptable.
+(default None). (overrides any previous configuration).
+
+* `failOnResourceLoadingFailed(bool $bool)`:
+Forces GotenbergScreenshot to return a 409 Conflict response if there are
+exceptions load at least one resource. (default false).
+
* `failOnConsoleExceptions(bool $bool)`:
Forces GotenbergScreenshot to return a 409 Conflict response if there are
exceptions in the Chromium console. (default false).
diff --git a/docs/screenshot/builders_api/MarkdownScreenshotBuilder.md b/docs/screenshot/builders_api/MarkdownScreenshotBuilder.md
index 3f7df2e1..2c961101 100644
--- a/docs/screenshot/builders_api/MarkdownScreenshotBuilder.md
+++ b/docs/screenshot/builders_api/MarkdownScreenshotBuilder.md
@@ -63,6 +63,14 @@ document. (default None).
Return a 409 Conflict response if the HTTP status code from
the main page is not acceptable. (default [499,599]). (overrides any previous configuration).
+* `failOnResourceHttpStatusCodes(array $statusCodes)`:
+Return a 409 Conflict response if the HTTP status code from at least one resource is not acceptable.
+(default None). (overrides any previous configuration).
+
+* `failOnResourceLoadingFailed(bool $bool)`:
+Forces GotenbergScreenshot to return a 409 Conflict response if there are
+exceptions load at least one resource. (default false).
+
* `failOnConsoleExceptions(bool $bool)`:
Forces GotenbergScreenshot to return a 409 Conflict response if there are
exceptions in the Chromium console. (default false).
diff --git a/docs/screenshot/builders_api/UrlScreenshotBuilder.md b/docs/screenshot/builders_api/UrlScreenshotBuilder.md
index 09185dcd..868d5e8a 100644
--- a/docs/screenshot/builders_api/UrlScreenshotBuilder.md
+++ b/docs/screenshot/builders_api/UrlScreenshotBuilder.md
@@ -62,6 +62,14 @@ document. (default None).
Return a 409 Conflict response if the HTTP status code from
the main page is not acceptable. (default [499,599]). (overrides any previous configuration).
+* `failOnResourceHttpStatusCodes(array $statusCodes)`:
+Return a 409 Conflict response if the HTTP status code from at least one resource is not acceptable.
+(default None). (overrides any previous configuration).
+
+* `failOnResourceLoadingFailed(bool $bool)`:
+Forces GotenbergScreenshot to return a 409 Conflict response if there are
+exceptions load at least one resource. (default false).
+
* `failOnConsoleExceptions(bool $bool)`:
Forces GotenbergScreenshot to return a 409 Conflict response if there are
exceptions in the Chromium console. (default false).
diff --git a/docs/screenshot/customization.md b/docs/screenshot/customization.md
index 7df7eef1..a9a95cb1 100644
--- a/docs/screenshot/customization.md
+++ b/docs/screenshot/customization.md
@@ -28,6 +28,8 @@
[extraHttpHeaders](#extraHttpHeaders)
[addExtraHttpHeaders](#addExtraHttpHeaders)
[failOnHttpStatusCodes](#failOnHttpStatusCodes)
+[failOnResourceHttpStatusCodes](#failOnResourceHttpStatusCodes)
+[failOnResourceLoadingFailed](#failOnResourceLoadingFailed)
[failOnConsoleExceptions](#failOnConsoleExceptions)
[skipNetworkIdleEvent](#skipNetworkIdleEvent)
@@ -555,6 +557,70 @@ class YourController
> [!TIP]
> For more information go to [Gotenberg documentations](https://gotenberg.dev/docs/routes#invalid-http-status-codes-chromium).
+### failOnResourceHttpStatusCodes
+
+default: `None`
+
+Return a 409 Conflict response if the HTTP status code from at least one resource
+is not acceptable.
+
+```php
+namespace App\Controller;
+
+use Sensiolabs\GotenbergBundle\GotenbergPdfInterface;
+
+class YourController
+{
+ public function yourControllerMethod(GotenbergPdfInterface $gotenberg): Response
+ {
+ return $gotenberg
+ ->html()
+ ->content('content.html.twig', [
+ 'my_var' => 'value'
+ ])
+ ->failOnResourceHttpStatusCodes([401, 403])
+ ->generate()
+ ->stream()
+ ;
+ }
+}
+```
+
+> [!TIP]
+> For more information go to [Gotenberg documentations](https://gotenberg.dev/docs/routes#invalid-http-status-codes-chromium).
+
+### failOnResourceLoadingFailed
+
+default: `false`
+
+Return a 409 Conflict response if there are exceptions to load at least one resource
+in the Chromium.
+
+```php
+namespace App\Controller;
+
+use Sensiolabs\GotenbergBundle\GotenbergPdfInterface;
+
+class YourController
+{
+ public function yourControllerMethod(GotenbergPdfInterface $gotenberg): Response
+ {
+ return $gotenberg
+ ->html()
+ ->content('content.html.twig', [
+ 'my_var' => 'value'
+ ])
+ ->failOnResourceLoadingFailed()
+ ->generate()
+ ->stream()
+ ;
+ }
+}
+```
+
+> [!TIP]
+> For more information go to [Gotenberg documentations](https://gotenberg.dev/docs/routes#network-errors-chromium).
+
### failOnConsoleExceptions
default: `false`
diff --git a/src/Builder/Pdf/AbstractChromiumPdfBuilder.php b/src/Builder/Pdf/AbstractChromiumPdfBuilder.php
index a8864b2b..c734cccf 100644
--- a/src/Builder/Pdf/AbstractChromiumPdfBuilder.php
+++ b/src/Builder/Pdf/AbstractChromiumPdfBuilder.php
@@ -53,6 +53,9 @@ public function __construct(
'failOnHttpStatusCodes' => function (mixed $value): array {
return $this->encodeData('failOnHttpStatusCodes', $value);
},
+ 'failOnResourceHttpStatusCodes' => function (mixed $value): array {
+ return $this->encodeData('failOnResourceHttpStatusCodes', $value);
+ },
'cookies' => fn (mixed $value): array => $this->cookieNormalizer($value, $this->encodeData(...)),
];
@@ -460,6 +463,34 @@ public function failOnHttpStatusCodes(array $statusCodes): static
return $this;
}
+ /**
+ * Return a 409 Conflict response if the HTTP status code from at least one resource is not acceptable.
+ * (default None). (overrides any previous configuration).
+ *
+ * @see https://gotenberg.dev/docs/routes#invalid-http-status-codes-chromium
+ *
+ * @param list> $statusCodes
+ */
+ public function failOnResourceHttpStatusCodes(array $statusCodes): static
+ {
+ $this->formFields['failOnResourceHttpStatusCodes'] = $statusCodes;
+
+ return $this;
+ }
+
+ /**
+ * Forces GotenbergScreenshot to return a 409 Conflict response if there are
+ * exceptions load at least one resource. (default false).
+ *
+ * @see https://gotenberg.dev/docs/routes#network-errors-chromium
+ */
+ public function failOnResourceLoadingFailed(bool $bool = true): static
+ {
+ $this->formFields['failOnResourceLoadingFailed'] = $bool;
+
+ return $this;
+ }
+
/**
* Forces GotenbergPdf to return a 409 Conflict response if there are
* exceptions in the Chromium console. (default false).
@@ -600,6 +631,8 @@ protected function addConfiguration(string $configurationName, mixed $value): vo
'user_agent' => $this->userAgent($value),
'extra_http_headers' => $this->extraHttpHeaders($value),
'fail_on_http_status_codes' => $this->failOnHttpStatusCodes($value),
+ 'fail_on_resource_http_status_codes' => $this->failOnResourceHttpStatusCodes($value),
+ 'fail_on_resource_loading_failed' => $this->failOnResourceLoadingFailed($value),
'fail_on_console_exceptions' => $this->failOnConsoleExceptions($value),
'skip_network_idle_event' => $this->skipNetworkIdleEvent($value),
'metadata' => $this->metadata($value),
diff --git a/src/Builder/Screenshot/AbstractChromiumScreenshotBuilder.php b/src/Builder/Screenshot/AbstractChromiumScreenshotBuilder.php
index 82d592c4..7ffb756a 100644
--- a/src/Builder/Screenshot/AbstractChromiumScreenshotBuilder.php
+++ b/src/Builder/Screenshot/AbstractChromiumScreenshotBuilder.php
@@ -44,6 +44,9 @@ public function __construct(
'failOnHttpStatusCodes' => function (mixed $value): array {
return $this->encodeData('failOnHttpStatusCodes', $value);
},
+ 'failOnResourceHttpStatusCodes' => function (mixed $value): array {
+ return $this->encodeData('failOnResourceHttpStatusCodes', $value);
+ },
'cookies' => fn (mixed $value): array => $this->cookieNormalizer($value, $this->encodeData(...)),
];
@@ -283,6 +286,34 @@ public function failOnHttpStatusCodes(array $statusCodes): static
return $this;
}
+ /**
+ * Return a 409 Conflict response if the HTTP status code from at least one resource is not acceptable.
+ * (default None). (overrides any previous configuration).
+ *
+ * @see https://gotenberg.dev/docs/routes#invalid-http-status-codes-chromium
+ *
+ * @param list> $statusCodes
+ */
+ public function failOnResourceHttpStatusCodes(array $statusCodes): static
+ {
+ $this->formFields['failOnResourceHttpStatusCodes'] = $statusCodes;
+
+ return $this;
+ }
+
+ /**
+ * Forces GotenbergScreenshot to return a 409 Conflict response if there are
+ * exceptions load at least one resource. (default false).
+ *
+ * @see https://gotenberg.dev/docs/routes#network-errors-chromium
+ */
+ public function failOnResourceLoadingFailed(bool $bool = true): static
+ {
+ $this->formFields['failOnResourceLoadingFailed'] = $bool;
+
+ return $this;
+ }
+
/**
* Forces GotenbergScreenshot to return a 409 Conflict response if there are
* exceptions in the Chromium console. (default false).
@@ -383,6 +414,8 @@ private function addConfiguration(string $configurationName, mixed $value): void
'user_agent' => $this->userAgent($value),
'extra_http_headers' => $this->extraHttpHeaders($value),
'fail_on_http_status_codes' => $this->failOnHttpStatusCodes($value),
+ 'fail_on_resource_http_status_codes' => $this->failOnResourceHttpStatusCodes($value),
+ 'fail_on_resource_loading_failed' => $this->failOnResourceLoadingFailed($value),
'fail_on_console_exceptions' => $this->failOnConsoleExceptions($value),
'skip_network_idle_event' => $this->skipNetworkIdleEvent($value),
'download_from' => $this->downloadFrom($value),
diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php
index 09d79761..47e65493 100644
--- a/src/DependencyInjection/Configuration.php
+++ b/src/DependencyInjection/Configuration.php
@@ -326,6 +326,16 @@ private function addChromiumPdfOptionsNode(ArrayNodeDefinition $parent): void
->integerPrototype()
->end()
->end()
+ ->arrayNode('fail_on_resource_http_status_codes')
+ ->info('Return a 409 Conflict response if the HTTP status code from at least one resource is not acceptable. - default None. https://gotenberg.dev/docs/routes#invalid-http-status-codes-chromium')
+ ->defaultValue([])
+ ->integerPrototype()
+ ->end()
+ ->end()
+ ->booleanNode('fail_on_resource_loading_failed')
+ ->info('Return a 409 Conflict response if Chromium fails to load at least one resource - default false. https://gotenberg.dev/docs/routes#network-errors-chromium')
+ ->defaultNull()
+ ->end()
->booleanNode('fail_on_console_exceptions')
->info('Return a 409 Conflict response if there are exceptions in the Chromium console - default false. https://gotenberg.dev/docs/routes#console-exceptions')
->defaultNull()
@@ -450,6 +460,16 @@ private function addChromiumScreenshotOptionsNode(ArrayNodeDefinition $parent):
->integerPrototype()
->end()
->end()
+ ->arrayNode('fail_on_resource_http_status_codes')
+ ->info('Return a 409 Conflict response if the HTTP status code from the main page is not acceptable. - default None. https://gotenberg.dev/docs/routes#invalid-http-status-codes-chromium')
+ ->defaultValue([])
+ ->integerPrototype()
+ ->end()
+ ->end()
+ ->booleanNode('fail_on_resource_loading_failed')
+ ->info('Return a 409 Conflict response if Chromium fails to load at least one resource - default false. https://gotenberg.dev/docs/routes#network-errors-chromium')
+ ->defaultNull()
+ ->end()
->booleanNode('fail_on_console_exceptions')
->info('Return a 409 Conflict response if there are exceptions in the Chromium console - default false. https://gotenberg.dev/docs/routes#console-exceptions')
->defaultNull()
diff --git a/tests/Builder/Pdf/AbstractChromiumPdfBuilderTest.php b/tests/Builder/Pdf/AbstractChromiumPdfBuilderTest.php
index 696666a2..6b2eaa1b 100644
--- a/tests/Builder/Pdf/AbstractChromiumPdfBuilderTest.php
+++ b/tests/Builder/Pdf/AbstractChromiumPdfBuilderTest.php
@@ -104,6 +104,12 @@ public static function configurationIsCorrectlySetProvider(): \Generator
yield 'fail_on_http_status_codes' => ['fail_on_http_status_codes', [499, 500], [
['failOnHttpStatusCodes' => '[499,500]'],
]];
+ yield 'fail_on_resource_http_status_codes' => ['fail_on_resource_http_status_codes', [499, 500], [
+ ['failOnResourceHttpStatusCodes' => '[499,500]'],
+ ]];
+ yield 'fail_on_resource_loading_failed' => ['fail_on_resource_loading_failed', false, [
+ ['failOnResourceLoadingFailed' => 'false'],
+ ]];
yield 'fail_on_console_exceptions' => ['fail_on_console_exceptions', false, [
['failOnConsoleExceptions' => 'false'],
]];
diff --git a/tests/Builder/Screenshot/AbstractChromiumScreenshotBuilderTest.php b/tests/Builder/Screenshot/AbstractChromiumScreenshotBuilderTest.php
index a9a1bf61..ea46afa9 100644
--- a/tests/Builder/Screenshot/AbstractChromiumScreenshotBuilderTest.php
+++ b/tests/Builder/Screenshot/AbstractChromiumScreenshotBuilderTest.php
@@ -60,6 +60,12 @@ public static function configurationIsCorrectlySetProvider(): \Generator
yield 'fail_on_http_status_codes' => ['fail_on_http_status_codes', [499, 500], [
'failOnHttpStatusCodes' => '[499,500]',
]];
+ yield 'fail_on_resource_http_status_codes' => ['fail_on_resource_http_status_codes', [499, 500], [
+ 'failOnResourceHttpStatusCodes' => '[499,500]',
+ ]];
+ yield 'fail_on_resource_loading_failed' => ['fail_on_resource_loading_failed', false, [
+ 'failOnResourceLoadingFailed' => 'false',
+ ]];
yield 'fail_on_console_exceptions' => ['fail_on_console_exceptions', false, [
'failOnConsoleExceptions' => 'false',
]];
diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php
index 84b40cf6..f24e583b 100644
--- a/tests/DependencyInjection/ConfigurationTest.php
+++ b/tests/DependencyInjection/ConfigurationTest.php
@@ -256,6 +256,8 @@ private static function getBundleDefaultConfig(): array
'user_agent' => null,
'extra_http_headers' => [],
'fail_on_http_status_codes' => [499, 599],
+ 'fail_on_resource_http_status_codes' => [],
+ 'fail_on_resource_loading_failed' => null,
'fail_on_console_exceptions' => null,
'skip_network_idle_event' => null,
'pdf_format' => null,
@@ -285,6 +287,8 @@ private static function getBundleDefaultConfig(): array
'user_agent' => null,
'extra_http_headers' => [],
'fail_on_http_status_codes' => [499, 599],
+ 'fail_on_resource_http_status_codes' => [],
+ 'fail_on_resource_loading_failed' => null,
'fail_on_console_exceptions' => null,
'skip_network_idle_event' => null,
'pdf_format' => null,
@@ -314,6 +318,8 @@ private static function getBundleDefaultConfig(): array
'user_agent' => null,
'extra_http_headers' => [],
'fail_on_http_status_codes' => [499, 599],
+ 'fail_on_resource_http_status_codes' => [],
+ 'fail_on_resource_loading_failed' => null,
'fail_on_console_exceptions' => null,
'skip_network_idle_event' => null,
'pdf_format' => null,
@@ -375,6 +381,8 @@ private static function getBundleDefaultConfig(): array
'user_agent' => null,
'extra_http_headers' => [],
'fail_on_http_status_codes' => [499, 599],
+ 'fail_on_resource_http_status_codes' => [],
+ 'fail_on_resource_loading_failed' => null,
'fail_on_console_exceptions' => null,
'skip_network_idle_event' => null,
'download_from' => [],
@@ -394,6 +402,8 @@ private static function getBundleDefaultConfig(): array
'user_agent' => null,
'extra_http_headers' => [],
'fail_on_http_status_codes' => [499, 599],
+ 'fail_on_resource_http_status_codes' => [],
+ 'fail_on_resource_loading_failed' => null,
'fail_on_console_exceptions' => null,
'skip_network_idle_event' => null,
'download_from' => [],
@@ -413,6 +423,8 @@ private static function getBundleDefaultConfig(): array
'user_agent' => null,
'extra_http_headers' => [],
'fail_on_http_status_codes' => [499, 599],
+ 'fail_on_resource_http_status_codes' => [],
+ 'fail_on_resource_loading_failed' => null,
'fail_on_console_exceptions' => null,
'skip_network_idle_event' => null,
'download_from' => [],
diff --git a/tests/DependencyInjection/SensiolabsGotenbergExtensionTest.php b/tests/DependencyInjection/SensiolabsGotenbergExtensionTest.php
index 04449ffd..a69c7dd4 100644
--- a/tests/DependencyInjection/SensiolabsGotenbergExtensionTest.php
+++ b/tests/DependencyInjection/SensiolabsGotenbergExtensionTest.php
@@ -61,6 +61,8 @@ public function testGotenbergConfiguredWithValidConfig(): void
]],
'extra_http_headers' => ['MyHeader' => 'MyValue', 'User-Agent' => 'MyValue'],
'fail_on_http_status_codes' => [401],
+ 'fail_on_resource_http_status_codes' => [401],
+ 'fail_on_resource_loading_failed' => true,
'fail_on_console_exceptions' => true,
'skip_network_idle_event' => true,
'pdf_format' => 'PDF/A-1b',
@@ -86,6 +88,8 @@ public function testGotenbergConfiguredWithValidConfig(): void
'emulated_media_type' => 'screen',
'extra_http_headers' => ['MyHeader' => 'MyValue', 'User-Agent' => 'MyValue'],
'fail_on_http_status_codes' => [401, 403],
+ 'fail_on_resource_http_status_codes' => [401, 403],
+ 'fail_on_resource_loading_failed' => false,
'fail_on_console_exceptions' => false,
'skip_network_idle_event' => false,
'pdf_format' => PdfFormat::Pdf2b->value,
@@ -112,6 +116,8 @@ public function testGotenbergConfiguredWithValidConfig(): void
'emulated_media_type' => 'screen',
'extra_http_headers' => ['MyHeader' => 'MyValue', 'User-Agent' => 'MyValue'],
'fail_on_http_status_codes' => [404],
+ 'fail_on_resource_http_status_codes' => [404],
+ 'fail_on_resource_loading_failed' => false,
'fail_on_console_exceptions' => false,
'skip_network_idle_event' => true,
'pdf_format' => PdfFormat::Pdf3b->value,
@@ -160,6 +166,8 @@ public function testGotenbergConfiguredWithValidConfig(): void
]],
'extra_http_headers' => ['MyHeader' => 'MyValue', 'User-Agent' => 'MyValue'],
'fail_on_http_status_codes' => [401],
+ 'fail_on_resource_http_status_codes' => [401],
+ 'fail_on_resource_loading_failed' => true,
'fail_on_console_exceptions' => true,
'skip_network_idle_event' => true,
'download_from' => [],
@@ -186,6 +194,8 @@ public function testGotenbergConfiguredWithValidConfig(): void
]],
'extra_http_headers' => ['MyHeader' => 'MyValue', 'User-Agent' => 'MyValue'],
'fail_on_http_status_codes' => [401, 403],
+ 'fail_on_resource_http_status_codes' => [401, 403],
+ 'fail_on_resource_loading_failed' => false,
'fail_on_console_exceptions' => false,
'skip_network_idle_event' => true,
'download_from' => [],
@@ -211,6 +221,8 @@ public function testGotenbergConfiguredWithValidConfig(): void
]],
'extra_http_headers' => ['MyHeader' => 'MyValue', 'User-Agent' => 'MyValue'],
'fail_on_http_status_codes' => [401, 403],
+ 'fail_on_resource_http_status_codes' => [401, 403],
+ 'fail_on_resource_loading_failed' => false,
'fail_on_console_exceptions' => false,
'skip_network_idle_event' => false,
'download_from' => [],
@@ -320,6 +332,7 @@ public function testDataCollectorIsProperlyConfiguredIfEnabled(): void
'cookies' => [],
'extra_http_headers' => [],
'fail_on_http_status_codes' => [],
+ 'fail_on_resource_http_status_codes' => [],
'download_from' => [],
],
'url' => [
@@ -329,6 +342,7 @@ public function testDataCollectorIsProperlyConfiguredIfEnabled(): void
'cookies' => [],
'extra_http_headers' => [],
'fail_on_http_status_codes' => [],
+ 'fail_on_resource_http_status_codes' => [],
'download_from' => [],
],
'markdown' => [
@@ -338,6 +352,7 @@ public function testDataCollectorIsProperlyConfiguredIfEnabled(): void
'cookies' => [],
'extra_http_headers' => [],
'fail_on_http_status_codes' => [],
+ 'fail_on_resource_http_status_codes' => [],
'download_from' => [],
],
'office' => [
@@ -372,6 +387,7 @@ public function testDataCollectorIsProperlyConfiguredIfEnabled(): void
'cookies' => [],
'extra_http_headers' => [],
'fail_on_http_status_codes' => [],
+ 'fail_on_resource_http_status_codes' => [],
'download_from' => [],
],
'url' => [
@@ -381,6 +397,7 @@ public function testDataCollectorIsProperlyConfiguredIfEnabled(): void
'cookies' => [],
'extra_http_headers' => [],
'fail_on_http_status_codes' => [],
+ 'fail_on_resource_http_status_codes' => [],
'download_from' => [],
],
'markdown' => [
@@ -390,6 +407,7 @@ public function testDataCollectorIsProperlyConfiguredIfEnabled(): void
'cookies' => [],
'extra_http_headers' => [],
'fail_on_http_status_codes' => [],
+ 'fail_on_resource_http_status_codes' => [],
'download_from' => [],
],
'office' => [
@@ -587,6 +605,8 @@ private static function getValidConfig(): array
]],
'extra_http_headers' => [['name' => 'MyHeader', 'value' => 'MyValue'], ['name' => 'User-Agent', 'value' => 'MyValue']],
'fail_on_http_status_codes' => [401],
+ 'fail_on_resource_http_status_codes' => [401],
+ 'fail_on_resource_loading_failed' => true,
'fail_on_console_exceptions' => true,
'skip_network_idle_event' => true,
'pdf_format' => PdfFormat::Pdf1b->value,
@@ -612,6 +632,8 @@ private static function getValidConfig(): array
'emulated_media_type' => 'screen',
'extra_http_headers' => [['name' => 'MyHeader', 'value' => 'MyValue'], ['name' => 'User-Agent', 'value' => 'MyValue']],
'fail_on_http_status_codes' => [401, 403],
+ 'fail_on_resource_http_status_codes' => [401, 403],
+ 'fail_on_resource_loading_failed' => false,
'fail_on_console_exceptions' => false,
'skip_network_idle_event' => false,
'pdf_format' => PdfFormat::Pdf2b->value,
@@ -637,6 +659,8 @@ private static function getValidConfig(): array
'emulated_media_type' => 'screen',
'extra_http_headers' => [['name' => 'MyHeader', 'value' => 'MyValue'], ['name' => 'User-Agent', 'value' => 'MyValue']],
'fail_on_http_status_codes' => [404],
+ 'fail_on_resource_http_status_codes' => [404],
+ 'fail_on_resource_loading_failed' => false,
'fail_on_console_exceptions' => false,
'skip_network_idle_event' => true,
'pdf_format' => PdfFormat::Pdf3b->value,
@@ -678,6 +702,8 @@ private static function getValidConfig(): array
]],
'extra_http_headers' => [['name' => 'MyHeader', 'value' => 'MyValue'], ['name' => 'User-Agent', 'value' => 'MyValue']],
'fail_on_http_status_codes' => [401],
+ 'fail_on_resource_http_status_codes' => [401],
+ 'fail_on_resource_loading_failed' => true,
'fail_on_console_exceptions' => true,
'skip_network_idle_event' => true,
],
@@ -699,6 +725,8 @@ private static function getValidConfig(): array
]],
'extra_http_headers' => [['name' => 'MyHeader', 'value' => 'MyValue'], ['name' => 'User-Agent', 'value' => 'MyValue']],
'fail_on_http_status_codes' => [401, 403],
+ 'fail_on_resource_http_status_codes' => [401, 403],
+ 'fail_on_resource_loading_failed' => false,
'fail_on_console_exceptions' => false,
'skip_network_idle_event' => true,
],
@@ -719,6 +747,8 @@ private static function getValidConfig(): array
]],
'extra_http_headers' => [['name' => 'MyHeader', 'value' => 'MyValue'], ['name' => 'User-Agent', 'value' => 'MyValue']],
'fail_on_http_status_codes' => [401, 403],
+ 'fail_on_resource_http_status_codes' => [401, 403],
+ 'fail_on_resource_loading_failed' => false,
'fail_on_console_exceptions' => false,
'skip_network_idle_event' => false,
],
diff --git a/tests/GotenbergPdfTest.php b/tests/GotenbergPdfTest.php
index 0c7d56a5..5edca283 100644
--- a/tests/GotenbergPdfTest.php
+++ b/tests/GotenbergPdfTest.php
@@ -64,6 +64,7 @@ public function testUrlBuilderFactory(): void
self::assertSame([
['failOnHttpStatusCodes' => '[499,599]'],
+ ['failOnResourceHttpStatusCodes' => '[]'],
['nativePageRanges' => '1-5'],
['url' => 'https://google.com'],
], $builder->getMultipartFormData());
@@ -86,23 +87,26 @@ public function testHtmlBuilderFactory(): void
$builder->contentFile(__DIR__.'/../Fixtures/files/content.html');
$multipartFormData = $builder->getMultipartFormData();
- self::assertCount(4, $multipartFormData);
+ self::assertCount(5, $multipartFormData);
self::assertArrayHasKey(0, $multipartFormData);
self::assertSame(['failOnHttpStatusCodes' => '[499,599]'], $multipartFormData[0]);
self::assertArrayHasKey(1, $multipartFormData);
- self::assertSame(['marginTop' => '3in'], $multipartFormData[1]);
+ self::assertSame(['failOnResourceHttpStatusCodes' => '[]'], $multipartFormData[1]);
self::assertArrayHasKey(2, $multipartFormData);
- self::assertSame(['marginBottom' => '1in'], $multipartFormData[2]);
+ self::assertSame(['marginTop' => '3in'], $multipartFormData[2]);
self::assertArrayHasKey(3, $multipartFormData);
- self::assertIsArray($multipartFormData[3]);
- self::assertCount(1, $multipartFormData[3]);
- self::assertArrayHasKey('files', $multipartFormData[3]);
- self::assertInstanceOf(DataPart::class, $multipartFormData[3]['files']);
- self::assertSame('index.html', $multipartFormData[3]['files']->getFilename());
+ self::assertSame(['marginBottom' => '1in'], $multipartFormData[3]);
+
+ self::assertArrayHasKey(4, $multipartFormData);
+ self::assertIsArray($multipartFormData[4]);
+ self::assertCount(1, $multipartFormData[4]);
+ self::assertArrayHasKey('files', $multipartFormData[4]);
+ self::assertInstanceOf(DataPart::class, $multipartFormData[4]['files']);
+ self::assertSame('index.html', $multipartFormData[4]['files']->getFilename());
}
public function testMarkdownBuilderFactory(): void
@@ -119,19 +123,19 @@ public function testMarkdownBuilderFactory(): void
$builder->wrapperFile(__DIR__.'/Fixtures/files/wrapper.html');
$multipartFormData = $builder->getMultipartFormData();
- self::assertCount(3, $multipartFormData);
-
- self::assertArrayHasKey(1, $multipartFormData);
- self::assertIsArray($multipartFormData[1]);
- self::assertArrayHasKey('files', $multipartFormData[1]);
- self::assertInstanceOf(DataPart::class, $multipartFormData[1]['files']);
- self::assertSame('file.md', $multipartFormData[1]['files']->getFilename());
+ self::assertCount(4, $multipartFormData);
self::assertArrayHasKey(2, $multipartFormData);
self::assertIsArray($multipartFormData[2]);
self::assertArrayHasKey('files', $multipartFormData[2]);
self::assertInstanceOf(DataPart::class, $multipartFormData[2]['files']);
- self::assertSame('index.html', $multipartFormData[2]['files']->getFilename());
+ self::assertSame('file.md', $multipartFormData[2]['files']->getFilename());
+
+ self::assertArrayHasKey(3, $multipartFormData);
+ self::assertIsArray($multipartFormData[3]);
+ self::assertArrayHasKey('files', $multipartFormData[3]);
+ self::assertInstanceOf(DataPart::class, $multipartFormData[3]['files']);
+ self::assertSame('index.html', $multipartFormData[3]['files']->getFilename());
}
public function testOfficeBuilderFactory(): void
diff --git a/tests/GotenbergScreenshotTest.php b/tests/GotenbergScreenshotTest.php
index 82fcb68e..bfbca3d6 100644
--- a/tests/GotenbergScreenshotTest.php
+++ b/tests/GotenbergScreenshotTest.php
@@ -53,6 +53,7 @@ public function testUrlBuilderFactory(): void
self::assertSame([
['failOnHttpStatusCodes' => '[499,599]'],
+ ['failOnResourceHttpStatusCodes' => '[]'],
['width' => '500'],
['height' => '500'],
['url' => 'https://google.com'],
@@ -76,20 +77,20 @@ public function testHtmlBuilderFactory(): void
$builder->contentFile(__DIR__.'/../Fixtures/files/content.html');
$multipartFormData = $builder->getMultipartFormData();
- self::assertCount(4, $multipartFormData);
-
- self::assertArrayHasKey(1, $multipartFormData);
- self::assertSame(['format' => 'jpeg'], $multipartFormData[1]);
+ self::assertCount(5, $multipartFormData);
self::assertArrayHasKey(2, $multipartFormData);
- self::assertSame(['quality' => '50'], $multipartFormData[2]);
+ self::assertSame(['format' => 'jpeg'], $multipartFormData[2]);
self::assertArrayHasKey(3, $multipartFormData);
- self::assertIsArray($multipartFormData[3]);
- self::assertCount(1, $multipartFormData[3]);
- self::assertArrayHasKey('files', $multipartFormData[3]);
- self::assertInstanceOf(DataPart::class, $multipartFormData[3]['files']);
- self::assertSame('index.html', $multipartFormData[3]['files']->getFilename());
+ self::assertSame(['quality' => '50'], $multipartFormData[3]);
+
+ self::assertArrayHasKey(4, $multipartFormData);
+ self::assertIsArray($multipartFormData[4]);
+ self::assertCount(1, $multipartFormData[4]);
+ self::assertArrayHasKey('files', $multipartFormData[4]);
+ self::assertInstanceOf(DataPart::class, $multipartFormData[4]['files']);
+ self::assertSame('index.html', $multipartFormData[4]['files']->getFilename());
}
public function testMarkdownBuilderFactory(): void
@@ -106,18 +107,18 @@ public function testMarkdownBuilderFactory(): void
$builder->wrapperFile(__DIR__.'/Fixtures/files/wrapper.html');
$multipartFormData = $builder->getMultipartFormData();
- self::assertCount(3, $multipartFormData);
-
- self::assertArrayHasKey(1, $multipartFormData);
- self::assertIsArray($multipartFormData[1]);
- self::assertArrayHasKey('files', $multipartFormData[1]);
- self::assertInstanceOf(DataPart::class, $multipartFormData[1]['files']);
- self::assertSame('file.md', $multipartFormData[1]['files']->getFilename());
+ self::assertCount(4, $multipartFormData);
self::assertArrayHasKey(2, $multipartFormData);
self::assertIsArray($multipartFormData[2]);
self::assertArrayHasKey('files', $multipartFormData[2]);
self::assertInstanceOf(DataPart::class, $multipartFormData[2]['files']);
- self::assertSame('index.html', $multipartFormData[2]['files']->getFilename());
+ self::assertSame('file.md', $multipartFormData[2]['files']->getFilename());
+
+ self::assertArrayHasKey(3, $multipartFormData);
+ self::assertIsArray($multipartFormData[3]);
+ self::assertArrayHasKey('files', $multipartFormData[3]);
+ self::assertInstanceOf(DataPart::class, $multipartFormData[3]['files']);
+ self::assertSame('index.html', $multipartFormData[3]['files']->getFilename());
}
}