Skip to content

Commit 4fd791f

Browse files
committed
no longer recommend to overwrite open_url()
1 parent 36bfa5d commit 4fd791f

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/osmium/replication/server.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ class ReplicationServer:
3232
Replication change files allow to keep local OSM data up-to-date without
3333
downloading the full dataset again.
3434
35+
`url` contains the base URL of the replication service. This is the
36+
directory that contains the state file with the current state. If the
37+
replication service serves something other than osc.gz files, set
38+
the `diff_type` to the given file suffix.
39+
40+
`extra_parameters` may be used to define additional parameters to be
41+
handed to the `requests.get()` method when downloading files. This
42+
may be used to set custom headers, timeouts and similar parameters.
43+
See the `requests documentation <https://requests.readthedocs.io/en/latest/api/?highlight=get#requests.request>`_
44+
for possible parameters. The default is to set a timeout of 60 sec
45+
and enable streaming download.
46+
3547
ReplicationServer may be used as a context manager. In this case, it
3648
internally keeps a connection to the server making downloads faster.
3749
"""
@@ -67,20 +79,6 @@ def make_request(self, url: str) -> urlrequest.Request:
6779
def open_url(self, url: urlrequest.Request) -> Any:
6880
""" Download a resource from the given URL and return a byte sequence
6981
of the content.
70-
71-
This method has no support for cookies or any special authentication
72-
methods. If you need these, you have to provide your own custom URL
73-
opener. Overwrite open_url() with a method that receives an
74-
urlrequest.Request object and returns a ByteIO-like object or a
75-
requests.Response.
76-
77-
Example::
78-
79-
opener = urlrequest.build_opener()
80-
opener.addheaders = [('X-Fancy-Header', 'important_content')]
81-
82-
svr = ReplicationServer()
83-
svr.open_url = opener.open
8482
"""
8583
if 'headers' in self.extra_request_params:
8684
get_params = self.extra_request_params

0 commit comments

Comments
 (0)