@function
@public

Find value of header field in a stringified header.

@param {Object} header The stringified header
@param {string} field The header field to be searched for
@returns {Array | null} The result of the executed RegExp
540230
function getHeader (header, field) {
  const re = new RegExp(`(?:\\r\\n)${field}: *([a-zA-z0-9 /,:;=-]*)`, 'gi')
  return re.exec(header, field)
}
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;
    }
712747
function(field) {
  var converted = field.fieldId;
  converted.values = field.fieldValues;
  converted.sectionIndex = field.sectionIndex;
  return converted;
}
1178177
private Object getFieldValue(final Field field) {
        Object field_value = AccessController.doPrivileged(new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                try {
                    Object value = field.get(_member);

                    // Don't dump sensitive data
                    boolean sensitive = _member.getClass().isAnnotationPresent(Sensitive.class) || field.isAnnotationPresent(Sensitive.class);
                    if (value != null && sensitive) {
                        value = DataFormatHelper.sensitiveToString(value);
                    }

                    return value;
                } catch (IllegalAccessException e) {
                    // No FFDC code needed - we're in the middle of FFDC'ing!
                    // Should not happen - if it does return a string :-)
                    return "/* Could not access " + field.getName() + " */";
                }
            }
        });
        return field_value;
    }
802358
function extractParameters(header) {
  var SEPARATOR = /(?: |,)/g;
  var OPERATOR = /=/;

  return header.split(SEPARATOR).reduce(function (parameters, property) {
    var parts = property.split(OPERATOR).map(function (part) {
      return part.trim();
    });

    if (parts.length === 2)
      parameters[parts[0]] = parts[1];

    return parameters;
  }, {});
}
912550
public String getHeader(String header) {
        if (headers == null) {
            return null;
        }
        return headers.get(header);
    }
1072554
def _extract_header_value(line):
    

    # Skip blank lines, returning None
    if not line:
        return None

    # Attempt to split by equals sign
    halves = line.split('=')
    if len(halves) > 1:
        key = halves[0].strip()
        value = halves[1].strip()
        return {key: value}

    # Otherwise, attempt to split by colon
    else:
        halves = line.split(':')
        key = halves[0].strip()
        value = halves[1].strip()
        return {key: value}
1265789
def find_header(header)
      {}.tap do |returning|
        contents.scan(header_with_content_regexp(header)).flatten.first.split("\n").each do |setting|
          name, value = *setting.split('=').map(&:strip)
          returning[name] = value
        end
      end
    end
96849
function parseUnits (header) {
  if(isObject(header)) return header
  var m = /^(.+)\s+\(([^\)]+)\)$/.exec(header.trim())
  if(!m) return {name: header.trim()}
  return {name: m[1].trim(), units: m[2]}
}
137773
def parse_headers(self, req, name, field):
        """"""
        return get_value(req.headers, name, field)
312349
private static String getHeaderInfo(String name, String headerLine) {
        String[] fields = headerLine.split("[\t ]");
        for (String field : fields) {
            if (field.startsWith(name + "=")) {
                String[] subfields = field.split("=");
                return subfields[1];
            }
        }
        return null;
    }
1072396
def field_value(field)
      element = find_field(field)
      value = (element.tag_name == 'textarea') ? element.text : element.value
      # If field value is an Array, take the first item
      if value.class == Array
        value = value.first
      end
      return value.to_s
    end
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;
    }
