lib/http/base.js
function normalizeHeaders(headers)
{
  var ret = headers;

  if (Util.isObject(headers))
  {
    ret = {};

    // shallow copy the headers object and convert some headers like 'Accept'
    // and 'Content-Type' to lower case while copying; this is necessary
    // because the browser-request module, which we use to make http requests in
    // the browser, does not do case-insensitive checks when deciding whether to
    // insert default values for the 'accept' and 'content-type' headers; in
    // otherwise, if someone specifies an 'Accept': 'application/json' header,
    // browser-request will inject its own 'accept': 'application/json' header
    // and the browser XMLHttpRequest object will concatenate the two values and
    // send 'Accept': 'application/json, application/json' with the request
    var headerNameLowerCase;
    for (var headerName in headers)
    {
      if (headers.hasOwnProperty(headerName))
      {
        headerNameLowerCase = headerName.toLowerCase();
        if ((headerNameLowerCase === 'accept') ||
            (headerNameLowerCase === 'content-type'))
        {
          ret[headerNameLowerCase] = headers[headerName];
        }
        else
        {
          ret[headerName] = headers[headerName];
        }
      }
    }
  }

  return ret;
}
function normalizeHeaders(headers)
{
  var ret = headers;

  if (Util.isObject(headers))
  {
    ret = {};

    // shallow copy the headers object and convert some headers like 'Accept'
    // and 'Content-Type' to lower case while copying; this is necessary
    // because the browser-request module, which we use to make http requests in
    // the browser, does not do case-insensitive checks when deciding whether to
    // insert default values for the 'accept' and 'content-type' headers; in
    // otherwise, if someone specifies an 'Accept': 'application/json' header,
    // browser-request will inject its own 'accept': 'application/json' header
    // and the browser XMLHttpRequest object will concatenate the two values and
    // send 'Accept': 'application/json, application/json' with the request
    var headerNameLowerCase;
    for (var headerName in headers)
    {
      if (headers.hasOwnProperty(headerName))
      {
        headerNameLowerCase = headerName.toLowerCase();
        if ((headerNameLowerCase === 'accept') ||
            (headerNameLowerCase === 'content-type'))
        {
          ret[headerNameLowerCase] = headers[headerName];
        }
        else
        {
          ret[headerName] = headers[headerName];
        }
      }
    }
  }

  return ret;
}
function normalizeHeaders ( headers ) { var ret = headers ; if ( Util . isObject ( headers ) ) { ret = { } ; // shallow copy the headers object and convert some headers like 'Accept' // and 'Content-Type' to lower case while copying; this is necessary // because the browser-request module, which we use to make http requests in // the browser, does not do case-insensitive checks when deciding whether to // insert default values for the 'accept' and 'content-type' headers; in // otherwise, if someone specifies an 'Accept': 'application/json' header, // browser-request will inject its own 'accept': 'application/json' header // and the browser XMLHttpRequest object will concatenate the two values and // send 'Accept': 'application/json, application/json' with the request var headerNameLowerCase ; for ( var headerName in headers ) { if ( headers . hasOwnProperty ( headerName ) ) { headerNameLowerCase = headerName . toLowerCase ( ) ; if ( ( headerNameLowerCase === 'accept' ) || ( headerNameLowerCase === 'content-type' ) ) { ret [ headerNameLowerCase ] = headers [ headerName ] ; } else { ret [ headerName ] = headers [ headerName ] ; } } } } return ret ; }
Normalizes a request headers object so that we get the same behavior
regardless of whether we're using request.js or browser-request.js.

@param {Object} headers

@returns {Object}
Normalizes a request headers object so that we get the same behavior regardless of whether we re using request . js or browser - request . js .