[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Refactor User-Agent constant into common location



commit b122a6fa2bfcf9242244a42e1b25330848a0dd27
Author: Dave Rolek <dmr-x@xxxxxxxxxx>
Date:   Fri May 25 03:28:21 2018 +0000

    Refactor User-Agent constant into common location
---
 stem/__init__.py          | 3 +++
 stem/descriptor/remote.py | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/stem/__init__.py b/stem/__init__.py
index c4d8c1a5..7d84423a 100644
--- a/stem/__init__.py
+++ b/stem/__init__.py
@@ -544,6 +544,9 @@ __all__ = [
   'TimeoutSetType',
 ]
 
+# Constant that we use by default for our User-Agent when downloading descriptors
+stem.USER_AGENT = 'Stem/%s' % __version__
+
 # Constant to indicate an undefined argument default. Usually we'd use None for
 # this, but users will commonly provide None as the argument so need something
 # else fairly unique...
diff --git a/stem/descriptor/remote.py b/stem/descriptor/remote.py
index a8be9280..9adc4466 100644
--- a/stem/descriptor/remote.py
+++ b/stem/descriptor/remote.py
@@ -846,7 +846,7 @@ def _download_from_orport(endpoint, compression, resource):
       request = '\r\n'.join((
         'GET %s HTTP/1.0' % resource,
         'Accept-Encoding: %s' % ', '.join(compression),
-        'User-Agent: Stem/%s' % stem.__version__,
+        'User-Agent: %s' % stem.USER_AGENT,
       )) + '\r\n\r\n'
 
       circ.send('RELAY_BEGIN_DIR', stream_id = 1)
@@ -889,7 +889,7 @@ def _download_from_dirport(url, compression, timeout):
       url,
       headers = {
         'Accept-Encoding': ', '.join(compression),
-        'User-Agent': 'Stem/%s' % stem.__version__,
+        'User-Agent': stem.USER_AGENT,
       }
     ),
     timeout = timeout,



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits