Since you don't use `request` after for the complex cases, you'd better use `http.request` here too and remove the dependency to the `request` module.