XMLHttpRequest returns a not very usable single big string with all headers
495020
function (headers) {
      var parsed = {};

      if (headers) {
        headers = headers.trim().split("\n");
        for (var h in headers) {
          if (headers.hasOwnProperty(h)) {
            var header = headers[h].match(/([^:]+):(.*)/);
            parsed[header[1].trim().toLowerCase()] = header[2].trim();
          }
        }
      }
      return parsed;
    }
607198
static function stripHTTPHeader( $data )
    {
        // Look for CR/LF or simple LF as line separator,
        // (even though it is not valid http)
        $pos = strpos($data,"\r\n\r\n");
        if( $pos || is_int( $pos ) )
        {
            $bd = $pos+4;
        }
        else
        {
            $pos = strpos( $data, "\n\n" );
            if( $pos || is_int( $pos ) )
            {
                $bd = $pos+2;
            }
            else
            {
                // No separation between response headers and body: fault?
                $bd = 0;
            }
        }
        if ($bd)
        {
            // this filters out all http headers from proxy.
            // maybe we could take them into account, too?
            return substr( $data, $bd );
        }
        else
        {
            //error_log('XML-RPC: xmlrpcmsg::parseResponse: HTTPS via proxy error, tunnel connection possibly failed');
            //$r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $GLOBALS['xmlrpcstr']['http_error']. ' (HTTPS via proxy error, tunnel connection possibly failed)');
            return $data;
        }
    }
96921
private void setHeaders(XMLHttpRequest xmlHttpRequest) throws RequestException {

        if ((headers != null) && (headers.size() > 0)) {
            for (Map.Entry<String, String> header : headers.entrySet()) {
                try {
                    xmlHttpRequest.setRequestHeader(header.getKey(), header.getValue());
                } catch (JavaScriptException e) {
                    throw new RequestException(e.getMessage());
                }
            }
        } else {
            xmlHttpRequest.setRequestHeader("Content-Type", "text/plain; charset=utf-8");
        }
    }
