def http_call(http_method, path, params={}, headers={}, options={})
      headers ||= { }

      args = [http_method]
      if %w[post put].include?(http_method.to_s)
        #If using multi-part forms, the paramaters should not be json
        if ((headers.include?(:content_type)) and (headers[:content_type] == "multipart/form-data"))
          args << params
        else
          args << params.to_json
        end
      else
        headers[:params] = params if params
      end

      log.info "Server: #{@uri}"
      log.info "#{http_method.to_s.upcase} #{path}"
      log.debug "Params: #{inspect_data(params)}"
      log.debug "Headers: #{inspect_data(headers)}"

      args << headers if headers

      if dry_run?
        empty_response = ApipieBindings::Example.new('', '', '', 200, '')
        ex = options[:fake_response ] || empty_response
        response = create_fake_response(ex.status, ex.response, http_method, URI.join(@uri || 'http://example.com', path).to_s, args)
      else
        apidoc_without_auth = (path =~ /\/apidoc\//) && !@apidoc_authenticated
        authenticate = options[:with_authentication].nil? ? !apidoc_without_auth : options[:with_authentication]
        begin
          client = authenticate ? authenticated_client : unauthenticated_client
          response = call_client(client, path, args)
          update_cache(response.headers[:apipie_checksum])
        rescue => e
          log.error e.message
          log.debug inspect_data(e)
          if e.respond_to?(:response) && e.response.respond_to?(:headers)
            update_cache(e.response.headers[:apipie_checksum])
          end
          override_e = @authenticator.error(e) if authenticate && @authenticator
          raise override_e.is_a?(StandardError) ? override_e : e
        end
      end

      result = options[:response] == :raw ? response : process_data(response)
      log.debug "Response: %s" % (options[:reduce_response_log] ? "Received OK" : inspect_data(result))
      log.debug "Response headers: #{inspect_data(response.headers)}" if response.respond_to?(:headers)
      result
    end
def http_call(http_method, path, params={}, headers={}, options={})
      headers ||= { }

      args = [http_method]
      if %w[post put].include?(http_method.to_s)
        #If using multi-part forms, the paramaters should not be json
        if ((headers.include?(:content_type)) and (headers[:content_type] == "multipart/form-data"))
          args << params
        else
          args << params.to_json
        end
      else
        headers[:params] = params if params
      end

      log.info "Server: #{@uri}"
      log.info "#{http_method.to_s.upcase} #{path}"
      log.debug "Params: #{inspect_data(params)}"
      log.debug "Headers: #{inspect_data(headers)}"

      args << headers if headers

      if dry_run?
        empty_response = ApipieBindings::Example.new('', '', '', 200, '')
        ex = options[:fake_response ] || empty_response
        response = create_fake_response(ex.status, ex.response, http_method, URI.join(@uri || 'http://example.com', path).to_s, args)
      else
        apidoc_without_auth = (path =~ /\/apidoc\//) && !@apidoc_authenticated
        authenticate = options[:with_authentication].nil? ? !apidoc_without_auth : options[:with_authentication]
        begin
          client = authenticate ? authenticated_client : unauthenticated_client
          response = call_client(client, path, args)
          update_cache(response.headers[:apipie_checksum])
        rescue => e
          log.error e.message
          log.debug inspect_data(e)
          if e.respond_to?(:response) && e.response.respond_to?(:headers)
            update_cache(e.response.headers[:apipie_checksum])
          end
          override_e = @authenticator.error(e) if authenticate && @authenticator
          raise override_e.is_a?(StandardError) ? override_e : e
        end
      end

      result = options[:response] == :raw ? response : process_data(response)
      log.debug "Response: %s" % (options[:reduce_response_log] ? "Received OK" : inspect_data(result))
      log.debug "Response headers: #{inspect_data(response.headers)}" if response.respond_to?(:headers)
      result
    end
Low level call to the API. Suitable for calling actions not covered by
 apipie documentation. For all other cases use {#call}
 @param [String] http_method one of +get+, +put+, +post+, +destroy+, +patch+
 @param [String] path URL path that should be called
 @param [Hash] params parameters to be send in the request
 @param [Hash] headers extra headers to be sent with the request
 @param [Hash] options options to influence the how the call is processed
   * *:response* (Symbol) *:raw* - skip parsing JSON in response
   * *:reduce_response_log* (Bool) - do not show response content in the log.
   * *:with_authentication* (Bool) *true* - use rest client with/without auth configuration
 @example show user data
   http_call('get', '/api/users/1')