v0.28 plusses for spaces causing errors and _urlparse suddenly being ignored
#3447
-
|
Good morning, I have requests like this: httpx.request("https://impressdc/fmi/odata/v4/Data_Orders/Order", params={
"$filter": f"ID_Order eq {order_number}",
"$select": "ExtSource,ExtOrderID,ID_Order",
})And I use this to keep the special characters intact: from httpx import _urlparse as httpx_urlparse
httpx_urlparse.UNRESERVED_CHARACTERS += "$,"After upgrading from - https://impressdc/fmi/odata/v4/Data_Orders/Order?$filter=ID_Order%20eq%20341589&$select=ExtSource,ExtOrderID,ID_Order
+ https://impressdc/fmi/odata/v4/Data_Orders/Order?%24filter=ID_Order+eq+341589&%24select=ExtSource%2CExtOrderID%2CID_OrderThis is causing the remote to respond with "400: I see #3371 and #3373 linked to in #3394 talking about the spaces, though I'm not sure about why |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
Thanks @shenanigansd, really good question.
* Actually I'm unkeen on having chosen |
Beta Was this translation helpful? Give feedback.
-
|
Is there a reason this isn't just a flag to flip? We're actually debating monkeypatching httpx (or maybe even just replacing it with something else) because we're using an API that actually expects spaces to be percent encoded. Keeping it as bytes seems like an odd solution to the problem. |
Beta Was this translation helpful? Give feedback.
Thanks @shenanigansd, really good question.
_urlparseis not public API and direct usage is not currently supported.httpx.URL("https://www.example.com/", query=b"test=$%24 %20+")* is a good approach if you need to be precise about what escaping style you want. This will only percent encode the query portion where spec-required. (Usingparams={...}will always give you HTML form-like behavior. There's some docs work to be done here.)* Actually I'm unkeen on having chosen
bytesfor that interface, but there's a more involved discussion there to be had at a later date.