Move CurlAdapter to lib/ and refactor related code.