Code extracted from: https://github.com/bagder/curl.git at commit f2cb3a01192d36395d16acec6cdb93446ca6fd45 (curl-7_50_1).