summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-11-28 12:57:59 -0600
committerSamuel Giddins <segiddins@segiddins.me>2016-11-28 12:57:59 -0600
commit6ba767d3cfab068cf0622495686939b022c6e20d (patch)
tree555cbb029f7a08d647e85d5e4382ce47b889a98c
parentc5efd85580d6a6d40442393f1f2d21c6db1306e1 (diff)
downloadbundler-seg-vendor-persistent.tar.gz
Vendor net-http-persistent with automatiekseg-vendor-persistent
-rw-r--r--Rakefile18
-rw-r--r--lib/bundler/fetcher.rb4
-rw-r--r--lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb (renamed from lib/bundler/vendor/net/http/faster.rb)1
-rw-r--r--lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb (renamed from lib/bundler/vendor/net/http/persistent.rb)47
-rw-r--r--lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb (renamed from lib/bundler/vendor/net/http/persistent/ssl_reuse.rb)3
-rw-r--r--lib/bundler/vendored_persistent.rb13
6 files changed, 56 insertions, 30 deletions
diff --git a/Rakefile b/Rakefile
index 28e8e7fb3a..3a0779ce0c 100644
--- a/Rakefile
+++ b/Rakefile
@@ -305,11 +305,29 @@ begin
lib.prefix = "BundlerVendoredPostIt"
lib.vendor_lib = "lib/bundler/vendor/postit"
end
+
+ Automatiek::RakeTask.new("net-http-persistent") do |lib|
+ lib.download = { :github => "https://github.com/drbrain/net-http-persistent" }
+ lib.namespace = "Net::HTTP::Persistent"
+ lib.prefix = "Bundler::Persistent"
+ lib.vendor_lib = "lib/bundler/vendor/net-http-persistent"
+
+ mixin = Module.new do
+ def namespace_files
+ super
+ require_target = vendor_lib.sub(%r{^(.+?/)?lib/}, "") << "/lib"
+ relative_files = files.map {|f| Pathname.new(f).relative_path_from(Pathname.new(vendor_lib) / "lib").sub_ext("").to_s }
+ process_files(/require (['"])(#{Regexp.union(relative_files)})/, "require \\1#{require_target}/\\2")
+ end
+ end
+ lib.send(:extend, mixin)
+ end
rescue LoadError
namespace :vendor do
task(:molinillo) { abort "Install the automatiek gem to be able to vendor gems." }
task(:thor) { abort "Install the automatiek gem to be able to vendor gems." }
task(:postit) { abort "Install the automatiek gem to be able to vendor gems." }
+ task("net-http-persistent") { abort "Install the automatiek gem to be able to vendor gems." }
end
end
diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb
index 0e890d491c..9e208e4957 100644
--- a/lib/bundler/fetcher.rb
+++ b/lib/bundler/fetcher.rb
@@ -237,7 +237,7 @@ module Bundler
Bundler.settings[:ssl_client_cert]
raise SSLError if needs_ssl && !defined?(OpenSSL::SSL)
- con = Net::HTTP::Persistent.new "bundler", :ENV
+ con = Bundler::Persistent::Net::HTTP::Persistent.new "bundler", :ENV
if gem_proxy = Bundler.rubygems.configuration[:http_proxy]
con.proxy = URI.parse(gem_proxy) if gem_proxy != :no_proxy
end
@@ -273,7 +273,7 @@ module Bundler
Timeout::Error, EOFError, SocketError, Errno::ENETDOWN, Errno::ENETUNREACH,
Errno::EINVAL, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::EAGAIN,
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
- Net::HTTP::Persistent::Error, Zlib::BufError, Errno::EHOSTUNREACH
+ Bundler::Persistent::Net::HTTP::Persistent::Error, Zlib::BufError, Errno::EHOSTUNREACH
].freeze
def bundler_cert_store
diff --git a/lib/bundler/vendor/net/http/faster.rb b/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb
index 74b94d1d99..e5e09080c2 100644
--- a/lib/bundler/vendor/net/http/faster.rb
+++ b/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb
@@ -24,3 +24,4 @@ class Net::BufferedIO #:nodoc:
end
end
end if RUBY_VERSION < '1.9'
+
diff --git a/lib/bundler/vendor/net/http/persistent.rb b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb
index e2805b1236..5195be2152 100644
--- a/lib/bundler/vendor/net/http/persistent.rb
+++ b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb
@@ -4,7 +4,7 @@ begin
rescue LoadError
# net/https or openssl
end if RUBY_VERSION < '1.9' # but only for 1.8
-require 'net/http/faster'
+require 'bundler/vendor/net-http-persistent/lib/net/http/faster'
require 'uri'
require 'cgi' # for escaping
@@ -18,27 +18,27 @@ autoload :OpenSSL, 'openssl'
##
# Persistent connections for Net::HTTP
#
-# Net::HTTP::Persistent maintains persistent connections across all the
+# Bundler::Persistent::Net::HTTP::Persistent maintains persistent connections across all the
# servers you wish to talk to. For each host:port you communicate with a
# single persistent connection is created.
#
-# Multiple Net::HTTP::Persistent objects will share the same set of
+# Multiple Bundler::Persistent::Net::HTTP::Persistent objects will share the same set of
# connections.
#
# For each thread you start a new connection will be created. A
-# Net::HTTP::Persistent connection will not be shared across threads.
+# Bundler::Persistent::Net::HTTP::Persistent connection will not be shared across threads.
#
# You can shut down the HTTP connections when done by calling #shutdown. You
-# should name your Net::HTTP::Persistent object if you intend to call this
+# should name your Bundler::Persistent::Net::HTTP::Persistent object if you intend to call this
# method.
#
# Example:
#
-# require 'net/http/persistent'
+# require 'bundler/vendor/net-http-persistent/lib/net/http/persistent'
#
# uri = URI 'http://example.com/awesome/web/service'
#
-# http = Net::HTTP::Persistent.new 'my_app_name'
+# http = Bundler::Persistent::Net::HTTP::Persistent.new 'my_app_name'
#
# # perform a GET
# response = http.request uri
@@ -149,19 +149,19 @@ autoload :OpenSSL, 'openssl'
#
# The recommended way to handle non-idempotent requests is the following:
#
-# require 'net/http/persistent'
+# require 'bundler/vendor/net-http-persistent/lib/net/http/persistent'
#
# uri = URI 'http://example.com/awesome/web/service'
# post_uri = uri + 'create'
#
-# http = Net::HTTP::Persistent.new 'my_app_name'
+# http = Bundler::Persistent::Net::HTTP::Persistent.new 'my_app_name'
#
# post = Net::HTTP::Post.new post_uri.path
# # ... fill in POST request
#
# begin
# response = http.request post_uri, post
-# rescue Net::HTTP::Persistent::Error
+# rescue Bundler::Persistent::Net::HTTP::Persistent::Error
#
# # POST failed, make a new request to verify the server did not process
# # the request
@@ -178,7 +178,7 @@ autoload :OpenSSL, 'openssl'
#
# === Connection Termination
#
-# If you are done using the Net::HTTP::Persistent instance you may shut down
+# If you are done using the Bundler::Persistent::Net::HTTP::Persistent instance you may shut down
# all the connections in the current thread with #shutdown. This is not
# recommended for normal use, it should only be used when it will be several
# minutes before you make another HTTP request.
@@ -188,7 +188,7 @@ autoload :OpenSSL, 'openssl'
# Ruby will automatically garbage collect and shutdown your HTTP connections
# when the thread terminates.
-class Net::HTTP::Persistent
+class Bundler::Persistent::Net::HTTP::Persistent
##
# The beginning of Time
@@ -201,9 +201,9 @@ class Net::HTTP::Persistent
HAVE_OPENSSL = defined? OpenSSL::SSL # :nodoc:
##
- # The version of Net::HTTP::Persistent you are using
+ # The version of Bundler::Persistent::Net::HTTP::Persistent you are using
- VERSION = '2.9.3'
+ VERSION = '2.9.4'
##
# Exceptions rescued for automatic retry on ruby 2.0.0. This overlaps with
@@ -221,7 +221,7 @@ class Net::HTTP::Persistent
].compact
##
- # Error class for errors raised by Net::HTTP::Persistent. Various
+ # Error class for errors raised by Bundler::Persistent::Net::HTTP::Persistent. Various
# SystemCallErrors are re-raised with a human-readable message under this
# class.
@@ -241,7 +241,7 @@ class Net::HTTP::Persistent
# NOTE: This may not work on ruby > 1.9.
def self.detect_idle_timeout uri, max = 10
- uri = URI uri unless uri.is_a?(URI::Generic)
+ uri = URI uri unless URI::Generic === uri
uri += '/'
req = Net::HTTP::Head.new uri.request_uri
@@ -257,7 +257,7 @@ class Net::HTTP::Persistent
$stderr.puts "HEAD #{uri} => #{response.code}" if $DEBUG
- unless response.is_a?(Net::HTTPOK) then
+ unless Net::HTTPOK === response then
raise Error, "bad response code #{response.code} detecting idle timeout"
end
@@ -463,7 +463,7 @@ class Net::HTTP::Persistent
attr_accessor :retry_change_requests
##
- # Creates a new Net::HTTP::Persistent.
+ # Creates a new Bundler::Persistent::Net::HTTP::Persistent.
#
# Set +name+ to keep your connections apart from everybody else's. Not
# required currently, but highly recommended. Your library name should be
@@ -594,7 +594,7 @@ class Net::HTTP::Persistent
use_ssl = uri.scheme.downcase == 'https'
if use_ssl then
- raise Net::HTTP::Persistent::Error, 'OpenSSL is not available' unless
+ raise Bundler::Persistent::Net::HTTP::Persistent::Error, 'OpenSSL is not available' unless
HAVE_OPENSSL
ssl_generation = @ssl_generation
@@ -728,7 +728,7 @@ class Net::HTTP::Persistent
} or not @reuse_ssl_sessions then
Net::HTTP
else
- Net::HTTP::Persistent::SSLReuse
+ Bundler::Persistent::Net::HTTP::Persistent::SSLReuse
end
end
@@ -1065,7 +1065,7 @@ class Net::HTTP::Persistent
# Returns the request.
def request_setup req_or_uri # :nodoc:
- req = if req_or_uri.is_a?(URI) then
+ req = if URI === req_or_uri then
Net::HTTP::Get.new req_or_uri.request_uri
else
req_or_uri
@@ -1092,7 +1092,7 @@ class Net::HTTP::Persistent
#
# Uses the current thread by default.
#
- # If you've used Net::HTTP::Persistent across multiple threads you should
+ # If you've used Bundler::Persistent::Net::HTTP::Persistent across multiple threads you should
# call this in each thread when you're done making HTTP requests.
#
# *NOTE*: Calling shutdown for another thread can be dangerous!
@@ -1227,4 +1227,5 @@ application:
end
-require 'net/http/persistent/ssl_reuse'
+require 'bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse'
+
diff --git a/lib/bundler/vendor/net/http/persistent/ssl_reuse.rb b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb
index d73aa54996..1b6b789f6d 100644
--- a/lib/bundler/vendor/net/http/persistent/ssl_reuse.rb
+++ b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb
@@ -7,7 +7,7 @@
# This class is an implementation detail and is subject to change or removal
# at any time.
-class Net::HTTP::Persistent::SSLReuse < Net::HTTP
+class Bundler::Persistent::Net::HTTP::Persistent::SSLReuse < Net::HTTP
@is_proxy_class = false
@proxy_addr = nil
@@ -126,3 +126,4 @@ class Net::HTTP::Persistent::SSLReuse < Net::HTTP
private :connect
end
+
diff --git a/lib/bundler/vendored_persistent.rb b/lib/bundler/vendored_persistent.rb
index d5ae513c59..729ac6b6f5 100644
--- a/lib/bundler/vendored_persistent.rb
+++ b/lib/bundler/vendored_persistent.rb
@@ -6,7 +6,12 @@ begin
rescue LoadError
# some Ruby builds don't have OpenSSL
end
-
-vendor = File.expand_path("../vendor", __FILE__)
-$:.unshift(vendor) unless $:.include?(vendor)
-require "net/http/persistent"
+module Bundler
+ module Persistent
+ module Net
+ module HTTP
+ end
+ end
+ end
+end
+require "bundler/vendor/net-http-persistent/lib/net/http/persistent"