Skip to content

Instantly share code, notes, and snippets.

@drbrain
Last active December 13, 2015 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drbrain/4950704 to your computer and use it in GitHub Desktop.
Save drbrain/4950704 to your computer and use it in GitHub Desktop.
Index: lib/net/http.rb
===================================================================
--- lib/net/http.rb (revision 39237)
+++ lib/net/http.rb (working copy)
@@ -1424,7 +1424,9 @@ module Net #:nodoc:
raise
rescue Net::ReadTimeout, IOError, EOFError,
Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPIPE,
- OpenSSL::SSL::SSLError, Timeout::Error => exception
+ # avoid a dependency on OpenSSL
+ defined?(OpenSSL::SSL) ? OpenSSL::SSL::SSLError : IOError,
+ Timeout::Error => exception
if count == 0 && IDEMPOTENT_METHODS_.include?(req.method)
count += 1
@socket.close if @socket and not @socket.closed?
Index: test/net/http/test_http_request.rb
===================================================================
--- test/net/http/test_http_request.rb (revision 39232)
+++ test/net/http/test_http_request.rb (working copy)
@@ -62,7 +62,7 @@ class HTTPRequestTest < Test::Unit::Test
refute req2.decode_content,
'Bug #7381 - do not decode content if the user overrides'
- end
+ end if Net::HTTP::HAVE_ZLIB
def test_header_set
req = Net::HTTP::Get.new '/'
@@ -73,7 +73,7 @@ class HTTPRequestTest < Test::Unit::Test
refute req.decode_content,
'Bug #7831 - do not decode content if the user overrides'
- end
+ end if Net::HTTP::HAVE_ZLIB
end
Index: test/net/http/test_http.rb
===================================================================
--- test/net/http/test_http.rb (revision 39237)
+++ test/net/http/test_http.rb (working copy)
@@ -442,7 +442,7 @@ module TestNetHTTP_version_1_2_methods
assert_equal $test_net_http_data.size, res.body.size
assert_equal $test_net_http_data, res.body
- assert res.decode_content, 'Bug #7831'
+ assert res.decode_content, 'Bug #7831' if Net::HTTP::HAVE_ZLIB
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment