Skip to content

Commit

Permalink
feat: add user agent to stream context in DefaultDownloader (#3248)
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfvandekrol authored Apr 21, 2023
1 parent 20d7ccc commit 99b703e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Downloaders/DefaultDownloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ class DefaultDownloader implements Downloader
{
public function getTempFile(string $url): string
{
if (! $stream = @fopen($url, 'r')) {
$context = stream_context_create([
"http" => [
"header" => "User-Agent: Spatie MediaLibrary",
],
]);

if (! $stream = @fopen($url, 'r', false, $context)) {
throw UnreachableUrl::create($url);
}

Expand Down

0 comments on commit 99b703e

Please sign in to comment.