[ticket/13227] Properly handle curlwrapper headers in remote avatars

Read a bit of the file to ensure header values are populated and then
handle headers in the nested array structure too.

https://tracker.phpbb.com/browse/PHPBB3-13227