Finds best match

@param supported the supported types
@param header    the header
@return the best match
346289
public static String bestMatch(Collection<String> supported, String header) {
        List<ParseResults> parseResults = new LinkedList<>();
        List<FitnessAndQuality> weightedMatches = new LinkedList<>();
        for (String r : header.split(",")) {
            parseResults.add(parseMediaRange(r));
        }

        for (String s : supported) {
            FitnessAndQuality fitnessAndQuality = fitnessAndQualityParsed(s, parseResults);
            fitnessAndQuality.mimeType = s;
            weightedMatches.add(fitnessAndQuality);
        }
        Collections.sort(weightedMatches);

        FitnessAndQuality lastOne = weightedMatches.get(weightedMatches.size() - 1);
        return Float.compare(lastOne.quality, 0) != 0 ? lastOne.mimeType : NO_MIME_TYPE;
    }
912550
public String getHeader(String header) {
        if (headers == null) {
            return null;
        }
        return headers.get(header);
    }
1158583
private String getSimpleHeaderValue(String header, HttpResponse httpResponse) {
    return getSimpleHeaderValue(header, httpResponse, true);
  }
1324101
protected List<HString> longestMatchFirst(@NonNull HString source) {
      List<HString> results = new LinkedList<>();
      List<Annotation> tokens = source.tokens();
      Predicate<HString> prefix = (this instanceof PrefixSearchable)
                                  ? Cast.<PrefixSearchable>as(this)::isPrefixMatch
                                  : h -> true;

      for (int i = 0; i < tokens.size(); ) {
         Annotation token = tokens.get(i);
         if (prefix.test(token)) {

            LexiconMatch bestMatch = null;
            for (int j = i + 1; j <= tokens.size() && j < (i + 1 + longestLemma); j++) {
               HString temp = HString.union(tokens.subList(i, j));
               List<LexiconEntry> entries = getEntries(temp);
               if (entries.size() > 0) {
                  bestMatch = new LexiconMatch(temp, entries.get(0));
               }
               if (!prefix.test(temp)) {
                  break;
               }
            }

            if (bestMatch != null) {
               results.add(createFragment(bestMatch));
               i += bestMatch.getSpan().tokenLength();
            } else {
               i++;
            }

         } else if (test(token)) {
            results.add(createFragment(new LexiconMatch(token, getEntries(token).get(0))));
            i++;
         } else {
            i++;
         }
      }

      return results;
   }
982624
public HttpClientVerifyBuilder withHeader(String header, Matcher<String> matcher) {
        ruleBuilder.addCondition(new HeaderCondition(header, matcher));
        return this;
    }
195422
private static Map<String, String> convertHeaders(Header[] headers) {
        Map<String, String> result = new HashMap<String, String>(headers.length);
		for (Header header : headers) {
			result.put(header.getName(), header.getValue());
		}
        return result;
    }
1204081
public boolean isFilterMatch(BaseMessageHeader messageHeader)
    {
        boolean bMatch = super.isFilterMatch(messageHeader);
        if (bMatch)
        {
            if (!(messageHeader instanceof RecordMessageHeader))
                return false;   // Never
            if (m_iDatabaseType != -1)
                if (m_iDatabaseType != ((RecordMessageHeader)messageHeader).getDatabaseType())
                    return false;   // No match
        }
        return bMatch;  // Match
    }
169581
public List<String> getValuesList(HttpHeader header) {
        final List<String> list = new ArrayList<>();
        for (HttpField f : this)
            if (f.getHeader() == header)
                list.add(f.getValue());
        return list;
    }
694267
@Override
    public boolean accepts(String mimeType) {
        String contentType = request.headers().get(HeaderNames.ACCEPT);
        if (contentType == null) {
            contentType = MimeTypes.HTML;
        }
        // For performance reason, we first try a full match:
        if (contentType.contains(mimeType)) {
            return true;
        }
        // Else check the media types:
        MediaType input = MediaType.parse(mimeType);
        for (MediaType type : mediaTypes()) {
            if (input.is(type)) {
                return true;
            }
        }
        return false;
    }
831324
public OkRequest<T> headers(final Map<String, String> headers) {
        if (!headers.isEmpty())
            for (Map.Entry<String, String> header : headers.entrySet())
                header(header);
        return this;
    }
520721
public function getBest($header, array $priorities)
    {
        if (empty($priorities) || !$header) {
            return null;
        }

        // Once upon a time, two `array_map` calls were sitting there, but for
        // some reasons, they triggered `E_WARNING` time to time (because of
        // PHP bug [55416](https://bugs.php.net/bug.php?id=55416). Now, they
        // are gone.
        // See: https://github.com/willdurand/Negotiation/issues/81
        $acceptedHeaders = [];
        foreach ($this->parseHeader($header) as $h) {
            $acceptedHeaders[] = $this->pareseAccept($h);
        }
        $acceptedPriorities = [];
        foreach ($priorities as $p) {
            $acceptedPriorities[] = $this->pareseAccept($p);
        }
        $matches = $this->findMatches($acceptedHeaders, $acceptedPriorities);
        $specificMatches = \array_reduce($matches, 'self::reduce', []);

        \usort($specificMatches, 'self::compare');

        $match = $specificMatches[0];

        return null === $match ? null : $acceptedPriorities[$match->index]['value'];
    }
501769
def search_upper_header(hdr)
      hdr.class.known_headers.each do |nh, bindings|
        return nh if bindings.check?(hdr)
      end

      nil
    end
715216
public boolean contains( String name )
    {
        for ( Header header : headers ) {
            if ( header.getName().equals( name ) ) {
                return true;
            }
        }
        return false;
    }
9590
public static String getHeader(HttpServletRequest request, String header) {

		// noting to search in or nothing to be found
		if (request == null || StringUtils.isNullOrEmptyTrimmed(header)) {
			return null;
		}

		return request.getHeader(header);
	}
821290
public OkRequest<T> header(final Map.Entry<String, String> header) {
        return header(header.getKey(), header.getValue());
    }
410315
public static <T> DecomposableMatchBuilder0<List<T>> headNil(MatchesExact<T> head) {
    List<Matcher<Object>> matchers = Lists.of(ArgumentMatchers.eq(head.t));
    return new DecomposableMatchBuilder0<List<T>>(matchers, new ListConsHeadFieldExtractor<>());
  }
860073
public PactDslRequestWithPath matchHeader(String header, String regex) {
        return matchHeader(header, regex, new Generex(regex).random());
    }