Replies: 1 comment
-
After some experimentation & debugging, I've found that it's possible to send bytes parameters through httpx if you do all of the URL-encoding and -construction manually, e.g.: from urllib.parse import quote
import httpx
BASE_URL = "..."
INFO_HASH = b"..."
url = f"{BASE_URL}?info_hash={quote(INFO_HASH)}"
async with httpx.AsyncClient() as client:
r = await client.get(url) Note that, if you try to also pass in a separate I'd still prefer it if httpx had built-in support for this, though. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Certain HTTP applications (like BitTorrent) require clients to send GET requests in which one or more query parameters are URL-encoded byte sequences, e.g.,
?info_hash=%124Vx%9A%BC%DE%F1%23Eg%89%AB%CD%EF%124Vx%9A
. Is there any way to send such requests with httpx? Trying to pass abytes
instance as a value inparams
results in the URL-encoding of the bytes'repr
being used, and if thebytes
is decoded with Latin-1, httpx will just re-encode it as UTF-8 before URL-encoding, which is wrong.I am aware of issue #746, which currently says there are no plans to support
bytes
values inparams
, but I felt it was still worth asking if there was another way to accomplish what I need with this library.Beta Was this translation helpful? Give feedback.
All reactions