Configures and returns a new <tt>Net::HTTP</tt> request object
541130
def http_request
      if http_proxy
        http_request = http_proxy.new(url.host, url.port)
      else
        http_request = Net::HTTP.new(url.host, url.port)
      end
      
      # enable SSL/TLS
      if url.scheme == 'https'
        require 'net/https'
        require 'openssl'
        Error::Connection.extend_classes!
        
        http_request.use_ssl = true
        
        if options[:tls_verify] or options[:verify_ssl]
          if http_request.respond_to?(:enable_post_connection_check=)
            http_request.enable_post_connection_check = true
          end
          # from http://curl.haxx.se/ca/cacert.pem
          http_request.ca_file = options[:tls_ca_file] || File.expand_path('../../../support/cacert.pem', __FILE__)
          http_request.verify_mode = OpenSSL::SSL::VERIFY_PEER
        else
          http_request.verify_mode = OpenSSL::SSL::VERIFY_NONE
        end
        
        if options[:tls_key_and_certificate_file]
          key_and_certificate       = File.read(options[:tls_key_and_certificate_file])
          options[:tls_key]         = OpenSSL::PKey::RSA.new(key_and_certificate)
          options[:tls_certificate] = OpenSSL::X509::Certificate.new(key_and_certificate)
        end
        
        if options[:tls_key] and options[:tls_certificate]
          http_request.key  = options[:tls_key]
          http_request.cert = options[:tls_certificate]
        elsif options[:tls_key] || options[:tls_certificate]
          raise ArgumentError, "Please specify both the certificate and private key (:tls_key and :tls_certificate)"
        end
      end
      
      if @configure_block
        @configure_block.call(http_request)
      end
      
      http_request
    end
797195
def http(&block)
      http = Net::HTTP.new(@uri.host, @uri.port)
      if @uri.port == 443
        http.use_ssl = true
        http.verify_mode = OpenSSL::SSL::VERIFY_NONE
      end
      return http.start(&block) if block_given?
      http
    end
263461
def create_http_request(http_method, path, *arguments)
        http_method = http_method.to_sym

        if [:post, :put].include?(http_method)
          data = arguments.shift
        end

        headers = arguments.first.is_a?(Hash) ? arguments.shift : {}

        case http_method
        when :post
          request = Net::HTTP::Post.new(path,headers)
          request["Content-Length"] = 0 # Default to 0
        when :put
          request = Net::HTTP::Put.new(path,headers)
          request["Content-Length"] = 0 # Default to 0
        when :get
          request = Net::HTTP::Get.new(path,headers)
        when :delete
          request =  Net::HTTP::Delete.new(path,headers)
        else
          raise ArgumentError, "Don't know how to handle http_method: :#{http_method.to_s}"
        end
      
        # handling basic http auth
        request.basic_auth @config[:username], @config[:password]

        if data.is_a?(Hash)
          request.set_form_data(data)
        elsif data
          request.body = data.to_s
          request["Content-Length"] = request.body.length
        end

        request
      end
1198411
def build_http_request(klass, path, params = nil, body = nil)
      path += '?' + URI.encode_www_form(params) unless params.nil?
      req = klass.new(path)
      req.body = URI.encode_www_form(body) unless body.nil?
      Etcd::Log.debug("Built #{klass} path:'#{path}'  body:'#{req.body}'")
      req
    end
615021
def build_request(name, args)
      build_args(args) if args
      uri = build_url(query_params: @query_params)
      @http = build_http(uri.host, uri.port)
      net_http = Kernel.const_get('Net::HTTP::' + name.to_s.capitalize)
      @request = build_request_headers(net_http.new(uri.request_uri))
      if @request_body &&
         (!@request_headers.key?('Content-Type') ||
          @request_headers['Content-Type'] == 'application/json')

        @request.body = @request_body.to_json
        @request['Content-Type'] = 'application/json'
      elsif !@request_body && (name.to_s == 'post')
        @request['Content-Type'] = ''
      else
        @request.body = @request_body
      end
      @http_options.each do |attribute, value|
        @http.send("#{attribute}=", value)
      end
      make_request(@http, @request)
    end
