jenkins-bot has submitted this change and it was merged.

Change subject: merge two http.request calls in Request.submit
......................................................................


merge two http.request calls in Request.submit

Request.submit may submit using MIME or URL form.
Each approach invoked http.request, and then error handling
is performed in a uniform manner.

This patch moves the invocation out of each branch, so
changes to the http request parameters can be added in one
place rather than twice.

Change-Id: I47cbf80dac5b29f6d9548481815d47140aa0c575
---
M pywikibot/data/api.py
1 file changed, 8 insertions(+), 6 deletions(-)

Approvals:
  Mpaa: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 0e846ae..bb086fc 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -431,13 +431,15 @@
                     eoh = body.find(marker)
                     body = body[eoh + len(marker):]
                     # retrieve the headers from the MIME object
-                    mimehead = dict(list(container.items()))
-                    rawdata = http.request(self.site, uri, method="POST",
-                                           headers=mimehead, body=body)
+                    headers = dict(list(container.items()))
                 else:
-                    rawdata = http.request(self.site, uri, method="POST",
-                                           headers={'Content-Type': 
'application/x-www-form-urlencoded'},
-                                           body=paramstring)
+                    headers = {'Content-Type': 
'application/x-www-form-urlencoded'}
+                    body = paramstring
+
+                rawdata = http.request(
+                    self.site, uri, method="POST",
+                    headers=headers, body=body)
+
 #                import traceback
 #                traceback.print_stack()
 #                print rawdata

-- 
To view, visit https://gerrit.wikimedia.org/r/160190
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I47cbf80dac5b29f6d9548481815d47140aa0c575
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: Mpaa <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to