What is the equivalent of a call to drupal_http_request()? In Drupal 7 I am using the following code.

$url = 'testdomain/url';
$response = drupal_http_request($url, array('method' =&gt; 'POST', 'headers' =&gt; array('Content-Type' =&gt; 'application/x-www-form-urlencoded; charset=utf-8')));
if ($response-&gt;code == "200") {
  $result = $response-&gt;data;
}


What is the equivalent code I should use on Drupal 8?
Finally i find a code in https://api.drupal.org/api/drupal/core%21includes%21install.core.inc/8 (1375)

and its working for me :) 

 try {
    $response = \Drupal::httpClient()-&gt;get($uri, array('headers' =&gt; array('Accept' =&gt; 'text/plain')));
    $data = (string) $response-&gt;getBody();
    if (empty($data)) {
      return FALSE;
    }
  }
  catch (RequestException $e) {
    return FALSE;
  }


Hope this will help for some one