def make_http_request(request, follow_redirect = @follow_redirects)
      request.basic_auth @username, @password if @username
      request['Cookie'] = @cookies if @cookies

      if @proxy_ip
        case @proxy_protocol
        when 'http'
          http = Net::HTTP::Proxy(@proxy_ip, @proxy_port).new(@server_ip, @server_port)
        when 'socks'
          http = Net::HTTP::SOCKSProxy(@proxy_ip, @proxy_port).start(@server_ip, @server_port)
        else
          raise "unknown proxy protocol: '#{@proxy_protocol}'"
        end
      else
        http = Net::HTTP.new(@server_ip, @server_port)
      end

      if @ssl && @pkcs_file_path
        http.use_ssl = true
        pkcs12 =OpenSSL::PKCS12.new(File.binread(@pkcs_file_path), @pass_phrase!=nil ? @pass_phrase : "")
        http.cert = pkcs12.certificate
        http.key = pkcs12.key
        http.verify_mode = OpenSSL::SSL::VERIFY_NONE
      elsif @ssl
        http.use_ssl = true

        http.verify_mode = OpenSSL::SSL::VERIFY_PEER
        http.ca_file = @ca_file if @ca_file
      end
      http.open_timeout = @http_open_timeout
      http.read_timeout = @http_read_timeout

      response = http.request(request)
      case response
        when Net::HTTPRedirection then
          # If we got a redirect request, follow it (if flag set), but don't
          # go any deeper (only one redirect supported - don't want to follow
          # our tail)
          if follow_redirect
            redir_uri = URI.parse(response['location'])
            response = make_http_request(
              Net::HTTP::Get.new(redir_uri.path, false)
            )
          end
      end

      # Pick out some useful header info before we return
      @jenkins_version = response['X-Jenkins']
      @hudson_version = response['X-Hudson']

      return response
    end
def make_http_request(request, follow_redirect = @follow_redirects)
      request.basic_auth @username, @password if @username
      request['Cookie'] = @cookies if @cookies

      if @proxy_ip
        case @proxy_protocol
        when 'http'
          http = Net::HTTP::Proxy(@proxy_ip, @proxy_port).new(@server_ip, @server_port)
        when 'socks'
          http = Net::HTTP::SOCKSProxy(@proxy_ip, @proxy_port).start(@server_ip, @server_port)
        else
          raise "unknown proxy protocol: '#{@proxy_protocol}'"
        end
      else
        http = Net::HTTP.new(@server_ip, @server_port)
      end

      if @ssl && @pkcs_file_path
        http.use_ssl = true
        pkcs12 =OpenSSL::PKCS12.new(File.binread(@pkcs_file_path), @pass_phrase!=nil ? @pass_phrase : "")
        http.cert = pkcs12.certificate
        http.key = pkcs12.key
        http.verify_mode = OpenSSL::SSL::VERIFY_NONE
      elsif @ssl
        http.use_ssl = true

        http.verify_mode = OpenSSL::SSL::VERIFY_PEER
        http.ca_file = @ca_file if @ca_file
      end
      http.open_timeout = @http_open_timeout
      http.read_timeout = @http_read_timeout

      response = http.request(request)
      case response
        when Net::HTTPRedirection then
          # If we got a redirect request, follow it (if flag set), but don't
          # go any deeper (only one redirect supported - don't want to follow
          # our tail)
          if follow_redirect
            redir_uri = URI.parse(response['location'])
            response = make_http_request(
              Net::HTTP::Get.new(redir_uri.path, false)
            )
          end
      end

      # Pick out some useful header info before we return
      @jenkins_version = response['X-Jenkins']
      @hudson_version = response['X-Hudson']

      return response
    end
Connects to the Jenkins server, sends the specified request and returns
 the response.

 @param [Net::HTTPRequest] request The request object to send
 @param [Boolean] follow_redirect whether to follow redirects or not

 @return [Net::HTTPResponse] Response from Jenkins