in my knowledge, i think you can override from the URL
behavior class or you can also do it manually by encoding the query parameters and replacing the "+"
characters with the value of "%20"
to retain the original URL. afterwards, you can make a request by calling AsyncClient.request()
import httpx
from urllib.parse import urlencode, urlparse, urlunparse
# you can also use parameters to preserve other params value
# just in case if you might need to update with a value other than "%20"
def custom_encode_params(params, new_value):
encoded_params = urlencode(params)
return encoded_params.replace("+", new_value)
base_url = "http://example.com"
params = {"param": "a b"}
encoded_params = custom_encode_params(params, "%20")
parsed_url = urlparse(base_url)
new_url = urlunparse(parsed_url._replace(query=encoded_params))
# adjust with your code that uses `AsyncClient.request()` method
client = httpx.Client()
response = client.get(new_url)
print(response.url)
the URL appending process is indeed done manually and this possibility doesnt cover some other edge cases according to your needs. Hope this helps