7 - HTTP error 400 when calling system_retrieve_file()?
In my case, I needed to encode urls, but not how you may expect with PHP's urlencode or rawurlencode.
For example, I needed to convert http://DOMAIN.COM/C8B195/assets/images/01 Grapes 3.jpg to http://DOMAIN.COM/C8B195/assets/images/01%20Grapes%203.jpg. I'm not sure why system_retrieve_file or drupal_http_request had a problem with the spaces.

  $encodedPath = rawurlencode($path);
  $encodedPath = str_replace('%3A', ':', str_replace('%2F', '/', $encodedPath));