diff --git a/lib/restclient.rb b/lib/restclient.rb index 642f8ad..fbcc97d 100644 --- a/lib/restclient.rb +++ b/lib/restclient.rb @@ -94,7 +94,7 @@ module RestClient # A global proxy URL to use for all requests. This can be overridden on a # per-request basis by passing `:proxy` to RestClient::Request. def self.proxy - @proxy + @proxy ||= nil end def self.proxy=(value) @proxy = value diff --git a/lib/restclient/abstract_response.rb b/lib/restclient/abstract_response.rb index cde1bd6..680330c 100644 --- a/lib/restclient/abstract_response.rb +++ b/lib/restclient/abstract_response.rb @@ -64,7 +64,7 @@ module RestClient # @return [HTTP::CookieJar] # def cookie_jar - return @cookie_jar if @cookie_jar + return @cookie_jar if defined?(@cookie_jar) && @cookie_jar jar = @request.cookie_jar.dup headers.fetch(:set_cookie, []).each do |cookie| diff --git a/lib/restclient/payload.rb b/lib/restclient/payload.rb index fc08d8f..56563fa 100644 --- a/lib/restclient/payload.rb +++ b/lib/restclient/payload.rb @@ -174,7 +174,7 @@ module RestClient end def boundary - return @boundary if @boundary + return @boundary if defined?(@boundary) && @boundary # Use the same algorithm used by WebKit: generate 16 random # alphanumeric characters, replacing `+` `/` with `A` `B` (included in diff --git a/lib/restclient/request.rb b/lib/restclient/request.rb index d82a639..d0c7bd4 100644 --- a/lib/restclient/request.rb +++ b/lib/restclient/request.rb @@ -124,6 +124,8 @@ module RestClient else raise ArgumentError, "must pass :url" end + + @user = @password = nil parse_url_with_auth!(url) # process cookie arguments found in headers or args @@ -815,7 +817,7 @@ module RestClient # Kudos to _why! @tf = Tempfile.new('rest-client.') @tf.binmode - size, total = 0, http_response.header['Content-Length'].to_i + size, total = 0, http_response['Content-Length'].to_i http_response.read_body do |chunk| @tf.write chunk size += chunk.size diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c43a240..bca8e28 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,6 +13,10 @@ RSpec.configure do |config| # --seed 1234 config.order = 'random' + # always run with ruby warnings enabled + # TODO: figure out why this is so obscenely noisy (rspec bug?) + # config.warnings = true + # add helpers config.include Helpers, :include_helpers @@ -20,3 +24,6 @@ RSpec.configure do |config| mocks.yield_receiver_to_any_instance_implementation_blocks = true end end + +# always run with ruby warnings enabled (see above) +$VERBOSE = true