Last active
December 15, 2015 05:19
-
-
Save sferik/5208022 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# API v1.1, HTTPS | |
# Expected: {\"errors\":[{\"message\":\"Bad Authentication data\",\"code\":215}]} | |
# Raises: EOFError: end of file reached | |
require 'net/http' | |
uri = "https://api.twitter.com/1.1/users/show.json?user_id=33978" | |
Net::HTTP.get(URI(uri)) | |
# API v1, HTTPS | |
# Expected: {\"errors\":[{\"message\":\"Bad Authentication data\",\"code\":215}]} | |
# Raises: EOFError: end of file reached | |
require 'net/http' | |
uri = "https://api.twitter.com/1/users/show.json?user_id=33978" | |
Net::HTTP.get(URI(uri)) | |
# API v1.1, HTTP | |
# Expected: {\"errors\":[{\"message\":\"Bad Authentication data\",\"code\":215}]} | |
# Returns: {\"errors\":[{\"message\":\"Bad Authentication data\",\"code\":215}]} | |
require 'net/http' | |
uri = "http://api.twitter.com/1.1/users/show.json?user_id=33978" | |
Net::HTTP.get(URI(uri)) | |
# API v1.0, HTTP | |
# Expected: {\"errors\":[{\"message\":\"Bad Authentication data\",\"code\":215}]} | |
# Returns: {\"errors\":[{\"message\":\"Bad Authentication data\",\"code\":215}]} | |
require 'net/http' | |
uri = "http://api.twitter.com/1/users/show.json?user_id=33978" | |
Net::HTTP.get(URI(uri)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm trying to figure out what Ruby is doing to send the request. I was able to get the following to work:
Note that I'm setting up a proxy using mitmproxy to capture the request. Interestingly, the difference between the request from the snippet above and the failing first example is that the working example sends:
But the failing ruby test sends:
Note the http/https difference. It seems like Ruby is sending a non-HTTPS request to api.twitter.com:443 and just getting rejected at the SSL handshake part of the request.
Any idea of anything which may have changed recently with regard to how Net::HTTP sends requests?