7
7
8
8
import requests
9
9
10
+ import git_pw
10
11
from git_pw import config
11
12
12
13
if 0 : # noqa
@@ -43,6 +44,12 @@ def _get_auth(): # type: () -> requests.auth.AuthBase
43
44
sys .exit (1 )
44
45
45
46
47
+ def _get_headers (): # type: () -> Dict[str, str]
48
+ return {
49
+ 'User-Agent' : 'git-pw ({})' .format (git_pw .__version__ ),
50
+ }
51
+
52
+
46
53
def _get_server (): # type: () -> str
47
54
if CONF .server :
48
55
return CONF .server .rstrip ('/' )
@@ -58,7 +65,8 @@ def get(url, params=None): # type: (str, dict) -> requests.Response
58
65
LOG .debug ('GET %s' , url )
59
66
60
67
try :
61
- rsp = requests .get (url , auth = _get_auth (), params = params )
68
+ rsp = requests .get (url , auth = _get_auth (), headers = _get_headers (),
69
+ params = params )
62
70
rsp .raise_for_status ()
63
71
except requests .exceptions .RequestException as exc :
64
72
if exc .response is not None and exc .response .content :
@@ -84,7 +92,8 @@ def put(url, data): # type: (str, dict) -> requests.Response
84
92
LOG .debug ('PUT %s, data=%r' , url , data )
85
93
86
94
try :
87
- rsp = requests .patch (url , auth = _get_auth (), data = data )
95
+ rsp = requests .patch (url , auth = _get_auth (), headers = _get_headers (),
96
+ data = data )
88
97
rsp .raise_for_status ()
89
98
except requests .exceptions .RequestException as exc :
90
99
if exc .response is not None and exc .response .content :
0 commit comments