X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/846ecff0c557a558417429a0dd041cac143506c7..64c591da7fd1318fb3b6ae93bc6fd6f924564d2e:/nominatim/tools/replication.py diff --git a/nominatim/tools/replication.py b/nominatim/tools/replication.py index d93335b8..443a9577 100644 --- a/nominatim/tools/replication.py +++ b/nominatim/tools/replication.py @@ -156,25 +156,25 @@ def _make_replication_server(url: str, timeout: int) -> ContextManager[Replicati """ Download a resource from the given URL and return a byte sequence of the content. """ - get_params = { - 'headers': {"User-Agent" : f"Nominatim (pyosmium/{pyo_version.pyosmium_release})"}, - 'timeout': timeout or None, - 'stream': True - } + headers = {"User-Agent" : f"Nominatim (pyosmium/{pyo_version.pyosmium_release})"} if self.session is not None: - return self.session.get(url.get_full_url(), **get_params) + return self.session.get(url.get_full_url(), + headers=headers, timeout=timeout or None, + stream=True) @contextmanager def _get_url_with_session() -> Iterator[requests.Response]: with requests.Session() as session: - request = session.get(url.get_full_url(), **get_params) # type: ignore + request = session.get(url.get_full_url(), + headers=headers, timeout=timeout or None, + stream=True) yield request return _get_url_with_session() repl = ReplicationServer(url) - repl.open_url = types.MethodType(patched_open_url, repl) + setattr(repl, 'open_url', types.MethodType(patched_open_url, repl)) return cast(ContextManager[ReplicationServer], repl)