In case there's more than one header of a given name, we want the first one as it should be the one that was added by the first proxy in the chain
978689
function getFirstHeader (req, header) {
  const value = req.headers[header]
  return (Array.isArray(value) ? value[0] : value).split(', ')[0]
}
1182605
public Object getFirstHeader( String name )
    {
        List foundHeaders = ( List ) _headers.get( name );
        return ! foundHeaders.isEmpty() ? foundHeaders.get( 0 ) : null;
    }
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
450910
public void addHeaders(HttpServletRequest reqSource, HttpRequestBase httpTarget)
    {
    	Enumeration<?> headerNames = reqSource.getHeaderNames();
    	while (headerNames.hasMoreElements())
    	{
    		String key = headerNames.nextElement().toString();
    		if (CONTENT_LENGTH.equalsIgnoreCase(key))
    			continue;	// Length will be different
    		Enumeration<?> headers = reqSource.getHeaders(key);
    		while (headers.hasMoreElements())
    		{
    			String value = (String)headers.nextElement();
    			if (HOST.equalsIgnoreCase(key))
    			{
    				value = proxyURLPrefix;
    				if (value.indexOf(":") != -1)
    				{
    					value = value.substring(value.indexOf(":") + 1);
    					while (value.startsWith("/"))
    					{
    						value = value.substring(1);
    					}
    				}
    				if (value.indexOf("/") != -1)
    					value = value.substring(0, value.indexOf("/"));
    			}
    			httpTarget.setHeader(new BasicHeader(key, value));
    		}
    	}
    }
302117
function indexifyName(name, scope) {
	const variables = scope.variableScope.set;

	let index = 1;
	while (variables.has(index === 1 ? name : name + index)) {
		index++;
	}

	return name + (index === 1 ? '' : index);
}
1000512
def _ensure_request_id_header(self):
        ""
        if REQUEST_ID_HEADER not in self.request.headers:
            self.request.headers.add(REQUEST_ID_HEADER, uuid.uuid1().hex)
1306088
def last_first(self):
        
        return "{}, {} ".format(self.last_name, self.first_name) + ("({})".format(self.nickname) if self.nickname else "")
601477
def remove_header(self, name):
        """"""
        if name in self.info_dict:
            self.info_dict.pop(name)
            logger.info("Removed '{0}' from INFO".format(name))
        if name in self.filter_dict:
            self.filter_dict.pop(name)
            logger.info("Removed '{0}' from FILTER".format(name))
        if name in self.format_dict:
            self.format_dict.pop(name)
            logger.info("Removed '{0}' from FORMAT".format(name))
        if name in self.contig_dict:
            self.contig_dict.pop(name)
            logger.info("Removed '{0}' from CONTIG".format(name))
        if name in self.alt_dict:
            self.alt_dict.pop(name)
            logger.info("Removed '{0}' from ALT".format(name))
        if name in self.other_dict:
            self.other_dict.pop(name)
            logger.info("Removed '{0}' from OTHER".format(name))
        return
1181072
public String getFirstHeader(String name) {
        List<String> headerValues = getHeader(name);

        if (headerValues == null || headerValues.size() == 0) {
            return null;
        }

        return headerValues.get(0);
    }
246038
def add_header(self, header):
        
        if header.personalization is not None:
            try:
                personalization = \
                    self._personalizations[header.personalization]
                has_internal_personalization = True
            except IndexError:
                personalization = Personalization()
                has_internal_personalization = False
            if isinstance(header, dict):
                (k, v) = list(header.items())[0]
                personalization.add_header(Header(k, v))
            else:
                personalization.add_header(header)

            if not has_internal_personalization:
                self.add_personalization(
                    personalization,
                    index=header.personalization)
        else:
            if isinstance(header, dict):
                (k, v) = list(header.items())[0]
                self._headers = self._ensure_append(
                                    Header(k, v), self._headers)
            else:
                self._headers = self._ensure_append(header, self._headers)
1034269
def make_headers(headers):
    
    out = {}
    if 'etag' in headers:
        out['if-none-match'] = headers['etag']
    if 'last-modified' in headers:
        out['if-modified-since'] = headers['last-modified']
    return out
835492
public static function matchHeaders(Request $first, Request $second)
    {
        // Use array_filter to ignore headers which are null.

        return array_filter($first->getHeaders()) === array_filter($second->getHeaders());
    }
1134434
public PactDslRequestWithPath matchHeader(String header, String regex, String headerExample) {
        requestMatchers.addCategory("header").setRule(header, new RegexMatcher(regex));
        requestHeaders.put(header, Collections.singletonList(headerExample));
        return this;
    }
1293601
private static Map<String, String> getOrderedHeadersToSign(Header[] headers) {
        Map<String, String> unique = new TreeMap<>();
        for (Header header : headers) {
            String key = header.getName().toLowerCase(Locale.US).trim();
            if (key.equals("connection")) {
                // do not sign 'connection' header, it is very likely to be changed en-route.
                continue;
            }
            String value = header.getValue();
            if (value == null) {
                value = "";
            } else {
                // minimize white space
                value = value.trim().replaceAll("\\s+", " ");
            }
            // merge all values with same header name
            String prior = unique.get(key);
            if (prior != null) {
                if (prior.length() > 0) {
                    value = prior + ',' + value;
                }
                unique.put(key, value);
            } else {
                unique.put(key, value);
            }
        }
        return unique;
    }
900368
def link(self, thing1, thing2):
		
		thing1 = thing1.strip().lower()
		thing2 = thing2.strip().lower()
		if thing1 == thing2:
			raise SameName("Attempted to link two of the same name")
		self.change(thing1, 0)
		self.change(thing2, 0)
		return self._link(thing1, thing2)
500464
def header(self, name, value):
        
        self.message += "{}: {}\r\n".format(name, value)
        logger.debug('<{}> Received {} header'.format(self.id, name))
        if name.lower().startswith(self.header_prefix.lower()):
            self.remove_headers.append(name)
            logger.debug('<{}> Going to remove {} header'.format(
                self.id, name))
        return Milter.CONTINUE
975624
def set_header(self, name: str, value: _HeaderTypes) -> None:
        
        self._headers[name] = self._convert_header_value(value)