]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: sample: zero-pad the fractional part emitted by http_date()
authorWilly Tarreau <w@1wt.eu>
Wed, 30 Sep 2026 08:49:48 +0000 (10:49 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 30 Sep 2026 14:11:24 +0000 (16:11 +0200)
commit5b515a38cef696a28a568fdbc41b16ac2ad863b4
tree4365a3c7ccce8915863b7eaebc1337b71aaae0c2
parent31703b81bb12cf1c80362a46a0d89af07afff327
BUG/MINOR: sample: zero-pad the fractional part emitted by http_date()

When http_date() is given the "ms" or "us" unit, it appends the
sub-second part of the date with a plain "%d", so it is printed without
any padding: 123 ms gives ".123" but 23 ms gives ".23", which stands
for a completely different instant, and 23 us gives ".23" as well
although the two units must not produce the same string.

The fraction is now printed over the number of digits its unit
requires, three for milliseconds and six for microseconds. The test
which selects the format is also made to depend on that width rather
than on the unit argument, which is equivalent but clearer.

The bug was introduced in 2.1-dev4 with commit ae6f125c7b ("MINOR:
sample: add us/ms support to date/http_date"), so this fix should
be backported to all stable branches.
src/http_conv.c