You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working on migrating an HTTP library from requests to httpx. One of the differences I noticed (which matter for me in final implementation) is treatment of None values in params and headers. Requests just does not send params if they have None value, while httpx sends query parameter but without value and raises exceptions for headers.
What requests does seems more intuitive to me. Is this deliberate design decision and is it subject to change? I can handle it on my end, but it seems like something that should be part of httpx.
For headers requests does not send None values, while httpx fails with AttributeError: 'NoneType' object has no attribute 'encode'. IMO - at very least it should not fail.
I think I saw discussion about overwriting client params in concrete request - this might be a solution to that as well (send None for concrete value).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am working on migrating an HTTP library from
requests
tohttpx
. One of the differences I noticed (which matter for me in final implementation) is treatment ofNone
values inparams
andheaders
. Requests just does not send params if they haveNone
value, whilehttpx
sends query parameter but without value and raises exceptions for headers.What requests does seems more intuitive to me. Is this deliberate design decision and is it subject to change? I can handle it on my end, but it seems like something that should be part of
httpx
.For headers
requests
does not sendNone
values, whilehttpx
fails withAttributeError: 'NoneType' object has no attribute 'encode'
. IMO - at very least it should not fail.Example:
I think I saw discussion about overwriting client params in concrete request - this might be a solution to that as well (send
None
for concrete value).What do you think?
Beta Was this translation helpful? Give feedback.
All reactions