How about Client.base_url and Request.url merge? #1779
|
I often use below code when using the requests library I like httpx Client's base_url properties If there is a base_url among the properties of the client when sending, How about there is a function to merge it with the url of the request? |
Answered by
lovelydinosaur
Aug 4, 2021
Replies: 1 comment 2 replies
|
So, this'll work... client = httpx.Client(base_url="https://www.foo.co.kr/")
response = client.get("/common.do")This would also work... client = httpx.Client(base_url="https://www.foo.co.kr/")
request = client.build_request("GET", "/common.do")
response = client.send(request)The difference is that if you instantiate the request directly and then call Worth considering if our docs at https://www.python-httpx.org/advanced/#request-instances could do with any tweaking to help make things clearer here. |
2 replies
Answer selected by
Atralupus
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So, this'll work...
This would also work...
The difference is that if you instantiate the request directly and then call
.send(), then that's exactly what the client attempts to send, without making any further alterations to it.Worth considering if our docs at https://www.python-httpx.org/advanced/#request-instances could do with any tweaking to help make things clearer here.