Skip to content

Commit

Permalink
[7.x] Prevent interaction with Http::preventStrayRequests (#1052)
Browse files Browse the repository at this point in the history
* use Guzzle directly

* StyleCI: remove unused import

* Throw exception for invalid responses

* styleci

* Update ChromeDriverCommand.php

---------

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
joshbonnick and taylorotwell authored Aug 3, 2023
1 parent d7c536a commit 8d7ce58
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Console/ChromeDriverCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Str;
use Laravel\Dusk\OperatingSystem;
use Symfony\Component\Process\Process;
Expand Down Expand Up @@ -308,13 +307,23 @@ protected function resolveChromeDriverDownloadUrl(string $version, string $os)
* Get the contents of a URL using the 'proxy' and 'ssl-no-verify' command options.
*
* @return string
*
* @throws Exception
*/
protected function getUrl(string $url)
{
return Http::withOptions(array_merge([
$client = new Client();

$response = $client->get($url, array_merge([
'verify' => $this->option('ssl-no-verify') === false,
], array_filter([
'proxy' => $this->option('proxy'),
])))->get($url)->body();
])));

if ($response->getStatusCode() < 200 || $response->getStatusCode() > 299) {
throw new Exception("Unable to fetch contents from [{$url}].");
}

return (string) $response->getBody();
}
}

0 comments on commit 8d7ce58

Please sign in to comment.