Fixed compilation with elder versions of curl

Fallback to dup-based method. It's not optimal, but at least it works