Skip to content

Commit 681c265

Browse files
committed
Catch TypeError getting empty content-type #127
1 parent aa30d01 commit 681c265

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

tests/test_basic.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,6 @@ def test_page_get_more_continue(self):
514514
self.assertEqual(len(page.data['backlinks']), 501)
515515

516516
qry = page._query('querymore', wptools.query.WPToolsQuery())
517-
print("\n\n>>>\n%s\n<<<\n\n" % qry)
518517
self.assertTrue(qry.endswith('&blcontinue=0|2062757'))
519518

520519
def test_page_get_imageinfo(self):
@@ -871,7 +870,7 @@ def test_request_curl_info(self):
871870
info = wptools.request.curl_info(req.cobj)
872871
self.assertEqual(info.get('status'), 0)
873872
self.assertEqual(info.get('bytes'), 0.0)
874-
self.assertEqual(info.get('content'), None)
873+
self.assertEqual(info.get('content-type'), None)
875874
self.assertTrue('wptools' in info.get('user-agent'))
876875

877876
def test_request_curl_setup(self):

wptools/request.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,16 @@ def curl_info(crl):
120120
kbps = crl.getinfo(crl.SPEED_DOWNLOAD) / 1000.0
121121
url = crl.getinfo(crl.EFFECTIVE_URL)
122122
url = url.replace("&format=json", '').replace("&formatversion=2", '')
123+
124+
# https://travis-ci.org/siznax/wptools/jobs/401109410
125+
try:
126+
content_type = crl.getinfo(crl.CONTENT_TYPE)
127+
except TypeError:
128+
content_type = None
129+
123130
return {"url": url,
124131
"user-agent": user_agent(),
125-
"content": crl.getinfo(crl.CONTENT_TYPE),
132+
"content-type": content_type,
126133
"status": crl.getinfo(crl.RESPONSE_CODE),
127134
"bytes": crl.getinfo(crl.SIZE_DOWNLOAD),
128135
"seconds": "%5.3f" % crl.getinfo(crl.TOTAL_TIME),

0 commit comments

Comments
 (0)