567315
def make_request(uri)
        http_client.start do |http|
          req = Net::HTTP::Get.new(uri.request_uri, @headers)
          req.basic_auth(@username, @password)
          http.request(req)
        end
      end
670865
def prepare_http_connection
      conn = HTTPClient.new(options[:proxy] || self.class.proxy)
      set_http_connection_options(conn, options)
      conn
    end
1034375
def options(path, options = {}, &block)
      perform_request Net::HTTP::Options, path, options, &block
    end
1214415
def request(method, url, headers=None, data=None, session=None):
    
    base_headers = {
        'User-Agent': random_agent()
    }
    if headers is None:
        headers = {}

    base_headers.update(headers)

    if 'Content-Length' in headers:
        del base_headers['Content-Length']

    headers = base_headers
    if session is not None:
        req = session.request
    else:
        req = requests.request

    r = req(method, url, headers=headers, data=data)
    return r
998873
def make_request(method, path, options, raw=false)
      options.merge!({:key => api_key, :id => api_id })

      response = connection(raw).send(method) do |request|
        case method
        when :get, :delete
          request.url(path, options)
        when :post, :put
          request.path = path
          request.body = options unless options.empty?
        end
      end
      return response if raw
      return response.body
    end
348146
def request(method, uri, data: nil, headers: {}, **kwargs)
      request = Request.new(
        headers: default_headers.merge(headers),
        **kwargs,
        method: method,
        uri: join(uri),
        data: data
      )

      ret = cache.call(request) {|req| adapter.call(req) }
      ret.then do |response|
        if !response.errored?
          process response
        else
          raise ResponseError.from_code(response)
        end
      end
    end
1197727
def http_client=(client)
      unless client.kind_of?(Net::HTTP) or client.nil?
        raise ArgumentError, "`client` expected to be a kind of `Net::HTTP`, `#{client.class}` given"
      end
      @http_client = client
    end
337846
def http_post(url, data)
    req = HTTPI::Request.new(:url => url, :body => data)
    return HTTPI.post(req).body
  end
35390
def make_request(call, url)
      request              = Net::HTTP.new(url.host, url.port)
      request.read_timeout = 30
      request.use_ssl      = true

      response = request.start { |http| http.request(call) }
      JSON.parse(response.body)
    end
1312673
def request(method:, url_path:, body: nil, params: {}, header_overrides: {})
      spec = body.nil? ? {} : {body_type: :json}
      endpoint_spec = Smartsheet::API::EndpointSpec.new(method, [url_path], **spec)
      request_spec = Smartsheet::API::RequestSpec.new(
          header_overrides: header_overrides,
          body: body,
          params: params
      )
      client.make_request(endpoint_spec, request_spec)
    end
492103
def request(method, path, params={}, body=nil, headers={}, options={}, &block)
      options = { :mashify => true }.merge(options)
      req = http.build_request(method)
      req.path = path
      req.params.update(Util.clean_params(params)) if params
      req.body = body
      req.headers.update(headers) if headers
      block.call(req) if block
      logger.debug { Util.curl_format(req) }

      if @http_threadsafe
        env = req.to_env(http)
        check_response(http.app.call(env), options)
      else
        @request_mtx.synchronize {
          env = req.to_env(http)
          check_response(http.app.call(env), options)
        }
      end
    end
688508
def send
      http = Net::HTTP.new(@uri.host, @uri.port)
      http.read_timeout = @http_timeout

      # Output request XML if debug flag is set
      puts body if debug == true

      if @uri.port == 443
        http.use_ssl = true
        http.verify_mode = OpenSSL::SSL::VERIFY_NONE
      end

      post = Net::HTTP::Post.new(@uri.path, headers)
      post.body = body

      response = http.start { |conn| conn.request(post) }

      @response = Response.new(self, response)
    end