How to convert cUrl code to drupal way? I have below code

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$html = curl_exec($ch);
$redirectURL = curl_getinfo($ch,CURLINFO_EFFECTIVE_URL);
curl_close($ch);


In Drupal 8 way we can use

$client = \Drupal::httpClient();

$response = $client-&gt;request('GET', $url, [
  // To add 
]);


Not sure how to pass needed parameters/convert it to drupal way.

[UPDATE]

$uri = 'http://domain.com';

$client = \Drupal::httpClient();

$actual_uri = NULL;
$response = $client-&gt;fromOptions([
    'allow_redirects' =&gt; [
      'on_redirect' =&gt; function (RequestInterface $request, ResponseInterface $response, \Psr\Http\Message\UriInterface $uri) use (&amp;$actual_uri) {
        $actual_uri = (string) $uri;
      }
    ],
  ])-&gt;send($request);

dump($response);
exit;
The only special thing I see there is getting the effective URL, which is actually something that was specifically added back to Guzzle 6 for Drupal: https://github.com/guzzle/guzzle/issues/1166

See \Drupal\aggregator\Plugin\aggregator\fetcher\DefaultFetcher::fetch:

  /** @var \Psr\Http\Message\UriInterface $actual_uri */
  $actual_uri = NULL;
  $response = $this-&gt;httpClientFactory-&gt;fromOptions([
    'allow_redirects' =&gt; [
      'on_redirect' =&gt; function (RequestInterface $request, ResponseInterface $response, UriInterface $uri) use (&amp;$actual_uri) {
        $actual_uri = (string) $uri;
      }
    ],
  ])-&gt;send($request);