apiclient
apiclient copied to clipboard
add option to make http URIs not absolute
Currently all HTTP requests using apiclient are absolute due to the addition of self.BASE_URL to the path. This is not necessary, since urllib3 builds the connection on connection_from_url() using BASE_URL before the openurl() call.
Patch maintains the current behaviour but adds an option to turn absolute URIs.
That's cool but I encourage you to extend the class and override _compose_url
to do whatever you need it to do. :) I'd like for the point of the library to be to encourage people to extend it or to build their own similar versions.
Hey, thanks for the reply.
I am indeed extending it and doing quite a few other things. I just thought I'd propose the above as a patch because I see this as a bugfix, because absolute URIs are only used in proxy requests, and not all api servers like the absolute URIs (which was the error i was getting).
Normally HTTP requests should be:
GET /path/to/something HTTP/1.1
only needing to be
GET http://hostname:port/path/to/something HTTP/1.1
when it's a proxy request. The proxy itself would strip out the path into the same as the former request.
Anyhow, up to you :-) and thanks for making apiclient available.
Right. Maybe a better solution would be to switch from using urllib3.connection_from_url
to using a PoolManager which already handles converting to relative paths for you. :)