Builds the hash of options needed by the Connection object on
 construction.

 @param opts [Hash] merged configuration and mutable state data
 @return [Hash] hash of connection options
 @api private
552003
def connection_options(opts)
      connection_options = {
        logger:                 logger,
        user_known_hosts_file:  '/dev/null',
        hostname:               opts[:host],
        port:                   opts[:port],
        username:               opts[:user],
        compression:            opts[:compression],
        compression_level:      opts[:compression_level],
        keepalive:              opts[:keepalive],
        keepalive_interval:     opts[:keepalive_interval],
        timeout:                opts[:connection_timeout],
        connection_retries:     opts[:connection_retries],
        connection_retry_sleep: opts[:connection_retry_sleep],
        max_wait_until_ready:   opts[:max_wait_until_ready],
        auth_methods:           opts[:auth_methods],
        keys_only:              opts[:keys_only],
        keys:                   opts[:key_files],
        password:               opts[:password],
        forward_agent:          opts[:forward_agent],
        proxy_command:          opts[:proxy_command],
        bastion_host:           opts[:bastion_host],
        bastion_user:           opts[:bastion_user],
        bastion_port:           opts[:bastion_port],
        non_interactive:        opts[:non_interactive],
        transport_options:      opts,
      }
      # disable host key verification. The hash key and value to use
      # depends on the version of net-ssh in use.
      connection_options[verify_host_key_option] = verify_host_key_value(opts[:verify_host_key])

      connection_options
    end
953689
def rehash_options(opts)

      opts['Accept'] ||= (opts.delete(:accept) || 'application/json')
      opts['Accept'] = 'application/json' if opts['Accept'] == :json

      if ct = opts.delete(:content_type)
        opts['Content-Type'] = ct
      end
      if opts['Content-Type'] == :json
        opts['Content-Type'] = 'application/json'
      end

      if et = opts.delete(:etag)
        opts['If-None-Match'] = et
      end

      opts
    end
510412
def ssl_opts
      ssl_opts = OpenSSL::SSL::OP_ALL
      ssl_opts &= ~OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS if defined?(OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS)
      ssl_opts |= OpenSSL::SSL::OP_NO_COMPRESSION if defined?(OpenSSL::SSL::OP_NO_COMPRESSION)
      ssl_opts |= OpenSSL::SSL::OP_NO_SSLv2 if defined?(OpenSSL::SSL::OP_NO_SSLv2)
      ssl_opts |= OpenSSL::SSL::OP_NO_SSLv3 if defined?(OpenSSL::SSL::OP_NO_SSLv3)
      ssl_opts
    end
735765
def default_hash(env = ActiveRecord::ConnectionHandling::DEFAULT_ENV.call.to_s)
      default = find_db_config(env)
      default.config if default
    end
451087
def options=(options)
      fail ArgumentError, 'options must be a Hash. ' \
                          "#{ options.inspect } given." unless options.is_a?(Hash)

      @options.merge! options

      build_query
    end
832900
def connection(state = nil, &block)
      opts = merge_options(options, state || {})
      validate_options(opts)
      conn_opts = connection_options(opts)

      if @connection && @connection_options == conn_opts
        reuse_connection(&block)
      else
        create_new_connection(conn_opts, &block)
      end
    end
1519
def headers(h = nil)
      if h
        raise ArgumentError, 'Headers must be an object which responds to #to_hash' unless h.respond_to?(:to_hash)
        default_options[:headers] ||= {}
        default_options[:headers].merge!(h.to_hash)
      else
        default_options[:headers] || {}
      end
    end
125047
def to_hash
      Hash[options.reject(&:null?).map { |o| [o.key, o.value] }]
    end
868611
def concatenating_merge(options, options2, *args)
      options = call_each_hash_value_with_params(options, *args) || {}
      options2 = call_each_hash_value_with_params(options2, *args) || {}


      options.symbolize_keys.merge(options2.symbolize_keys) do |key, v1, v2|
        if v1.is_a?(String) && v2.is_a?(String)
          "#{v1} #{v2}"
        else
          v2
        end
      end
    end
188878
function formatOpts(opts) {
  opts = opts || {};
  // key
  opts.key = opts.key || 'koa:sess';

  // back-compat maxage
  if (!('maxAge' in opts)) opts.maxAge = opts.maxage;

  // defaults
  if (opts.overwrite == null) opts.overwrite = true;
  if (opts.httpOnly == null) opts.httpOnly = true;
  if (opts.signed == null) opts.signed = true;

  debug('session options %j', opts);

  // setup encoding/decoding
  if (typeof opts.encode !== 'function') {
    opts.encode = util.encode;
  }
  if (typeof opts.decode !== 'function') {
    opts.decode = util.decode;
  }

  const store = opts.store;
  if (store) {
    assert(is.function(store.get), 'store.get must be function');
    assert(is.function(store.set), 'store.set must be function');
    assert(is.function(store.destroy), 'store.destroy must be function');
  }

  const ContextStore = opts.ContextStore;
  if (ContextStore) {
    assert(is.class(ContextStore), 'ContextStore must be a class');
    assert(is.function(ContextStore.prototype.get), 'ContextStore.prototype.get must be function');
    assert(is.function(ContextStore.prototype.set), 'ContextStore.prototype.set must be function');
    assert(is.function(ContextStore.prototype.destroy), 'ContextStore.prototype.destroy must be function');
  }

  if (!opts.genid) {
    if (opts.prefix) opts.genid = () => opts.prefix + uid.sync(24);
    else opts.genid = () => uid.sync(24);
  }

  return opts;
}
10122
def parse_opts(opts_in, opts_defaults)
      diff_id = opts_in.keys - opts_defaults.keys
      raise ArgumentError, "Unrecognised argument(s): #{diff_id.join(", ")}" if diff_id.any?

      (opts_in.keys & opts_defaults.keys).each do |k|
        raise ArgumentError, "Argument #{k.to_s} must not be nil" if opts_defaults[k] == nil and opts_in[k] == nil
      end

      (opts_defaults.keys - opts_in.keys).each do |k|
        raise ArgumentError, "Argument #{k.to_s} must not be nil" if opts_defaults[k] == nil
        opts_in.merge!(k => opts_defaults[k])
      end
      opts_in
    end
