Bug 1681109 - python3 - use six.moves.urllib instead of urllib in testing/mozbase/mozproxy/mozproxy/backends/mitm/scripts/alternate-server-replay.py. r=jmaher
authorBob Clary <bclary@bclary.com>
Fri, 11 Dec 2020 19:45:55 +0000
changeset 560673 f77bdbdf95f1c67238838bfc40a33ca6cb3612a9
parent 560672 092f0ef9b7cf1dc0af4a92a8712be4be761e1bbc
child 560674 8c8bbc19e7f90f621bc92f805db1fddcdad605b4
push id38032
push usercsabou@mozilla.com
push dateTue, 15 Dec 2020 09:29:54 +0000
treeherdermozilla-central@f805f27183c3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs1681109
milestone85.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1681109 - python3 - use six.moves.urllib instead of urllib in testing/mozbase/mozproxy/mozproxy/backends/mitm/scripts/alternate-server-replay.py. r=jmaher Differential Revision: https://phabricator.services.mozilla.com/D98968
testing/mozbase/mozproxy/mozproxy/backends/mitm/scripts/alternate-server-replay.py
--- a/testing/mozbase/mozproxy/mozproxy/backends/mitm/scripts/alternate-server-replay.py
+++ b/testing/mozbase/mozproxy/mozproxy/backends/mitm/scripts/alternate-server-replay.py
@@ -8,24 +8,23 @@
 # Altered features:
 # * returns 404 rather than dropping the whole HTTP/2 connection on the floor
 # * remove the replay packages that don't have any content in their response package
 from __future__ import absolute_import, print_function
 
 import os
 import json
 import hashlib
-import urllib
 from collections import defaultdict
 import time
 import signal
 
 import typing
-from urllib import parse
 
+from six.moves import urllib
 from mitmproxy import ctx, http
 from mitmproxy import exceptions
 from mitmproxy import io
 
 # PATCHING AREA  - ALLOWS HTTP/2 WITH NO CERT SNIFFING
 from mitmproxy.proxy.protocol import tls
 from mitmproxy.proxy.protocol.http2 import Http2Layer, SafeH2Connection
 
@@ -178,17 +177,17 @@ class AlternateServerPlayback:
     def _hash(self, flow):
         """
         Calculates a loose hash of the flow request.
         """
         r = flow.request
 
         # unquote url
         # See Bug 1509835
-        _, _, path, _, query, _ = urllib.parse.urlparse(parse.unquote(r.url))
+        _, _, path, _, query, _ = urllib.parse.urlparse(urllib.parse.unquote(r.url))
         queriesArray = urllib.parse.parse_qsl(query, keep_blank_values=True)
 
         key = [str(r.port), str(r.scheme), str(r.method), str(path)]
         key.append(str(r.raw_content))
         key.append(r.host)
 
         for p in queriesArray:
             key.append(p[0])
@@ -267,17 +266,19 @@ class AlternateServerPlayback:
                     )
                     f.response = http.HTTPResponse.make(
                         404, b"", {"content-type": "text/plain"}
                     )
                     self._not_replayed += 1
 
                 # collecting stats only if we can dump them (see .done())
                 if ctx.options.upload_dir:
-                    parsed_url = urllib.parse.urlparse(parse.unquote(f.request.url))
+                    parsed_url = urllib.parse.urlparse(
+                        urllib.parse.unquote(f.request.url)
+                    )
                     self.netlocs[parsed_url.netloc][f.response.status_code] += 1
                     self.calls.append(
                         {
                             "time": str(time.time()),
                             "url": f.request.url,
                             "response_status": f.response.status_code,
                         }
                     )