From: naruse@... Date: 2015-12-18T03:50:13+00:00 Subject: [ruby-core:72236] [Ruby trunk - Bug #11671] [Closed] Net::HTTP uses closed keep-alive connection, causing EOFError Issue #11671 has been updated by Yui NARUSE. Status changed from Open to Closed ---------------------------------------- Bug #11671: Net::HTTP uses closed keep-alive connection, causing EOFError https://bugs.ruby-lang.org/issues/11671#change-55644 * Author: Kristian Hanekamp * Status: Closed * Priority: Normal * Assignee: Yui NARUSE * ruby -v: trunk * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- Most HTTP servers close idle keep-alive connections after a timeout. For the client, this leads to the TCP socket reaching End-Of-File (EOF). Currently, `Net::HTTP` does not check for EOF before reusing a keep-alive connection, causing an `EOFError`. For idempotent requests (for example GET), this does not do much harm, since Net::HTTP simply retries the request. But this does not work for requests that aren't idempotent like POST, so `HTTP#post` will raise an unnecessary `EOFError`. My suggestion is to check for EOF before reusing a keep-alive connection. I've prepared a Github PR for this: https://github.com/ruby/ruby/pull/1089 -- https://bugs.ruby-lang.org/