Skip to content

Commit

Permalink
reverseproxy: Fix support for "4xx" type status codes
Browse files Browse the repository at this point in the history
  • Loading branch information
francislavoie committed Apr 1, 2021
1 parent 27de783 commit e75f92d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/caddyhttp/reverseproxy/caddyfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,7 @@ func (h *Handler) parseNamedResponseMatcher(d *caddyfile.Dispenser, matchers map
}

matcher.Headers = http.Header(headerMatcher)

case "status":
if matcher.StatusCode == nil {
matcher.StatusCode = []int{}
Expand All @@ -1043,12 +1044,16 @@ func (h *Handler) parseNamedResponseMatcher(d *caddyfile.Dispenser, matchers map
}

for _, arg := range args {
if len(arg) == 3 && strings.HasSuffix(arg, "xx") {
arg = arg[:1]
}
statusNum, err := strconv.Atoi(arg)
if err != nil {
return d.Errf("bad status value '%s': %v", arg, err)
}
matcher.StatusCode = append(matcher.StatusCode, statusNum)
}

default:
return d.Errf("unrecognized response matcher %s", d.Val())
}
Expand Down

0 comments on commit e75f92d

Please sign in to comment.