708067
function(opts) {
      opts = opts || {};
      var path = opts.path || this.path,
          callback = opts.callback,
          method = opts.method || this.method,
          ws = getWebsocketPlugin(),
          transports = app.config.transports,
          self = this,
          i = 0,
          error,
          response;

      if (ws) {
        if (transports && transports.length > 0) {
          async.whilst(
            function () {
              return (i < transports.length);
            },
            function (done) {
              self.doConnect(transports[i], method, path, function (err, res) {
                error = err;
                response = res;
                if (!err && res) {
                  i = transports.length;
                } else {
                  i++;
                  if (i < transports.length) {
                    delete self.request;
                  }
                }
                done();
              });
            },
            function (err) {
              callback(err || error, response);
            }
          );
        } else {
          error = 'no transport available';
          log.error('%s %s', app.name, error);
          callback(error);
        }
      } else {
        this.doConnect('http', method, path, callback);
      }
      return this;
    }
500777
def opt_restore(prefix, opts):
    

    return {prefix + name: value for name, value in opts.items()}
620126
function getConfigOptions(opts) {
    opts = formatOptions(opts);
    _.forEach(config, function(value, key) {
      opts[key] = opts[key] || value;
    });
    opts.headers = opts.headers || {};

    return opts;
  }
1154219
def options
      map = Config.class_variables.map do |key|
        [key.to_s.tr('@', '').to_sym, class_variable_get(:"#{key}")]
      end
      Hash[map]
    end
1143056
function buildGet (opts) {
  // eslint-disable-next-line no-unused-vars
  const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
  /**
   * Perform a [get](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request
   *
   * @param {string} id - The document ID
   * @param {string} index - The name of the index
   * @param {string} type - The type of the document (use `_all` to fetch the first document matching the ID across all types)
   * @param {list} stored_fields - A comma-separated list of stored fields to return in the response
   * @param {string} parent - The ID of the parent document
   * @param {string} preference - Specify the node or shard the operation should be performed on (default: random)
   * @param {boolean} realtime - Specify whether to perform the operation in realtime or search mode
   * @param {boolean} refresh - Refresh the shard containing the document before performing the operation
   * @param {string} routing - Specific routing value
   * @param {list} _source - True or false to return the _source field or not, or a list of fields to return
   * @param {list} _source_excludes - A list of fields to exclude from the returned _source field
   * @param {list} _source_includes - A list of fields to extract and return from the _source field
   * @param {number} version - Explicit version number for concurrency control
   * @param {enum} version_type - Specific version type
   */

  const acceptedQuerystring = [
    'stored_fields',
    'parent',
    'preference',
    'realtime',
    'refresh',
    'routing',
    '_source',
    '_source_excludes',
    '_source_includes',
    'version',
    'version_type',
    'pretty',
    'human',
    'error_trace',
    'source',
    'filter_path'
  ]

  const snakeCase = {
    storedFields: 'stored_fields',
    _sourceExcludes: '_source_excludes',
    _sourceIncludes: '_source_includes',
    versionType: 'version_type',
    errorTrace: 'error_trace',
    filterPath: 'filter_path'
  }

  return function get (params, options, callback) {
    options = options || {}
    if (typeof options === 'function') {
      callback = options
      options = {}
    }
    if (typeof params === 'function' || params == null) {
      callback = params
      params = {}
      options = {}
    }

    // check required parameters
    if (params['id'] == null) {
      const err = new ConfigurationError('Missing required parameter: id')
      return handleError(err, callback)
    }
    if (params['index'] == null) {
      const err = new ConfigurationError('Missing required parameter: index')
      return handleError(err, callback)
    }
    if (params.body != null) {
      const err = new ConfigurationError('This API does not require a body')
      return handleError(err, callback)
    }

    // validate headers object
    if (options.headers != null && typeof options.headers !== 'object') {
      const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
      return handleError(err, callback)
    }

    var warnings = []
    var { method, body, id, index, type, ...querystring } = params
    querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)

    if (method == null) {
      method = 'GET'
    }

    var ignore = options.ignore
    if (typeof ignore === 'number') {
      options.ignore = [ignore]
    }

    var path = ''

    if ((index) != null && (type) != null && (id) != null) {
      path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id)
    } else {
      path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id)
    }

    // build request object
    const request = {
      method,
      path,
      body: null,
      querystring
    }

    options.warnings = warnings.length === 0 ? null : warnings
    return makeRequest(request, options, callback)
  }
}
522575
def connection opts={}
      connection = Faraday.new(opts) do |conn|

        if opts[:force_urlencoded]
          conn.request :url_encoded
        else
          conn.request :json
        end

        conn.request :json
        conn.use FaradayMiddleware::FollowRedirects
        conn.use FaradayMiddleware::Mashify
        conn.use FaradayMiddleware::ParseJson, :content_type => /\bjson$/
        conn.use FaradayMiddleware::ParseXml, :content_type => /\bxml$/
        conn.adapter adapter
      end

      connection.headers[:user_agent] = user_agent
      connection
    end