Page MenuHomePhabricator

pywikibot.http._enqueue should have dict argument `params` and `data` like requests
Closed, ResolvedPublic

Description

pywikibot.http._enqueue only accepts a uri and body.

It should also accept unencoded dicts params and data, like requests http://docs.python-requests.org/en/master/user/quickstart/#passing-parameters-in-urls

Note that data is only for POST/PUT/etc. It isnt relevant for GET.

Event Timeline

Btw, it looks like body is already mapped to data, so it probably already accepts a dict.

Change 329360 had a related patch set uploaded (by Sn1per):
Query string dictionary parameter for pwb.comms.http.fetch

https://gerrit.wikimedia.org/r/329360

I noticed that pywikibot.comms.http.fetch and other related methods claim to use the same kwargs as requests.Session.request in their docstrings, but pywikibot http methods use a body parameter to provide data for the Requests method's data parameter. (the body/data parameter corresponds to an HTTP POST body) This could be a bit confusing and should be changed to be more consistent unless there's some other naming conflict I don't know about.

Ya, see above T153559#2884218 ; IMO we should accept both body or data, and treat them the same (maybe using deprecation, if we prefer one name over the other, but I am not sure about that one). ((reviewing now))

Change 329360 merged by jenkins-bot:
Query string dictionary parameter for pwb.comms.http.fetch and friends

https://gerrit.wikimedia.org/r/329360