Using Guzzle to get a response code from another site in Drupal 8

https://guzzle3.readthedocs.io/http-client/request.html#head-requests

Key thing as far as timeout vs connection_timeout is that as far as i can tell they are separate and additive; that is, you don’t have to worry about making sure that one value is longer than the other so that it doesn’t short-circuit it.

See https://stackoverflow.com/questions/20847633/limit-connecting-time-with-guzzle-http-php-client#26845868 https://stackoverflow.com/questions/39526699/guzzle-difference-between-connect-timeout-and-timeout#44680364

>>> $client = \Drupal::httpClient();
=> GuzzleHttp\Client {#10681
     +"_serviceId": "http_client",
   }
>>> $request = $client->head('http://www.example.com');
=> GuzzleHttp\Psr7\Response {#10713}
>>> $response = $request->send();
PHP Error:  Call to undefined method GuzzleHttp/Psr7/Response::send() in Psy Shell code on line 1
>>> $request->getStatusCode();
=> 200

https://github.com/guzzle/guzzle/issues/969#issuecomment-71672924

https://stackoverflow.com/questions/17658283/catching-exceptions-from-guzzle