lib/rubygems/gemcutter_utilities.rb in rubygems-update-3.3.22 vs lib/rubygems/gemcutter_utilities.rb in rubygems-update-3.3.23
- old
+ new
@@ -199,19 +199,26 @@
##
# If +response+ is an HTTP Success (2XX) response, yields the response if a
# block was given or shows the response body to the user.
#
# If the response was not successful, shows an error to the user including
- # the +error_prefix+ and the response body.
+ # the +error_prefix+ and the response body. If the response was a permanent redirect,
+ # shows an error to the user including the redirect location.
def with_response(response, error_prefix = nil)
case response
when Net::HTTPSuccess then
if block_given?
yield response
else
say clean_text(response.body)
end
+ when Net::HTTPPermanentRedirect, Net::HTTPRedirection then
+ message = "The request has redirected permanently to #{response['location']}. Please check your defined push host URL."
+ message = "#{error_prefix}: #{message}" if error_prefix
+
+ say clean_text(message)
+ terminate_interaction(ERROR_CODE)
else
message = response.body
message = "#{error_prefix}: #{message}" if error_prefix
say clean_text(message)