While writing some code to consume Twitter's v1.1 api, I was continually running into this error:
EOFError: end of file reached
I began adding and removing bits of code around the http request, until I eventually discovered it was the gzip encoding that was causing the problem. Removing this header declaration seemed to fix everything up:
request["Accept-Encoding"] = "gzip"
I ran into the same issue again, this time with a different solution. I was including an HMAC signature in the header, but wasn't encoding it properly.
I changed it from
request['X-Hmac-signature"] = generate_signature
request['X-Hmac-signature'] = URI.encode(generate_signature)
and the EOFerror went away.