perform_request

in opensearch-transport/lib/opensearch/transport/transport/http/curb.rb [43:73]


          def perform_request(method, path, params={}, body=nil, headers=nil, opts={})
            super do |connection, url|
              connection.connection.url = connection.full_url(path, params)

              case method
              when 'HEAD'
                connection.connection.set :nobody, true
              when 'GET', 'POST', 'PUT', 'DELETE'
                connection.connection.set :nobody, false
                connection.connection.put_data = __convert_to_json(body) if body
                if headers
                  if connection.connection.headers
                    connection.connection.headers.merge!(headers)
                  else
                    connection.connection.headers = headers
                  end
                end
              else
                raise ArgumentError, "Unsupported HTTP method: #{method}"
              end

              connection.connection.http(method.to_sym)

              Response.new(
                connection.connection.response_code,
                decompress_response(connection.connection.body_str),
                headers(connection)
              )
            end
          end