Skip to content
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

Add env var to write raw HTTP traffic to stderr #394

Merged
merged 1 commit into from
Apr 27, 2017

Conversation

kevinburke
Copy link
Contributor

It can be difficult to see the raw traffic going over the wire, but that's what
you need to write tests that integrate with the twilio-php client - the kind
you use for all of your Holodeck tests!

This isn't exactly what goes over the wire, but it's close enough for the
purposes of testing this library. I tried setting CURLOPT_VERBOSE first, but
that prints a bunch of debugging information in addition to the actual data.

@kevinburke
Copy link
Contributor Author

Sample output:

POST /2010-04-01/Accounts/AC0baf7698c0dcef44271303e0ab9c576b/IncomingPhoneNumbers.json
User-Agent: twilio-php/5.4.2 (PHP 7.0.13)
Accept-Charset: utf-8
Content-Type: application/x-www-form-urlencoded
Accept: application/json

AreaCode=500

HTTP/1.1 201
Access-Control-Allow-Credentials:  true
Access-Control-Allow-Headers:  Accept, Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since
Access-Control-Allow-Methods:  GET, POST, DELETE, OPTIONS
Access-Control-Allow-Origin:  *
Access-Control-Expose-Headers:  ETag
Content-Type:  application/json; charset=utf-8
Date:  Thu, 01 Dec 2016 18:24:28 GMT
Strict-Transport-Security:  max-age=15768000
Twilio-Request-Duration:  0.171
Twilio-Request-Id:  RQb4148ed5d72c4a7d98b956805b8e742a
X-Powered-By:  AT-5000
X-Shenanigans:  none
Content-Length:  956
Connection:  keep-alive

{"sid": "PN59910f870686f2adefbde2340c7335e3", "account_sid": "AC0baf7698c0dcef44271303e0ab9c576b", "friendly_name": "(500) 555-0006", "phone_number": "+15005550006", "voice_url": null, "voice_method": "POST", "voice_fallback_url": null, "voice_fallback_method": "POST", "voice_caller_id_lookup": false, "date_created": "Thu, 01 Dec 2016 18:24:28 +0000", "date_updated": "Thu, 01 Dec 2016 18:24:28 +0000", "sms_url": "", "sms_method": "POST", "sms_fallback_url": "", "sms_fallback_method": "POST", "address_requirements": "none", "beta": false, "capabilities": {"voice": true, "sms": true, "mms": false}, "status_callback": "", "status_callback_method": "POST", "api_version": "2010-04-01", "voice_application_sid": null, "sms_application_sid": "", "trunk_sid": null, "emergency_status": "Inactive", "emergency_address_sid": null, "uri": "/2010-04-01/Accounts/AC0baf7698c0dcef44271303e0ab9c576b/IncomingPhoneNumbers/PN59910f870686f2adefbde2340c7335e3.json"}

I guess the Authorization header is added somewhere else by curl? Maybe that's for the best

@codejudas
Copy link
Contributor

@kevinburke I like this idea but can we check the environment variable in the constructor and then cache it in the client so we arent checking on every request? I dont think we need to be able to dynamically turn this off or on in the lifecycle of the client.

It can be difficult to see the raw traffic going over the wire, but that's what
you need to write tests that integrate with the twilio-php client - the kind
you use for all of your Holodeck tests!

This isn't *exactly* what goes over the wire, but it's close enough for the
purposes of testing this library. I tried setting CURLOPT_VERBOSE first, but
that prints a bunch of debugging information in addition to the actual data.
@kevinburke
Copy link
Contributor Author

Done

@codejudas
Copy link
Contributor

Awesome, we'll get this into the next release. Thanks!

@codejudas codejudas merged commit 802b1a7 into twilio:master Apr 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants