    # File lib/rubygems/remote_fetcher.rb, line 152
      def fetch_size(uri)
        return File.size(get_file_uri_path(uri)) if file_uri? uri

        uri = URI.parse uri unless URI::Generic === uri

        raise ArgumentError, 'uri is not an HTTP URI' unless URI::HTTP === uri

        response = request uri, Net::HTTP::Head

        case response
        when Net::HTTPOK then
        else
          raise FetchError.new("bad response #{response.message} #{response.code}", uri)
        end

        if response['content-length'] then
          return response['content-length'].to_i
        else
          response = http.get uri.request_uri
          return response.body.size
        end

      rescue SocketError, SystemCallError, Timeout::Error => e
        raise FetchError.new("#{e.message} (#{e.class})\n\tfetching size", uri)
      end