Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add a default context
- creates a user agent
- disables following redirects
  • Loading branch information
bsweeney committed Jun 14, 2022
1 parent 44c18ef commit bb1ef65
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/Options.php
Expand Up @@ -298,6 +298,18 @@ public function __construct(array $attributes = null)
$this->setFontDir($rootDir . "/lib/fonts");
$this->setFontCache($this->getFontDir());

$ver = "";
$versionFile = realpath(__DIR__ . "/../VERSION");
if (file_exists($versionFile) && ($version = trim(file_get_contents($versionFile))) !== false && $version !== '$Format:<%h>$') {
$ver = "/$version";
}
$this->setHttpContext([
"http" => [
"follow_location" => false,
"user_agent" => "Dompdf$ver https://github.com/dompdf/dompdf"
]
]);

if (null !== $attributes) {
$this->set($attributes);
}
Expand Down
1 change: 0 additions & 1 deletion tests/DompdfTest.php
Expand Up @@ -21,7 +21,6 @@ public function testConstructor()
$this->assertIsArray($dompdf->getCallbacks());
$this->assertInstanceOf(Stylesheet::class, $dompdf->getCss());
$this->assertNull($dompdf->getDom());
$this->assertNull($dompdf->getHttpContext());
$this->assertInstanceOf(Options::class, $dompdf->getOptions());
$this->assertFalse($dompdf->getQuirksmode());
$this->assertNull($dompdf->getTree());
Expand Down

0 comments on commit bb1ef65

Please sign in to comment.