New implementation, adjusted from old sub_spec_http_client.inc.php