| 89 | ) |
| 90 | |
| 91 | func extractStatusCode(lower string) int { |
| 92 | if matches := statusCodePattern.FindStringSubmatch(lower); len(matches) == 2 { |
| 93 | if code, err := strconv.Atoi(matches[1]); err == nil { |
| 94 | return code |
| 95 | } |
| 96 | return 0 |
| 97 | } |
| 98 | for _, loc := range standaloneStatusPattern.FindAllStringIndex(lower, -1) { |
| 99 | if shouldSkipStandaloneStatusMatch(lower, loc[0]) { |
| 100 | continue |
| 101 | } |
| 102 | if code, err := strconv.Atoi(lower[loc[0]:loc[1]]); err == nil { |
| 103 | return code |
| 104 | } |
| 105 | return 0 |
| 106 | } |
| 107 | return 0 |
| 108 | } |
| 109 | |
| 110 | func shouldSkipStandaloneStatusMatch(lower string, start int) bool { |
| 111 | // Skip values in host:port text. A later standalone status code in the |