func checkHeaderRegexContext(m *Match, tc *TestCase) (bool, error) {
	var success bool
	var actualHeader string
	for head := range tc.Header {
		success = strings.EqualFold(head, m.Header)
		if success {
			actualHeader = head
			break
		}
	}
	headerValue := tc.Header.Get(actualHeader)
	regex, err := regexp.Compile(m.Regex)
	if err != nil {
		return false, err
	}
	result := regex.FindStringSubmatch(headerValue)
	if len(result) < 2 {
		return false, m.AppErr(fmt.Sprintf("Header Regex Context Match Failed - regex (%s) failed to find anything on Header (%s) value (%s)", m.Regex, m.Header, headerValue))
	}
	m.Result = result[1]
	return success, nil
}
// Allows capturing of a regex subfield expression in a header
// For example with the following location header
// "Location:https://x.y.z/auth?code=12345&redir=https://redir"
// using the following match:
//{
//	"name": "xchange_code",
//	"description": "Get the xchange code from the location redirect",
//	"header": "Location",
//	"regex": "code=(.*)&?.*"
//  }
//
// Will extract the value of code "12345" and make it available in the match m.Result field
//


Will extract the value of code "12345" and make it available in the match m.Result field
// Allows capturing of a regex subfield expression in a header // For example with the following location header // " Location : https : // x . y . z / auth?code = 12345&redir = https : // redir " // using the following match : // { // " name " : " xchange_code " // " description " : " Get the xchange code from the location redirect " // " header " : " Location " // " regex " : " code = ( . * ) &? . * " // } // // Will extract the value of code " 12345 " and make it available in the match m . Result field //
func checkHeaderRegexContext(m *Match, tc *TestCase) (bool, error) {
	var success bool
	var actualHeader string
	for head := range tc.Header {
		success = strings.EqualFold(head, m.Header)
		if success {
			actualHeader = head
			break
		}
	}
	headerValue := tc.Header.Get(actualHeader)
	regex, err := regexp.Compile(m.Regex)
	if err != nil {
		return false, err
	}
	result := regex.FindStringSubmatch(headerValue)
	if len(result) < 2 {
		return false, m.AppErr(fmt.Sprintf("Header Regex Context Match Failed - regex (%s) failed to find anything on Header (%s) value (%s)", m.Regex, m.Header, headerValue))
	}
	m.Result = result[1]
	return success, nil
}
func checkHeaderRegexContext ( m * Match , tc * TestCase ) ( bool , error ) { var success bool var actualHeader string for head := range tc . Header { success = strings . EqualFold ( head , m . Header ) if success { actualHeader = head break } } headerValue := tc . Header . Get ( actualHeader ) regex , err := regexp . Compile ( m . Regex ) if err != nil { return false , err } result := regex . FindStringSubmatch ( headerValue ) if len ( result ) < 2 { return false , m . AppErr ( fmt . Sprintf ( " " , m . Regex , m . Header , headerValue ) ) } m . Result = result [ 1 ] return success , nil }