The D7 core function drupal_http_request uses the stream_socket_client() php function. For many serious web hosters, sockets and stream_sockets functions are a security bad practice and most of them disable these functions.

Why the D7 developpers don't make drupal_http_request rely on cURL functions ? Is there any alternative ? Thanks, J.


2 Answers 2


The cURL HTTP Request module was built for exactly that:

This is a module intended for developers, as it provides just one API to call: curl_http_request().

The function curl_http_request() is an alternative implementation of Drupal core function drupal_http_request() using cURL. The function intends to be backwards compatible with drupal_http_request(), by accepting the same parameters in the same form and by returning the response in the same format.

I can't comment as to the decision the original developers took, but don't forget that cURL isn't necessarily available on every system either.


I use Guzzle for anything requiring an HTTP-client. It's the official D8 http client, so future upgrades will require minimal work, and it's used by some of Amazon's official tools, so it should be "good enough" for most uses.

For the contrib module, there is currenly a problem with how to handle PSR-0 with composer loading in D7. If you don't need other composer loaded libraries, just stick with the 758860bdb0782aa6ec766655ba48b056c011bb59 commit for Guzzle. If you need others, you will need to head to the issue queue and see more details about solutions there.

I believe the reason curl wasn't relied upon was that curl-support in php wasn't considered widely enough available.

  • Might be worth mentioning this requires PHP >= 5.3
    – Clive
    Dec 11, 2012 at 13:40
  • Ah, I wasn't aware. I dearly wished there was absolutely no need to mention that. 5.5.0_alpha is out of crying out loud! (Not that it's Clive's fault that it might actually be worth mentioning)
    – Letharion
    Dec 11, 2012 at 14:52
  • lol nah that's fine, I don't mind taking the blame ;) The Guzzle module uses namespaces that's the only reason 5.3 is required as far as I can tell. I still find hosts who refuse to upgrade from 5.2 (and early revisions of 5.2 at that) 'cos they're too scared it'll break some legacy stuff. What a world...
    – Clive
    Dec 11, 2012 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.