apiclient icon indicating copy to clipboard operation
apiclient copied to clipboard

add option to make http URIs not absolute

Open edamato opened this issue 8 years ago • 3 comments

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.

edamato avatar Oct 03 '15 23:10 edamato

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.

shazow avatar Oct 05 '15 01:10 shazow

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.

edamato avatar Oct 05 '15 11:10 edamato

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. :)

shazow avatar Oct 05 '15 19:10 shazow