I’ve been reading the http API but I couldn’t find a way to do an http.get() by just providing the URI I want to access.
For example, I receive from client a complicated URI, say http://a.b.c:1234/d/e and I would like to do a GET request to it. The problem is that if I have to set the options parameter of the http.get() method I’m going to end up in complicated string parsing to parse host, port and path. Moreover, I’m not even sure port will always be provided, for example. Is there a way to do an http.get() by just providing the full URI?
Thanks!
You can use the
urllibrary to do this.will work, because the properties on the parsed url object are the same as the options expected by
http.get. This isn’t a hack, if you look in the docs it says that the two libraries are designed to complement one another like this.