How do I send a drupal_http_request() with GET method? Following examples found here and in API, I tried 2 methods, both return a bad request status message.

First method

$data = 'name=value&amp;name1=value1';

$options = array(
  'method' =&gt; 'GET',
  'data' =&gt; $data,
  'timeout' =&gt; 15,
  'headers' =&gt; array('Content-Type' =&gt; 'application/x-www-form-urlencoded'),
);

$result = drupal_http_request('http://example.com/foo', $options);

dpm($result);


Second method

$data = array(
  'key1' =&gt; $value1,
  'key2' =&gt; $value2,
);

$full_url = url('http://example.com/foo', array('query' =&gt; $data));

$options = array(
  'method' =&gt; 'GET',
  'timeout' =&gt; 15,
  'headers' =&gt; array('Content-Type' =&gt; 'application/x-www-form-urlencoded'),
);
$result = drupal_http_request($full_url, $options);

dpm($result);


Which one is the good one and what's wrong ? Thank you

Edit

This is dpm($result)
The first method is correct; you don't use url() to pass the data. Also, application/x-www-form-urlencoded is the content type used when POSTing data.

You could also use drupal_http_build_query() to build the data to pass.

$data = array('name' =&gt; 'value', 'name1' =&gt; 'value1');

$options = array(
  'method' =&gt; 'GET',
  'data' =&gt; drupal_http_build_query($data),
  'timeout' =&gt; 15,
);

$result = drupal_http_request('http://example.com/foo', $options);