8000 Merge branch 'twilio_proxy' of github.com:gustafa/twilio-python into … · manniru/twilio-python@1a2dbb5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1a2dbb5

Browse files
committed
Merge branch 'twilio_proxy' of github.com:gustafa/twilio-python into gustafa-twilio_proxy
Conflicts: twilio/rest/__init__.py twilio/rest/resources/base.py
2 parents f19f15e + 70b559d commit 1a2dbb5

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

twilio/rest/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from twilio.rest.resources import Calls
1212
from twilio.rest.resources import Conferences
1313
from twilio.rest.resources import ConnectApps
14+
from twilio.rest.resources import Connection
1415
from twilio.rest.resources import MediaList
1516
from twilio.rest.resources import Members
1617
from twilio.rest.resources import Messages
@@ -23,8 +24,8 @@
2324
from twilio.rest.resources import Sip
2425
from twilio.rest.resources import Sms
2526
from twilio.rest.resources import Transcriptions
26-
from twilio.rest.resources import Usage
2727
from twilio.rest.resources import UNSET_TIMEOUT
28+
from twilio.rest.resources import Usage
2829

2930

3031
def find_credentials():
@@ -39,6 +40,10 @@ def find_credentials():
3940
return None, None
4041

4142

43+
def set_twilio_proxy(proxy_url, proxy_port):
44+
Connection.set_proxy_info(proxy_url, proxy_port)
45+
46+
4247
class TwilioRestClient(object):
4348
"""
4449
A client for accessing the Twilio REST API

twilio/rest/resources/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
)
2626
from twilio.rest.resources.calls import Call, Calls
2727
from twilio.rest.resources.caller_ids import CallerIds, CallerId
28+
from twilio.rest.resources.connection import Connection
2829
from twilio.rest.resources.sandboxes import Sandbox, Sandboxes
2930
from twilio.rest.resources.sms_messages import (
3031
Sms, SmsMessage, SmsMessages, ShortCode, ShortCodes)

twilio/rest/resources/base.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import twilio
88
from twilio import TwilioException, TwilioRestException
99
from twilio.rest.resources import UNSET_TIMEOUT
10+
from twilio.rest.resources.connection import Connection
1011
from twilio.rest.resources.imports import parse_qs, httplib2, json
1112
from twilio.rest.resources.util import transform_params, parse_rfc2822_date
1213

@@ -56,7 +57,11 @@ def make_request(method, url, params=None, data=None, headers=None,
5657
5758
Currently proxies, files, and cookies are all ignored
5859
"""
59-
http = httplib2.Http(timeout=timeout, ca_certs=get_cert_file())
60+
http = httplib2.Http(
61+
timeout=timeout,
62+
ca_certs=get_cert_file(),
63+
proxy_info=Connection.proxy_info(),
64+
)
6065
http.follow_redirects = allow_redirects
6166

6267
if auth is not None:

twilio/rest/resources/connection.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from twilio.rest.resources.imports import httplib2
2+
3+
4+
class Connection(object):
5+
_proxy_info = None
6+
7+
@classmethod
8+
def proxy_info(cls):
9+
return cls._proxy_info
10+
11+
@classmethod
12+
def set_proxy_info(cls, proxy_url, proxy_port):
13+
cls._proxy_info = httplib2.ProxyInfo(httplib2.socks.PROXY_TYPE_HTTP,
14+
proxy_url, proxy_port)

0 commit comments

Comments
 (0)
0