Skip to content

Commit

Permalink
Fix upstream_response_time parsing with colon in value (#267)
Browse files Browse the repository at this point in the history
The fix for correct parsing of multiple values in upstream_response_time
applied in #221 was only partial, as it accounts only for commas, but
the value can also contain colons as separators, when the request goes
through an internal redirect.

See the description for '$upstream_addr' in
https://nginx.org/en/docs/http/ngx_http_upstream_module.html for more
info.

Co-authored-by: Jan Kral <[email protected]>
  • Loading branch information
kralewitz and Jan Kral authored Oct 11, 2022
1 parent 0b56183 commit 81de497
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func floatFromFieldsMulti(fields map[string]string, name string) (float64, bool,

sum := float64(0)

for _, v := range strings.Split(val, ",") {
for _, v := range strings.FieldsFunc(val, func(r rune) bool { return r == ',' || r == ':' }) {
v = strings.TrimSpace(v)

if v == "-" {
Expand Down

0 comments on commit 81de497

Please sign in to comment.