It appears CURLOPT_TIMEOUT isn't proper to use here, as indeed it times out in 120s regardless of the connection state. The fact the connection doesn't resume seems to be another issue, but I have attached a small patch that fixes the timeout issue. It sets the minimum transfer speed to 1bs, and uses the timeout of 120s only if < 1bs is being transferred.
It appears CURLOPT_TIMEOUT isn't proper to use here, as indeed it times out in 120s regardless of the connection state. The fact the connection doesn't resume seems to be another issue, but I have attached a small patch that fixes the timeout issue. It sets the minimum transfer speed to 1bs, and uses the timeout of 120s only if < 1bs is being transferred.