jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1225635?usp=email )

Change subject: Remove protocol swapping in api.Request
......................................................................

Remove protocol swapping in api.Request

Switches causing HTTP 403. Remove prtotocol swapping;
Family file must provide the right protocol.

Bug: T414369
Change-Id: I1234567890abcdef1234567890abcdef12345678
---
M ROADMAP.rst
M pywikibot/data/api/_requests.py
2 files changed, 4 insertions(+), 18 deletions(-)

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




diff --git a/ROADMAP.rst b/ROADMAP.rst
index 363fc31..4111ff9 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -90,6 +90,8 @@

 **Other breaking changes**

+* Protocol swapping in :class:`data.api.Request` was removed. Family files 
should provide
+  the correct protocol. (:phab:`T414369`)
 * Package requirements were updated (``beautifulsoup4``, ``fake-useragent``, 
``mwoauth``,
   ``mwparserfromhell``, ``packaging``, ``Pillow``, ``pydot``, ``PyMySQL``, 
``python-stdnum``,
   ``requests``, ``requests-sse``, ``wikitextparser``)
diff --git a/pywikibot/data/api/_requests.py b/pywikibot/data/api/_requests.py
index 9ec54dd..fe20032 100644
--- a/pywikibot/data/api/_requests.py
+++ b/pywikibot/data/api/_requests.py
@@ -21,7 +21,7 @@
 from email.mime.nonmultipart import MIMENonMultipart
 from pathlib import Path
 from typing import TYPE_CHECKING, Any, NoReturn
-from urllib.parse import unquote, urlencode, urlparse
+from urllib.parse import unquote, urlencode
 from warnings import warn

 import pywikibot
@@ -725,16 +725,10 @@

         :meta public:
         """
-        kwargs = {}
-        schemes = ('http', 'https')
-        if self.json_warning and self.site.protocol() in schemes:
-            # retry with other scheme
-            kwargs['protocol'] = schemes[self.site.protocol() == 'http']
-
         try:
             response = http.request(self.site, uri=uri,
                                     method='GET' if use_get else 'POST',
-                                    data=data, headers=headers, **kwargs)
+                                    data=data, headers=headers)
         except Server504Error:
             pywikibot.log('Caught HTTP 504 error; retrying')

@@ -838,16 +832,6 @@
                         self[param] = [str(math.ceil(value / 2))]
                         pywikibot.info(f'Set {param} = {self[param]}')
         else:
-            scheme = urlparse(response.url).scheme
-            if self.json_warning and scheme != self.site.protocol():
-                warn(f"""
-Your {self.site.family} family uses a wrong scheme {self.site.protocol()!r}
-but {scheme!r} is required. Please add the following code to your family file:
-
-    def protocol(self, code: str) -> str:
-        return '{scheme}'
-
-""", stacklevel=2)
             return result or {}

         self.wait()

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1225635?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I1234567890abcdef1234567890abcdef12345678
Gerrit-Change-Number: 1225635
Gerrit-PatchSet: 16
Gerrit-Owner: Akaza24 <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to