858703
function createXMLHTTPObject () {
  var xmlhttp = false
  for (var i = 0; i < XMLHttpFactories.length; i++) {
    try {
      xmlhttp = XMLHttpFactories[i]()
    } catch (e) {
      continue
    }
    break
  }
  return xmlhttp
}
94181
function parseHttpHeaders(headers) {
    var meta = {};
    
    for (var headerName in headers) {
        var headerValue = headers[headerName];
        
        if (headerName=="x-ratelimit-limit") {
            meta.rateLimit = headerValue;
        } else if (headerName=="x-ratelimit-remaining") {
            meta.rateLimitRemaining = headerValue;
        } else if (headerName=="x-ratelimit-reset") {
            meta.rateLimitReset = headerValue;
        } else if (headerName=="link") {
            var regexp = /<(.+)>; rel=(.+),?/g;
            var match;
            do {
                match = regexp.exec(headerValue);
                if (match) {
                    var url = match[1];
                    var rel = match[2];
                    
                    var regexp2 = /[\?|&]page=(\d+)/;
                    var match2 = regexp2.exec(url);
                    if (match2) {
                        var page = match2[1];
                        if (rel=='prev') {
                            meta.prevPage = page;
                        } else if (rel=='next') {
                            meta.nextPage = page;
                        } else if (rel=='last') {
                            meta.lastPage = page;
                        }
                    }
                }
            } while (match);
        } 
    }
    
    return meta;
}
1356798
function request(opts, cb) {
  opts = opts || {};
  opts.method = opts.method || 'GET';
  opts.headers = opts.headers || {};

  var req
    , z;

  /* jshint ignore:start */
  req = new XMLHttpRequest();
  /* jshint ignore:end */

  /**
   *  Parse response headers into an object.
   */
  function parse(headers) {
    var output = {}, i, p, k, v;
    headers = headers || '';
    headers = headers.replace('\r', '');
    headers = headers.split('\n');
    for(i = 0;i < headers.length;i++) {
      p = headers[i].indexOf(':');
      k = headers[i].substr(0, p);
      v = headers[i].substr(p + 1);
      if(k && v) {
        k = k.replace(/^\s+/, '').replace(/\s+$/, '');
        v = v.replace(/^\s+/, '').replace(/\s+$/, '');
        output[k.toLowerCase()] = v;
      }
    }
    return output;
  }

  function done() {
    req.onload = null;
    req.onerror = null;
    req.ontimeout = null;
    req.onprogress = null;
    cb.apply(null, arguments); 
  }

  if(opts.fields) {
    for(z in opts.fields) {
      req[z] = opts.fields[z];
    }
  }

  opts.headers['X-Requested-With'] = 'XMLHttpRequest';

  if(opts.json) {
    opts.headers['Content-Type'] = 'application/json';
    if(opts.body !== undefined) {
      opts.body = JSON.stringify(opts.body); 
    }
  }

  var url = opts.url;

  if(opts.qs) {
    var keys = Object.keys(opts.qs)
      , qs = '?';
    keys.forEach(function(key, index) {
      if(index) {
        qs += '&'; 
      }
      qs += encodeURIComponent(key) + '=' + encodeURIComponent(opts.qs[key]); 
    })

    url += qs;
  }

  req.open(opts.method, url);

  // sadly IE10/11 does not support `json` response type
  // see: http://caniuse.com/#feat=xhr2
  if(opts.responseType) {
    req.responseType = opts.responseType; 
  }

  // apply custom request headers
  for(z in opts.headers) {
    req.setRequestHeader(z, opts.headers[z]);
  }

  if(opts.mime && typeof(req.overrideMimeType) === 'function') {
    req.overrideMimeType(opts.mime);
  }

  req.onreadystatechange = function() {
    if(this.readyState === 4) {

      var res = opts.responseType ? this.response : this.responseText
        , info = {
            headers: parse(this.getAllResponseHeaders()),
            status: this.status
          };

      info.body = res;
      if(res && opts.json && (this.status === 200 || this.status === 201)) {
        try {
          info.body = JSON.parse(this.responseText);
        }catch(e) {
          return done(
            e,
            info,
            this);
        }
      }
      done(
        null,
        info,
        this);
    }
  }

  req.onerror = opts.error || function onError(err) {
    done(err);
  }

  req.onload = opts.load;
  req.ontimeout = opts.timeout;
  req.onprogress = opts.progress;

  req.send(opts.body);
}
1302902
function(xhr) {
    var response = {
        headers: {},
        statusCode: xhr.status
    };

    var headerPairs = xhr.getAllResponseHeaders().split('\u000d\u000a');
    for (var i = 0; i < headerPairs.length; i++) {
        var headerPair = headerPairs[i],
            index = headerPair.indexOf('\u003a\u0020');

        if (index > 0) {
            var key = headerPair.substring(0, index);
            var val = headerPair.substring(index + 2);
            response.headers[key.toLowerCase()] = val;
        }
    }

    return response;
}
1321677
def _get_body_string(self):
        
        clen = self.content_length
        if clen > self.MEMFILE_MAX:
            raise HTTPError(413, 'Request entity too large')
        if clen < 0: clen = self.MEMFILE_MAX + 1
        data = self.body.read(clen)
        if len(data) > self.MEMFILE_MAX:  # Fail fast
            raise HTTPError(413, 'Request entity too large')
        return data
700888
function(req, res, next) {
    // If we timed out before managing to respond, don't send the response
    if (res.headersSent) {
      return;
    }

    // Look for `.json` or `.xml` extension in path
    // And override request accept header
    if (/.json$/.test(req.path)) {
      req.headers.accept = 'application/json';
    } else if (/.xml$/.test(req.path)) {
      req.headers.accept = 'application/xml';
    }

    // Use request accept header to determine response content-type
    res.format({
      json: function() {
        res.status(res.code).jsonp(res.data);
      },
      xml: function() {
        var xml;
        try {
          var xmlData = JSON.parse(JSON.stringify(res.data));
          xml = this.xmlBuilder.buildObject(xmlData);
          res.set('Content-Type', 'application/xml; charset=utf-8');
          res.status(res.code).send(xml);
        } catch (e) {
          res.status(500).end();
        }
      }.bind(this)
    });
  }
