-
Notifications
You must be signed in to change notification settings - Fork 17
Use path_prefix to compute base_url in httpx #243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
💚 CLA has been signed |
|
Thank you! Can you please sign the CLA? |
|
Hi! Sorry for the delay. I just signed the CLA. |
|
By the way, do you think this commit could be backported to 8.x? |
|
I fixed it by setting Sadly, this PR was inactive for more than half a year. It would be great to add this to a release. Until then, we are stuck with silly fixes like: from elasticsearch import AsyncElasticsearch
from elastic_transport import HttpxAsyncHttpNode, NodeConfig
class HttpxAsyncHttpNodeFixed(HttpxAsyncHttpNode):
def __init__(self, config: NodeConfig):
super().__init__(config)
# This is just a fix to avoid omitting the path prefix in requests
self.client.base_url = self.base_url
es = AsyncElasticsearch("http://example.com/elasticsearch", node_class=HttpxAsyncHttpNodeFixed) |
|
I apologize for dropping the ball on this PR. I'll see that it gets merged and released over the next few days. |
29e475e to
68cbc18
Compare
de5d828 to
fbc1291
Compare
pquentin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM. Note that the requests backend also lacks such a test.
* Use path_prefix to compute base_url in httpx * unit test * add similar unit test for requests nodes --------- Co-authored-by: Miguel Grinberg <miguel.grinberg@gmail.com> (cherry picked from commit c8626a1)
* Use path_prefix to compute base_url in httpx * unit test * add similar unit test for requests nodes --------- (cherry picked from commit c8626a1) Co-authored-by: Vincent Ruello <5345986+vruello@users.noreply.github.com> Co-authored-by: Miguel Grinberg <miguel.grinberg@gmail.com>
Currently, the
path_prefixconfiguration (i.e. the url path) of the ES host is removed by the httpx client. This PR adds it.path_prefixis set byclient_utils.url_to_node_config(https://github.com/elastic/elastic-transport-python/blob/main/elastic_transport/client_utils.py#L187). It is either""if the url path is empty or"/", or the url path itself.For example, if you configure host to be
http://localhost:9092/testand run a search() query, you'll see an HTTP request sent tohttp://localhost:9092/_search, without the "test" prefix.This is very useful when elastic endpoints are behind a reverse proxy with a specific path.