Use cache directory when downloading composer.phar

Since there is a cache dir there is no need to populate the project
directory with temp files. Plus the permissions on the project dir
might not allow that.
Check if current dir is writable and if not try the cache dir from settings
Cache path never ends with '/'
Merge remote-tracking branch 'jimmykane/master'
don't require the error message have the first line of HTTP output in it
Merge pull request #2435 from ptarjan/master

don't require the error message have the first line of HTTP output in it