-
Notifications
You must be signed in to change notification settings - Fork 766
add request logging and hooking #385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
twilio/http/http_client.py
Outdated
try: 8000 | ||
from urllib.parse import urlencode | ||
except ImportError: | ||
from urllib import urlencode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should import things via the compat.py
module which handles version specific imports like this for you.
pushed commit to change urlencode import from twilio.compat |
@tysonholub Thank you for your PR! We have made a ticket in our internal tracking system and will get to this as soon as we can. |
twilio/http/http_client.py
Outdated
@@ -47,4 +72,12 @@ def request(self, method, url, params=None, data=None, headers=None, auth=None, | |||
timeout=timeout, | |||
) | |||
|
|||
if hasattr(response, 'json') and response.json(): | |||
# strip JSON of possible prettyprint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API doesn't pretty print. We probably want to save the loads
/dumps
cost by just always using response.text
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, I'd love to get this shipped this week. If you've got the time, responding to comments and resolving conflicts would be great. If not, we can tidy up before we ship on Friday.
twilio/http/http_client.py
Outdated
@@ -38,7 +45,25 @@ def request(self, method, url, params=None, data=None, headers=None, auth=None, | |||
session = Session() | |||
session.verify = get_cert_file() | |||
|
|||
request = Request(method.upper(), url, params=params, data=data, headers=headers, auth=auth) | |||
kwargs = dict( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Let's just use a dict literal here.
I should be able to address these issues before Friday. Thanks! |
PR adds request/response logging and request hooks to TwilioHttpClient