Substitutes atx headers (headers defined using #'s).
430951
def atx_header_sub(match):
    """"""
    level = len(match.group(1))
    title = match.group(2)

    id_class = ''
    ids = match.group(3) if match.group(3) else ''
    id_match = re.search('#([\w-]+)', ids)
    if id_match:
        id_class += ' id="' + id_match.group(1) + '"'
    classes = ' '.join(re.findall('\.([\w-]+)', ids))
    if classes:
        id_class += ' class="' + classes + '"'
    return '\n<h{0}{2}>{1}</h{0}>\n'.format(level, title, id_class)
185668
def parse_headers_link(headers):
    """"""

    header = CaseInsensitiveDict(headers).get('link')

    l = {}

    if header:
        links = parse_link(header)

        for link in links:
            key = link.get('rel') or link.get('url')
            l[key] = link

    return l
815479
def set_headers(self, headers):
        
        self.headers = []
        if 'order' in self.options:
            for element in self.options['order']:
                for header in headers:
                    if header['key'] == element:
                        self.headers.append(header)
                        break
        else:
            self.headers = headers
600558
protected void substituteSymbols(Map<String, String> initProps) {
        for (Entry<String, String> entry : initProps.entrySet()) {
            Object value = entry.getValue();
            if (value instanceof String) {
                String strValue = (String) value;
                Matcher m = SYMBOL_DEF.matcher(strValue);
                int i = 0;
                while (m.find() && i++ < 4) {
                    String symbol = m.group(1);
                    Object expansion = initProps.get(symbol);
                    if (expansion != null && expansion instanceof String) {
                        strValue = strValue.replace(m.group(0), (String) expansion);
                        entry.setValue(strValue);
                    }
                }
            }
        }
    }
412694
function Headers(headers) {
	            var _this = this;
	            /** @internal header names are lower case */
	            this._headers = new Map();
	            /** @internal map lower case names to actual names */
	            this._normalizedNames = new Map();
	            if (!headers) {
	                return;
	            }
	            if (headers instanceof Headers) {
	                headers._headers.forEach(function (values, name) {
	                    values.forEach(function (value) { return _this.append(name, value); });
	                });
	                return;
	            }
	            Object.keys(headers).forEach(function (name) {
	                var values = Array.isArray(headers[name]) ? headers[name] : [headers[name]];
	                _this.delete(name);
	                values.forEach(function (value) { return _this.append(name, value); });
	            });
	        }
152445
def headers_as_dict(cls, resp):
        """"""
        if six.PY2:
            pairs = [header.split(':', 1) for header in resp.msg.headers]
            return dict([(k, v.strip()) for k, v in pairs])
        else:
            return dict([(k, v.strip()) for k, v in resp.msg._headers])
675835
def prepare_headers(self, headers):
        """"""

        if headers:
            self.headers = CaseInsensitiveDict((to_native_string(name), value) for name, value in headers.items())
        else:
            self.headers = CaseInsensitiveDict()
534130
def _escape_headers(self, headers):
        
        for key, val in headers.items():
            try:
                val = val.replace('\\', '\\\\').replace('\n', '\\n').replace(':', '\\c').replace('\r', '\\r')
            except:
                pass
            headers[key] = val
1294522
function canonicalizeHeaders (headers) {
  var buf = []
    , fields = Object.keys(headers)
    ;
  for (var i = 0, len = fields.length; i < len; ++i) {
    var field = fields[i]
      , val = headers[field]
      , field = field.toLowerCase()
      ;
    if (0 !== field.indexOf('x-amz')) continue
    buf.push(field + ':' + val)
  }
  return buf.sort().join('\n')
}
608064
def header(self, item0, *items):
        
        self.txt(item0)
        at_x = None
        for item in items:
            if at_x is None:
                at_x = item
            else:
                self.txt(item, at_x=at_x)
                at_x = None
637411
public function header($header, $value, $replace = true)
    {
        $this->headers[] = array($header, $value, $replace);
    }
47108
private Header[] combineHeaders(NameValuePair[] headers) {

        Header[] fullHeaders = new Header[this.headers.size() + headers.length];

        // Add class-level headers (for all requests)
        for (int i = 0; i < this.headers.size(); i++) {
            fullHeaders[i] = this.headers.get(i);
        }

        // Add headers specific to this request:
        for (int i = 0; i < headers.length; i++) {
            NameValuePair header = headers[i];
            fullHeaders[i + this.headers.size()] = new BasicHeader(header.getName(), header.getValue());
        }

        //System.out.println(Arrays.toString(fullHeaders));
        return fullHeaders;
    }
840514
function headers(buffer) {
    var head = {};
    if (buffer[0] === 0x89 && buffer[1] === 0x50 && buffer[2] === 0x4E &&
        buffer[3] === 0x47 && buffer[4] === 0x0D && buffer[5] === 0x0A &&
        buffer[6] === 0x1A && buffer[7] === 0x0A) {
        head['Content-Type'] = 'image/png';
    } else if (buffer[0] === 0xFF && buffer[1] === 0xD8 &&
        buffer[buffer.length - 2] === 0xFF && buffer[buffer.length - 1] === 0xD9) {
        head['Content-Type'] = 'image/jpeg';
    } else if (buffer[0] === 0x47 && buffer[1] === 0x49 && buffer[2] === 0x46 &&
        buffer[3] === 0x38 && (buffer[4] === 0x39 || buffer[4] === 0x37) &&
        buffer[5] === 0x61) {
        head['Content-Type'] = 'image/gif';
    } else if (buffer[0] === 0x52 && buffer[1] === 0x49 && buffer[2] === 0x46 && buffer[3] === 0x46 &&
        buffer[8] === 0x57 && buffer[9] === 0x45 && buffer[10] === 0x42 && buffer[11] === 0x50) {
        head['Content-Type'] = 'image/webp';
    // deflate: recklessly assumes contents are PBF.
    } else if (buffer[0] === 0x78 && buffer[1] === 0x9C) {
        head['Content-Type'] = 'application/x-protobuf';
        head['Content-Encoding'] = 'deflate';
    // gzip: recklessly assumes contents are PBF.
    } else if (buffer[0] === 0x1F && buffer[1] === 0x8B) {
        head['Content-Type'] = 'application/x-protobuf';
        head['Content-Encoding'] = 'gzip';
    }
    return head;
}
274293
def add_conditional_headers(req, opts)

      # if path is cached send since and/or match

      e = @cache[opts[:c_uri]]

      return unless e # not cached

      req['If-Modified-Since'] = e.lastmod if e.lastmod
      req['If-None-Match'] = e.etag if e.etag

      opts[:c_cached] = e
    end
1181599
private function fixHeaders($headers) {
		$retval = NULL;
		if ($headers != NULL) {
			$retval = array();
			$index = 0;
			foreach ($headers as $key => $value) {
				$retval[$index] = array('Name' => $key, 'Value' => $value);
				$index++;
			}
		}
		return $retval;
	}
1222190
function filterSensitiveHeaders(headers, sensitiveKeys) {
    try {
        const retval = {};
        for (const key in headers) {
            if (sensitiveKeys.findIndex(item => key.toLowerCase() === item.toLowerCase()) === -1) {
                retval[key] = headers[key];
            }
        }
        return retval;
    } catch(e) {
        return headers;
    }
}
648592
def headers
      new_h = {}
      headers_orig.each_pair do |k, v|
        if v.is_a?(Array) && v.size == 1
          v = v[0]
        end
        new_h[k.downcase] = v
      end
      new_h
    end