diff options
author | Aleksey Lim <alsroot@sugarlabs.org> | 2014-05-02 12:57:05 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@sugarlabs.org> | 2014-05-02 12:57:05 (GMT) |
commit | 7d9ab73af830f79db29f8f15133e0293810e0db1 (patch) | |
tree | 8c1e30a21670313e3f15234f8c5b5240ff2ed698 /sugar_network | |
parent | 5f0b31906d28188ce420b84a25cac9c06787c614 (diff) |
Unique User-Agent HTTP header value for client
Diffstat (limited to 'sugar_network')
-rw-r--r-- | sugar_network/__init__.py.in (renamed from sugar_network/__init__.py) | 4 | ||||
-rw-r--r-- | sugar_network/toolkit/http.py | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/sugar_network/__init__.py b/sugar_network/__init__.py.in index 3e35c90..5d79a85 100644 --- a/sugar_network/__init__.py +++ b/sugar_network/__init__.py.in @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Aleksey Lim +# Copyright (C) 2012-2014 Aleksey Lim # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -12,3 +12,5 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. + +version = '%VERSION%' diff --git a/sugar_network/toolkit/http.py b/sugar_network/toolkit/http.py index 4096b7c..f0e9e5e 100644 --- a/sugar_network/toolkit/http.py +++ b/sugar_network/toolkit/http.py @@ -16,9 +16,10 @@ import sys import json import logging +import platform from os.path import join, dirname -from sugar_network import toolkit +from sugar_network import toolkit, version from sugar_network.toolkit import i18n, enforce @@ -331,6 +332,12 @@ class Connection(object): self._session = Connection._Session() self._session.headers['accept-language'] = \ ','.join(i18n.default_langs()) + self._session.headers['user-agent'] = \ + 'sugar-network-client/%s %s/%s' % ( + version, + platform.system(), + platform.release(), + ) for arg, value in self._session_args.items(): setattr(self._session, arg, value) self._session.stream = True |