- applied all the changes from #1363
- some extra escaping for the sake of it
- removed the timeout in http_send_raw