962563
function (options) {
    // Parse a string representing a file size and convert it into bytes.
    // A number on it's own will be assumed to be bytes. A multiple such as
    // "k" or "m" can be appended to the string to handle larger numbers. This
    // is case insensitive and uses powers of 1024 rather than (1000).
    // So both 1kB and 1kb == 1024.
    function parseLimit(string) {
      var matches = ('' + string).toLowerCase().match(regexp),
          bytes = null, power;

      if (matches) {
        bytes = parseFloat(matches[1]);
        power = powers[matches[2]];

        if (bytes && power) {
          bytes = Math.pow(bytes * 1024, power);
        }
      }

      return bytes || null;
    }

    var powers = { k: 1, m: 2, g: 3, t: 4 },
        regexp = /^(\d+(?:.\d+)?)\s*([kmgt]?)b?$/,
        limit  = options && parseLimit(options.limit);

    return function (req, res, next) {
      if (limit) {
        var contentLength = parseInt(req.header('Content-Length', 0), 10),
            message = 'Sorry, the content you have uploaded is larger than JS Bin can handle. Max size is ' + options.limit;

        if (limit && contentLength > limit) {
          return next(new errors.RequestEntityTooLarge(message));
        }
      }
      next();
    };
  }
525112
function(xhr, req) {
  var data = xhr.responseText || ''
    , status = +xhr.status
    , headers = {};

  if (status === 1223) status = 204;

  (xhr.getAllResponseHeaders() || '').replace(
    /(?:\r?\n|^)([^:\r\n]+): *([^\r\n]+)/g, 
    function($0, $1, $2) {
      headers[$1.toLowerCase()] = $2;
    }
  );

  this.rawBody = data;

  var type = headers['content-type'];
  if (type) {
    if (~type.indexOf('html')) {
      data = DOM(data);
    } else if (~type.indexOf('json')) {
      try {
        data = JSON.parse(data);
      } catch(e) {
        data = {};
        this._error = true;
      }
    } else if (~type.indexOf('javascript') && io.eval) {
      var script = document.createElement('script');
      DOM.setText(script, data);
      head.insertBefore(script, head.firstChild);
      data = null;
    }
  }

  this.url = req.url;
  this.statusCode = status;
  this.headers = headers;
  this.body = data;
}
1265747
function(name) {
    var header = this.headers[Utils.headerize(name)];

    if(header) {
      if(header[0]) {
        return header[0].raw;
      }
    } else {
      return;
    }
  }
978930
function parseHeaders(headers) {
  var parsed = createMap(), i;

  function fillInParsed(key, val) {
    if (key) {
      parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
    }
  }

  if (isString(headers)) {
    forEach(headers.split('\n'), function(line) {
      i = line.indexOf(':');
      fillInParsed(lowercase(trim(line.substr(0, i))), trim(line.substr(i + 1)));
    });
  } else if (isObject(headers)) {
    forEach(headers, function(headerVal, headerKey) {
      fillInParsed(lowercase(headerKey), trim(headerVal));
    });
  }

  return parsed;
}
23698
function(text) {
			var result = text;
			try {
				switch (this._headers.Accept) {
					case "application/json":
						result = JSON.parse(text);
						break;
					case "text/xml":
						result = new DOMParser().parseFromString(text, "text/xml");
						break;
				}
			} catch (exception) {
				if (gui.debug) {
					console.error(
						this._headers.Accept + " dysfunction at " + this._url
					);
				}
			}
			return result;
		}
329735
private static function getHeadersFromInput ()
	{
		// getallheaders available, use that
		if (function_exists('getallheaders')) return getallheaders();

		// getallheaders not available: manually extract 'm
		$headers = [];
		foreach ($_SERVER as $name => $value)
		{
			if (substr($name, 0, 5) == 'HTTP_') {
			    $key = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))));
				$headers[$key] = $value;
			} else if (strtolower (substr ($name, 0, 7)) == 'content') {
                $key = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', $name))));
				$headers[$key] = $value;
			}
		}
		return $headers;
	}
1056953
function parseHeaders(headerString) {
	var headers = {};
	var headersArray = headerString.split(/[\r\n]+/);
	headersArray.forEach(function (headerString) {
		var headerChunks = headerString.split(':');
		headers[headerChunks.shift().trim()] = headerChunks.join(':').trim();
	});
	return headers;
}
610034
String debugGetAllHttpHdrs(HttpServletRequest req) {
        if (req == null)
            return null;
        StringBuffer sb = new StringBuffer(512);
        Enumeration<String> headerNames = req.getHeaderNames();
        while (headerNames != null && headerNames.hasMoreElements()) {
            String headerName = headerNames.nextElement();
            sb.append(headerName).append("=");
            sb.append("[").append(SRTServletRequestUtils.getHeader(req, headerName)).append("]\n");
        }
        return sb.toString();
    }