370598
function matchKnownFields(field) {
  var low = false;
  while (true) {
    switch (field) {
      case 'Content-Type':
      case 'content-type':
        return 'content-type';
      case 'Content-Length':
      case 'content-length':
        return 'content-length';
      case 'User-Agent':
      case 'user-agent':
        return 'user-agent';
      case 'Referer':
      case 'referer':
        return 'referer';
      case 'Host':
      case 'host':
        return 'host';
      case 'Authorization':
      case 'authorization':
        return 'authorization';
      case 'Proxy-Authorization':
      case 'proxy-authorization':
        return 'proxy-authorization';
      case 'If-Modified-Since':
      case 'if-modified-since':
        return 'if-modified-since';
      case 'If-Unmodified-Since':
      case 'if-unmodified-since':
        return 'if-unmodified-since';
      case 'From':
      case 'from':
        return 'from';
      case 'Location':
      case 'location':
        return 'location';
      case 'Max-Forwards':
      case 'max-forwards':
        return 'max-forwards';
      case 'Retry-After':
      case 'retry-after':
        return 'retry-after';
      case 'ETag':
      case 'etag':
        return 'etag';
      case 'Last-Modified':
      case 'last-modified':
        return 'last-modified';
      case 'Server':
      case 'server':
        return 'server';
      case 'Age':
      case 'age':
        return 'age';
      case 'Expires':
      case 'expires':
        return 'expires';
      case 'Set-Cookie':
      case 'set-cookie':
        return '\u0001';
      case 'Cookie':
      case 'cookie':
        return '\u0002cookie';
      // The fields below are not used in _addHeaderLine(), but they are common
      // headers where we can avoid toLowerCase() if the mixed or lower case
      // versions match the first time through.
      case 'Transfer-Encoding':
      case 'transfer-encoding':
        return '\u0000transfer-encoding';
      case 'Date':
      case 'date':
        return '\u0000date';
      case 'Connection':
      case 'connection':
        return '\u0000connection';
      case 'Cache-Control':
      case 'cache-control':
        return '\u0000cache-control';
      case 'Vary':
      case 'vary':
        return '\u0000vary';
      case 'Content-Encoding':
      case 'content-encoding':
        return '\u0000content-encoding';
      case 'Origin':
      case 'origin':
        return '\u0000origin';
      case 'Upgrade':
      case 'upgrade':
        return '\u0000upgrade';
      case 'Expect':
      case 'expect':
        return '\u0000expect';
      case 'If-Match':
      case 'if-match':
        return '\u0000if-match';
      case 'If-None-Match':
      case 'if-none-match':
        return '\u0000if-none-match';
      case 'Accept':
      case 'accept':
        return '\u0000accept';
      case 'Accept-Encoding':
      case 'accept-encoding':
        return '\u0000accept-encoding';
      case 'Accept-Language':
      case 'accept-language':
        return '\u0000accept-language';
      case 'X-Forwarded-For':
      case 'x-forwarded-for':
        return '\u0000x-forwarded-for';
      case 'X-Forwarded-Host':
      case 'x-forwarded-host':
        return '\u0000x-forwarded-host';
      case 'X-Forwarded-Proto':
      case 'x-forwarded-proto':
        return '\u0000x-forwarded-proto';
      default:
        if (low)
          return '\u0000' + field;
        field = field.toLowerCase();
        low = true;
    }
  }
}
152422
function getStrictCheck(expectedHeader, caseSensitive, severity) {

	return function (content) {
		let actualHeader;
		if (caseSensitive) {
			actualHeader = content;
		} else {
			actualHeader = arrayToUpperCase(content);
			expectedHeader = arrayToUpperCase(expectedHeader);
		}

		if (expectedHeader.length !== actualHeader.length) {
			// If the length is different, it could not be the same
			return {
				errorCode: 'CHECK_HEADER_NO_STRICT_MATCH',
				severity: severity,
				message: 'The expected header [' + expectedHeader +
					'] has a different column count to the actual header [' + actualHeader +
					']'
			};
		} else {
			// no we need to compare field by field because the expected array could be an array of arrays
			// The expected header may contain alternative names for one column.
			for (let i = 0; i < expectedHeader.length; i++) {
				let match = false;
				const actualVal = actualHeader[i];
				let expectedVal = expectedHeader[i];
				if (Array.isArray(expectedVal)) {
					for (let j = 0; j < expectedVal.length; j++) {
						if (actualVal === expectedVal[j]) {
							match = true;
						}
					}
				} else {
					if (actualVal === expectedVal) {
						match = true;
					}
				}
				if (!match) {
					return {
						errorCode: 'CHECK_HEADER_NO_STRICT_MATCH',
						severity: severity,
						message: 'The expected header [' + expectedHeader +
							'] does not match the actual header [' +
							actualHeader +
							']'
					};
				}
			}
		}
	};
}
457650
private static String match(String headerLine, String token) {
    if (headerLine == null) {
      return null;
    }

    int match = headerLine.indexOf(token);
    if (match <= 0) {
      return null;
    }

    // = to skip
    match += token.length() + 1;
    int trailingComa = headerLine.indexOf(",", match);
    String value = headerLine.substring(match, trailingComa > 0 ? trailingComa : headerLine.length());
    value = value.length() > 0 && value.charAt(value.length() - 1) == '"'
            ? value.substring(0, value.length() - 1)
            : value;
    return value.charAt(0) == '"' ? value.substring(1) : value;
  }
757779
private String getSimpleHeaderValue(String header, HttpResponse httpResponse, boolean first) {
    if (StringUtils.isBlank(header)) {
      return StringUtils.EMPTY;
    }

    Header h;
    if (first) {
      h = httpResponse.getFirstHeader(header);
    } else {
      h = httpResponse.getLastHeader(header);
    }
    if (h == null) {
      return null;
    }
    return h.getValue();
  }