Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit ba93340

Browse files
guangtaopiboogheta
authored andcommitted
url lib support no auth for https
1 parent bf33714 commit ba93340

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

twitter/api.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ class TwitterCall(object):
188188

189189
def __init__(
190190
self, auth, format, domain, callable_cls, uri="",
191-
uriparts=None, secure=True, timeout=None, gzip=False, retry=False, verify_context=False):
191+
uriparts=None, secure=True, timeout=None, gzip=False, retry=False, verify_context=True):
192192
self.auth = auth
193193
self.format = format
194194
self.domain = domain
@@ -363,15 +363,16 @@ def __call__(self, **kwargs):
363363
else:
364364
return self._handle_response(req, uri, arg_data, _timeout, self.verify_context)
365365

366-
def _handle_response(self, req, uri, arg_data, _timeout=None, verify_context=False):
366+
def _handle_response(self, req, uri, arg_data, _timeout=None, verify_context=True):
367367
kwargs = {}
368368
if _timeout:
369369
kwargs['timeout'] = _timeout
370370
try:
371371
context = None
372372
if not verify_context:
373373
context = ssl._create_unverified_context()
374-
handle = urllib_request.urlopen(req, **kwargs, context=context)
374+
kwargs['context'] = context
375+
handle = urllib_request.urlopen(req, **kwargs)
375376
if handle.headers['Content-Type'] in ['image/jpeg', 'image/png']:
376377
return handle
377378
try:
@@ -552,7 +553,7 @@ class Twitter(TwitterCall):
552553
def __init__(
553554
self, format="json",
554555
domain="api.twitter.com", secure=True, auth=None,
555-
api_version=_DEFAULT, retry=False, verify_context=False):
556+
api_version=_DEFAULT, retry=False, verify_context=True):
556557
"""
557558
Create a new twitter API connector.
558559

0 commit comments

Comments
 (0)