Skip to content

How about Client.base_url and Request.url merge? #1779

Answered by tomchristie
Atralupus asked this question in Q&A
Discussion options

You must be logged in to vote

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

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Atralupus
Comment options

@tomchristie
Comment options

Answer selected by Atralupus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants