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
In light of the resolution of #3433, as I still believe that it is a common need to merge the query string from the URL with a params object, I propose implementing an option that would allow API users to specify the way that a query string in the URL will interact with a params dictionary.
I would call that url_query_params_mode;
I would like to implement 3 modes for this parameter:
replace: that is the behaviour from httpx >=0.28 - the query component from the URL is replaced wholesale;
merge: that is an approximation of the behaviour of httpx<0.28:
The query string from the URL is parsed, as a dictionary;
The parameters specified in client.params are then merged with the dictionary from the previous step
One of the peculiarities of merging is that, in the case where a parameter to merge has the same name as a parameter in the source, the incoming value will replace the previous one (as if merging dictionaries using |);
The parameters specified in request.params are then also merged with the dictionary from the previous step;
That final dictionary is then serialised to a query string, and set on the URL;
append: that is the behaviour that I personally find the most interesting, basically:
The query string from the URL is kept as is (no attempt is made to parse it);
The parameters specified in client.params are serialised to a query string, and appended to the URL;
The parameters specified in request.params are serialised to a query string, and appended to the URL:
I find that mode appealing for the following reasons:
This mode does not change any of the URL parameters that are already set on the URL string representation;
All parameters and all values specified at any level (client or request) will be found in the final URL;
What do you think? If anyone at @encode/maintainers thinks that idea is interesting, I would be happy to work on a PR.
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
-
In light of the resolution of #3433, as I still believe that it is a common need to merge the query string from the URL with a
params
object, I propose implementing an option that would allow API users to specify the way that a query string in the URL will interact with aparams
dictionary.url_query_params_mode
;replace
: that is the behaviour fromhttpx
>=0.28 - the query component from the URL is replaced wholesale;merge
: that is an approximation of the behaviour ofhttpx
<0.28:client.params
are then merged with the dictionary from the previous step|
);request.params
are then also merged with the dictionary from the previous step;append
: that is the behaviour that I personally find the most interesting, basically:client.params
are serialised to a query string, and appended to the URL;request.params
are serialised to a query string, and appended to the URL:client
orrequest
) will be found in the final URL;What do you think? If anyone at @encode/maintainers thinks that idea is interesting, I would be happy to work on a PR.
Beta Was this translation helpful? Give feedback.
All reactions