Cherry-pick of https://github.com/kennethreitz/requests/commit/bd1f1404a0b38837f8f8b3eaf5f27d783bb29362