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? |
Beta Was this translation helpful? Give feedback.
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. |
Beta Was this translation helpful? Give feedback.
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.