Skip to content

Commit 7c137d1

Browse files
author
icipiracy
committed
Fixed url headers for python urrllib (in case requests is not used)
1 parent 0eaee2f commit 7c137d1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Adyen/httpclient.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ def handle_header(header_line):
8989
stringbuffer = StringIO()
9090
curl.setopt(curl.WRITEDATA, stringbuffer)
9191

92+
# Add User-Agent header to request so that the request can be identified as coming
93+
# from the Adyen Python library.
9294
headers['User-Agent'] = self.user_agent
9395

9496
# Convert the header dict to formatted array as pycurl needs.
@@ -163,6 +165,8 @@ def _requests_post(self, url,
163165
else:
164166
auth = None
165167

168+
# Add User-Agent header to request so that the request can be identified as coming
169+
# from the Adyen Python library.
166170
headers['User-Agent'] = self.user_agent
167171

168172
request = requests.post(url, auth=auth, data=data, json = json,
@@ -216,6 +220,8 @@ def _urllib_post(self, url,
216220
elif not data:
217221
raise ValueError("Please provide either a json or a data field.")
218222

223+
# Add User-Agent header to request so that the request can be identified as coming
224+
# from the Adyen Python library.
219225
headers['User-Agent'] = self.user_agent
220226

221227
# Set regular dict to return as raw_request:
@@ -229,7 +235,7 @@ def _urllib_post(self, url,
229235

230236
#Adding the headers to the request.
231237
for key, value in headers.items():
232-
url_request.add_header(k, str(v))
238+
url_request.add_header(key, str(value))
233239

234240
#URLlib raises all non 200 responses as en error.
235241
try:
@@ -276,7 +282,6 @@ def request(self, url,
276282
int: HTTP status code, eg 200,404,401
277283
dict: Key/Value pairs of the headers received.
278284
"""
279-
print '\nHTTPCLIENT.REQUEST?????____________________\n'
280285
raise NotImplementedError('request of HTTPClient should have been '
281286
'overridden on initialization. Otherwise, can be overridden to '
282287
'supply your own post method')

0 commit comments

Comments
 (0)